Ejemplo n.º 1
0
 function JQ_view_stuReport($id, $option, $page, $course_id)
 {
     global $JLMS_DB, $JLMS_SESSION, $Itemid, $JLMS_CONFIG;
     $limit = intval(mosGetParam($_REQUEST, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit'))));
     $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0));
     $JLMS_SESSION->set('list_limit', $limit);
     $query = "SELECT count(*) FROM #__lms_quiz_r_student_quiz_pool WHERE start_id = {$id}";
     $JLMS_DB->setQuery($query);
     $is_new_version_of_quiz = $JLMS_DB->LoadResult();
     $is_new_version_of_quiz_gqp = 0;
     if ($JLMS_CONFIG->get('global_quest_pool')) {
         $query = "SELECT count(*) FROM #__lms_quiz_r_student_quiz_gqp WHERE start_id = {$id}";
         $JLMS_DB->setQuery($query);
         $is_new_version_of_quiz_gqp = $JLMS_DB->LoadResult();
     }
     if ($is_new_version_of_quiz_gqp) {
         $query = "SELECT COUNT(a.c_id)" . "\n FROM #__lms_quiz_r_student_question as a, #__lms_quiz_r_student_quiz_gqp as b" . "\n WHERE a.c_stu_quiz_id = '" . $id . "' AND a.c_stu_quiz_id = b.start_id AND a.c_question_id = b.quest_id";
     } elseif ($is_new_version_of_quiz) {
         $query = "SELECT COUNT(a.c_id)" . "\n FROM #__lms_quiz_r_student_question as a, #__lms_quiz_r_student_quiz_pool as b" . "\n WHERE a.c_stu_quiz_id = '" . $id . "' AND a.c_stu_quiz_id = b.start_id AND a.c_question_id = b.quest_id";
     } else {
         $query = "SELECT COUNT(a.c_id)" . "\n FROM #__lms_quiz_r_student_question as a" . "\n WHERE a.c_stu_quiz_id = '" . $id . "'";
     }
     //echo $query; die;
     $JLMS_DB->setQuery($query);
     $total = $JLMS_DB->loadResult();
     require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php";
     $pageNav = new JLMSPageNav($total, $limitstart, $limit);
     if ($is_new_version_of_quiz_gqp) {
         $query = "SELECT sp.c_id, sp.c_score, q.c_type, q.c_point, q.c_question, qt.c_qtype, q.c_pool, q.c_pool_gqp" . "\n FROM #__lms_quiz_r_student_quiz_gqp as b, #__lms_quiz_r_student_question as sp LEFT JOIN #__lms_quiz_t_question as q ON sp.c_question_id = q.c_id LEFT JOIN #__lms_quiz_t_qtypes as qt ON q.c_type = qt.c_id" . "\n WHERE sp.c_stu_quiz_id = '" . $id . "' AND sp.c_stu_quiz_id = b.start_id AND sp.c_question_id = b.quest_id" . "\n ORDER BY b.ordering, q.c_id" . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
     } elseif ($is_new_version_of_quiz) {
         $query = "SELECT sp.c_id, sp.c_score, q.c_type, q.c_point, q.c_question, qt.c_qtype, q.c_pool, q.c_pool_gqp" . "\n FROM #__lms_quiz_r_student_quiz_pool as b, #__lms_quiz_r_student_question as sp LEFT JOIN #__lms_quiz_t_question as q ON sp.c_question_id = q.c_id LEFT JOIN #__lms_quiz_t_qtypes as qt ON q.c_type = qt.c_id" . "\n WHERE sp.c_stu_quiz_id = '" . $id . "' AND sp.c_stu_quiz_id = b.start_id AND sp.c_question_id = b.quest_id" . "\n ORDER BY b.ordering, q.c_id" . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
     } else {
         $query = "SELECT sp.c_id, sp.c_score, q.c_type, q.c_point, q.c_question, qt.c_qtype, q.c_pool, q.c_pool_gqp" . "\n FROM #__lms_quiz_r_student_question as sp LEFT JOIN #__lms_quiz_t_question as q ON sp.c_question_id = q.c_id LEFT JOIN #__lms_quiz_t_qtypes as qt ON q.c_type = qt.c_id" . "\n WHERE sp.c_stu_quiz_id = '" . $id . "'" . "\n ORDER BY q.ordering, q.c_id" . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
     }
     $JLMS_DB->SetQuery($query);
     $rows = $JLMS_DB->LoadObjectList();
     for ($i = 0; $i < count($rows); $i++) {
         $str = '_JLMS_QUIZ_QTYPE_' . $rows[$i]->c_type;
         if (defined($str)) {
             $rows[$i]->qtype_full = constant($str);
         }
     }
     /*-------------------QP--------------------*/
     $q_from_pool = array();
     foreach ($rows as $row) {
         if ($row->c_type == 20) {
             $q_from_pool[] = $row->c_pool;
         }
     }
     if (count($q_from_pool)) {
         $qp_ids = implode(',', $q_from_pool);
         $query = "SELECT a.*, b.c_qtype as qtype_full FROM #__lms_quiz_t_question as a LEFT JOIN #__lms_quiz_t_qtypes b ON b.c_id = a.c_type" . "\n WHERE a.course_id = '" . $course_id . "'";
         $JLMS_DB->setQuery($query);
         $rows2 = $JLMS_DB->loadObjectList();
         for ($i = 0; $i < count($rows2); $i++) {
             $str = '_JLMS_QUIZ_QTYPE_' . $rows2[$i]->c_type;
             if (defined($str)) {
                 $rows2[$i]->qtype_full = constant($str);
             }
         }
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             if ($rows[$i]->c_type == 20) {
                 for ($j = 0, $m = count($rows2); $j < $m; $j++) {
                     if ($rows[$i]->c_pool == $rows2[$j]->c_id) {
                         $rows[$i]->c_question = $rows2[$j]->c_question;
                         $rows[$i]->c_point = $rows2[$j]->c_point;
                         $rows[$i]->c_qtype = _JLMS_QUIZ_QUEST_POOL_SHORT . ' - ' . $rows2[$j]->qtype_full;
                         break;
                     }
                 }
             }
         }
     }
     /*----------------------GQP-------------------*/
     $q_from_pool_gqp = array();
     foreach ($rows as $row) {
         if ($row->c_type == 21) {
             $q_from_pool_gqp[] = $row->c_pool_gqp;
         }
     }
     if (count($q_from_pool_gqp)) {
         $qp_ids_gqp = implode(',', $q_from_pool_gqp);
         $query = "SELECT a.*, b.c_qtype as qtype_full FROM #__lms_quiz_t_question as a LEFT JOIN #__lms_quiz_t_qtypes b ON b.c_id = a.c_type" . "\n WHERE a.course_id = 0";
         $JLMS_DB->setQuery($query);
         $rows2 = $JLMS_DB->loadObjectList();
         for ($i = 0; $i < count($rows2); $i++) {
             $str = '_JLMS_QUIZ_QTYPE_' . $rows2[$i]->c_type;
             if (defined($str)) {
                 $rows2[$i]->qtype_full = constant($str);
             }
         }
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             if ($rows[$i]->c_type == 21) {
                 for ($j = 0, $m = count($rows2); $j < $m; $j++) {
                     if ($rows[$i]->c_pool_gqp == $rows2[$j]->c_id) {
                         $rows[$i]->c_question = $rows2[$j]->c_question;
                         $rows[$i]->c_point = $rows2[$j]->c_point;
                         $rows[$i]->c_qtype = _JLMS_QUIZ_QUEST_POOL_GQP_SHORT . ' - ' . $rows2[$j]->qtype_full;
                         break;
                     }
                 }
             }
         }
     }
     JLMS_quiz_admin_html_class::JQ_view_stuReport($rows, $pageNav, $option, $page, $course_id, $id);
 }