Ejemplo n.º 1
0
 function JQ_importQuestions($option, $page, $course_id, $gqp = false)
 {
     global $JLMS_DB, $Itemid;
     $quiz_id = intval(mosGetParam($_REQUEST, 'quiz_id', 0));
     $mode_id = intval(mosGetParam($_REQUEST, 'mode_id', 0));
     $lists = array();
     /*$javascript = 'onchange="toogleMode();"';
     	$mode = array();
     	$mode[] = mosHTML::makeOption( 0, 'Quiz' );
     	$mode[] = mosHTML::makeOption( 1, 'GQP' );
     	$lists['mode'] = mosHTML::selectList($mode, 'mode_id', 'class="inputbox" style="width: 266px;" size="1" '.$javascript, 'value', 'text', $gqp );
     	$lists['mode_id'] = $mode_id;
     	$gqp = $mode_id;*/
     if ($gqp) {
         $javascript = 'onclick="read_filter();" onchange="javascript:write_filter();';
         $javascript .= 'form.page.value=\'import_quest_gqp\';document.adminForm.submit();"';
         //Multicategories
         $levels = array();
         //NEW MULTICAT
         $tmp_level = array();
         $last_catid = 0;
         $i = 0;
         foreach ($_REQUEST as $key => $item) {
             if (preg_match('#level_id_(\\d+)#', $key, $result)) {
                 if ($item) {
                     $tmp_level[$i] = $result;
                     $last_catid = $item;
                     $i++;
                 }
             }
         }
         $tmp = array();
         $tmp = JLMS_quiz_admin_class::JLMS_multicats($last_catid, $tmp);
         $tmp = array_reverse($tmp);
         $tmp_pop = $tmp;
         $tmp_p = array_pop($tmp_pop);
         if (count($tmp) && $tmp_p->catid) {
             $next = count($tmp);
             $tmp[$next] = new stdClass();
             $tmp[$next]->catid = 0;
             $tmp[$next]->parent = $tmp_p->catid;
         }
         if (count($levels) == 0) {
             for ($i = 0; $i < 15; $i++) {
                 $num = $i + 1;
                 if ($i > 0) {
                     //						$levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS;
                     $levels[$i]->cat_name = 'Level #' . $num;
                 } else {
                     //						$levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS;
                     $levels[$i]->cat_name = 'Level #' . $num;
                 }
             }
         }
         $level_id = array();
         for ($i = 0; $i < count($levels); $i++) {
             if ($i == 0 || isset($tmp[$i]->parent) && $tmp[$i]->parent) {
                 //(Max): extra requests
                 $query = "SELECT * FROM `#__lms_gqp_cats` WHERE parent = '" . $tmp[$i]->parent . "' ORDER BY c_category";
                 $JLMS_DB->setQuery($query);
                 $groups = $JLMS_DB->loadObjectList();
                 if ($tmp[$i]->parent && $i > 0 && count($groups)) {
                     $type_level[$i][] = mosHTML::makeOption(0, '&nbsp;');
                     foreach ($groups as $group) {
                         $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category);
                     }
                     $lists['level_' . $i . ''] = mosHTML::selectList($type_level[$i], 'level_id_' . $i . '', 'class="inputbox" size="1" style="width:266px;" ' . $javascript, 'value', 'text', $tmp[$i]->catid);
                 } elseif ($i == 0) {
                     $type_level[$i][] = mosHTML::makeOption(0, '&nbsp;');
                     foreach ($groups as $group) {
                         $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category);
                     }
                     $lists['level_' . $i . ''] = mosHTML::selectList($type_level[$i], 'level_id_' . $i . '', 'class="inputbox" size="1" style="width:266px;" ' . $javascript, 'value', 'text', $tmp[$i]->catid);
                 }
             }
         }
         $lists['levels'] = $levels;
     } else {
         $query = "SELECT c_id as value, c_category as text FROM #__lms_quiz_t_category WHERE course_id = '" . $course_id . "' AND is_quiz_cat = 0 order by c_category";
         $JLMS_DB->setQuery($query);
         $jq_cats = array();
         $jq_cats[] = mosHTML::makeOption(0, ' -' . _JLMS_QUIZ_CAT_TYPE_QUEST . ' - ');
         $jq_cats = array_merge($jq_cats, $JLMS_DB->loadObjectList());
         $lists['jq_categories'] = mosHTML::selectList($jq_cats, 'c_qcat', 'class="inputbox" size="1" style="width:266px;"', 'value', 'text', 0);
     }
     JLMS_quiz_admin_html_class::JQ_showImportQuestions($option, $page, $course_id, $quiz_id, $lists, $gqp);
 }