Beispiel #1
0
 public function setexamrelatequestion($erq_examid, $erq_zmoss_examid)
 {
     $erq_examid = intval($erq_examid);
     $erq_zmoss_examid = intval($erq_zmoss_examid);
     $paper_id = intval(Fn::getParam('er_paperid'));
     $exam = ExamModel::get_exam($erq_examid);
     if (!$exam['exam_pid']) {
         message('请指定需要设置试题对应的考试学科!');
     }
     $examrelate = ZmossModel::examRelateInfo($erq_examid, $erq_zmoss_examid);
     if (!$examrelate) {
         message('此考试学科没有对应关系,无法设置试题关系!');
     }
     $zmossquestion = ZmossModel::examQuestionList($examrelate['er_zmoss_examid']);
     if (!$zmossquestion) {
         message('此考试学科对应阅卷系统的考试没有试题,无法设置试题关系!');
     }
     $paperlist = ExamPaperModel::examSubjectPaperList($erq_examid);
     if (!$paperlist) {
         message('此考试学科没有设置考试试卷,无法设置试题关系!');
     }
     if ($paper_id) {
         $paper = $paperlist[$paper_id];
     }
     if (!$paper) {
         $paper = current($paperlist);
     }
     /*
     $paperquestion = ExamPaperModel::examPaperQuestion(
         $paper['paper_id'], 'q.ques_id, q.parent_id, q.type, IFNULL(pq.type, q.type) AS p_type', 
         'AND q.is_parent = 0', 'ORDER BY p_type ASC, q.parent_id ASC, q.ques_id ASC');
     */
     $question = json_decode($paper['question_sort'], true);
     $paperquestion = array();
     foreach ($question as $k => $ques_id) {
         $info = QuestionModel::get_question($ques_id);
         $list = QuestionModel::get_children($ques_id);
         if ($list) {
             foreach ($list as $key => $val) {
                 $paperquestion[$val['ques_id']] = array('ques_id' => $val['ques_id'], 'type' => $info['type'], 'parent_id' => $ques_id);
             }
         } else {
             $paperquestion[$ques_id] = array('ques_id' => $ques_id, 'type' => $info['type']);
         }
     }
     $examrelatequestion = ZmossModel::examRelateQuestionInfo($erq_examid, $erq_zmoss_examid, $paper['paper_id']);
     $erq_relate_data = array();
     if ($examrelatequestion) {
         $erq_relate_data = json_decode($examrelatequestion['erq_relate_data'], true);
     }
     $data['examrelatequestion'] = $erq_relate_data;
     $data['examrelate'] = $examrelate;
     $data['paperquestion'] = $paperquestion;
     $data['zmossquestion'] = $zmossquestion;
     $data['qtype'] = C('qtype');
     $data['paperlist'] = $paperlist;
     $this->load->view('zmoss/setexamrelatequestion', $data);
 }