コード例 #1
0
 /**
  * @usage 获取被试的试卷信息,判断试卷是否全部完成,成功则返回试卷信息
  * @param int $project_id
  * @param int $examinee_id
  * @throws Exception
  * @return unknown
  */
 protected static function getPapers($project_id, $examinee_id)
 {
     $project_detail_json = MemoryCache::getProjectDetail($project_id);
     $project_detail = json_decode($project_detail_json->exam_json, true);
     $papers_tmp = QuestionAns::find(array("examinee_id = :examinee_id:", 'bind' => array('examinee_id' => $examinee_id)));
     if (count($papers_tmp) != count($project_detail)) {
         throw new Exception(self::$error_state . '-答卷数量不正确-' . count($papers_tmp) . '-' . count($project_detail));
     }
     $papers_id_tmp = array();
     foreach ($papers_tmp as $value) {
         $papers_id_tmp[] = $value->paper_id;
     }
     $project_papers_id = array();
     foreach ($project_detail as $key => $value) {
         $project_papers_id[] = MemoryCache::getPaperDetail($key)->id;
     }
     if (!array_diff($papers_id_tmp, $project_papers_id)) {
         return $papers_tmp;
     } else {
         throw new Exception(self::$error_state . '-答卷信息与题库信息不符-' . print_r($papers_id_tmp, true) . print_r($project_papers_id, true));
     }
 }
コード例 #2
0
 /**
  * @usage 返回被试应该写入的所有因子得分
  * @param int $examinee_id
  */
 protected static function getFactorsAll($examinee_id)
 {
     if (empty(self::$examinee_info)) {
         self::getExamineeInfo($examinee_id);
     }
     $project_info = MemoryCache::getProjectDetail(self::$examinee_info['project_id']);
     self::$factors_list_all = json_decode($project_info->factor_names, true);
 }
コード例 #3
0
 private static function check($option_str, &$number_array, $project_id, $paper_name, $paper_value_array)
 {
     $array_value_ks = $paper_value_array;
     $project_detail_json = MemoryCache::getProjectDetail($project_id);
     $project_detail = json_decode($project_detail_json->exam_json, true);
     $question_count = count($project_detail[$paper_name]);
     if ($question_count == count($number_array) && !array_diff($project_detail[$paper_name], $number_array)) {
         $option_array = explode('|', $option_str);
         if (count($option_array) == $question_count) {
             $option_array = array_flip(array_count_values($option_array));
             if (!array_diff($option_array, $array_value_ks)) {
                 return true;
             } else {
                 throw new Exception(self::$error_state . '-答案不在选项范围内-' . print_r(array_diff($option_array, $array_value_ks), true));
             }
         } else {
             throw new Exception(self::$error_state . '-答案数量与题目数量不符-' . $question_count . '-' . substr_count($option_str, '|'));
         }
     } else {
         throw new Exception(self::$error_state . '-题目数量与题库不符-' . print_r(array_diff($project_detail[$paper_name], $number_array), true));
     }
 }
コード例 #4
0
 /**
  * @usage 获取所有涉及到的因子得分数组
  * @param int $examinee_id
  */
 private static function getFactors($examinee_id)
 {
     $factors_ans = FactorAns::find(array("examinee_id = :examinee_id:", 'bind' => array('examinee_id' => $examinee_id)));
     if (count($factors_ans) == 0) {
         throw new Exception(self::$error_state . '-下层因子成绩未写入-' . count($factors_ans));
     }
     if (empty(self::$project_id)) {
         self::getProjectId($examinee_id);
     }
     $project_detail = MemoryCache::getProjectDetail(self::$project_id);
     $factor_needed = json_decode($project_detail->factor_names, true);
     foreach ($factor_needed as $key => $value) {
         if (is_scalar($value)) {
             $factor_detail = MemoryCache::getFactorDetail($value);
             $factor_id = $factor_detail->id;
             $factor_ans = FactorAns::findFirst(array("examinee_id = :examinee_id: AND factor_id = :factor_id:", 'bind' => array('examinee_id' => $examinee_id, 'factor_id' => $factor_id)));
             if (!isset($factor_ans->examinee_id)) {
                 throw new Exception(self::$error_state . '-因子计分未写入-name-' . $value . '-id-' . $factor_id);
             }
             self::$factors_list[$value] = $factor_ans->ans_score;
         } else {
             foreach ($value as $skey => $svalue) {
                 $factor_detail = MemoryCache::getFactorDetail($svalue);
                 $factor_id = $factor_detail->id;
                 $factor_ans = FactorAns::findFirst(array("examinee_id = :examinee_id: AND factor_id = :factor_id:", 'bind' => array('examinee_id' => $examinee_id, 'factor_id' => $factor_id)));
                 if (!isset($factor_ans->examinee_id)) {
                     throw new Exception(self::$error_state . '-因子计分未写入-name-' . $svalue . '-id-' . $factor_id);
                 }
                 self::$factors_list[$svalue] = $factor_ans->ans_score;
             }
         }
     }
     if (isset($factor_needed)) {
         unset($factor_needed);
     }
 }