Пример #1
0
 /**
  * 根据paper_id和用户id的集合来查找所有符合条件的答案
  * 两个参数可以是单独的id,也可以是数组集合
  */
 public static function getAns($paper_id, $examinee_id)
 {
     $cond = '';
     if (is_array($paper_id)) {
         $cond .= 'paper_id IN ({paper_id:array})';
     } else {
         $cond .= 'paper_id = :paper_id:';
     }
     $cond .= ' AND ';
     if (is_array($examinee_id)) {
         $cond .= 'examinee_id IN ({examinee_id:array})';
     } else {
         $cond .= 'examinee_id = :examinee_id:';
     }
     $anss = QuestionAns::find(array($cond, 'bind' => array('paper_id' => $paper_id, 'examinee_id' => $examinee_id)));
     return $anss;
 }
Пример #2
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));
     }
 }
Пример #3
0
 protected static function getPapersByExamineeId($examinee_id)
 {
     $rt_list = QuestionAns::find(array("examinee_id = :examinee_id:", 'bind' => array('examinee_id' => $examinee_id)));
     if (empty(self::$factors_list_all)) {
         self::getFactorsAll($examinee_id);
     }
     if (count($rt_list) != count(self::$factors_list_all)) {
         throw new Exception(self::$error_state . '-答卷数量不正确-' . count($rt_list) . '-' . count(self::$factors_list_all));
     }
     $papers_id_tmp = array();
     foreach ($rt_list as $value) {
         $papers_id_tmp[] = $value->paper_id;
     }
     $project_papers_id = array();
     foreach (self::$factors_list_all as $key => $value) {
         $project_papers_id[] = MemoryCache::getPaperDetail($key)->id;
     }
     if (!array_diff($papers_id_tmp, $project_papers_id)) {
         return $rt_list;
     } else {
         throw new Exception(self::$error_state . '-答卷信息与题库信息不符-' . print_r($papers_id_tmp, true) . print_r($project_papers_id, true));
     }
 }