/** * Creates a new or edits and existing user record * @param int The id of the record, 0 if a new entry * @param string The current GET/POST option */ function editContact($id, $option) { global $database, $my; global $mosConfig_absolute_path; $row = new mosContact($database); // load the row from the db table $row->load($id); if ($id) { // do stuff for existing records $row->checkout($my->id); } else { // do stuff for new records $row->imagepos = 'top'; $row->ordering = 0; $row->published = 1; } $lists = array(); // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__contact_details" . "\n WHERE published >= 0" . "\n AND catid = '{$row->catid}'" . "\n ORDER BY ordering"; $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $id, $query, 1); // build list of users $lists['user_id'] = mosAdminMenus::UserSelect('user_id', $row->user_id, 1); // build list of categories $lists['catid'] = mosAdminMenus::ComponentCategory('catid', 'com_contact_details', intval($row->catid)); // build the html select list for images $lists['image'] = mosAdminMenus::Images('image', $row->image); // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); // build the html radio buttons for published $lists['published'] = mosHTML::yesnoradioList('published', '', $row->published); // build the html radio buttons for default $lists['default_con'] = mosHTML::yesnoradioList('default_con', '', $row->default_con); // get params definitions $file = $mosConfig_absolute_path . '/administrator/components/com_contact/contact_items.xml'; $params =& new mosAdminParameters($row->params, $file, 'component'); HTML_contact::editcontact($row, $lists, $option, $params); }
function JQ_editQuestion($id, $option, $qtype, $page, $course_id, $gqp = false) { global $JLMS_DB, $my, $JLMS_SESSION, $Itemid, $JLMS_CONFIG; if ($gqp && mosGetParam($_REQUEST, 'c_id')) { $query = "SELECT c_id FROM #__lms_quiz_t_question" . "\n WHERE c_id = '" . intval(mosGetParam($_REQUEST, 'c_id')) . "' AND course_id > 0 AND c_quiz_id > 0"; $JLMS_DB->setQuery($query); $c_id = $JLMS_DB->loadResult(); if ($c_id) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&page=setup_gqp")); } } $row = new mos_JoomQuiz_Question($JLMS_DB); $row->load($id); $quiz_id = intval(mosGetParam($_REQUEST, 'quiz_id', $JLMS_SESSION->get('quiz_id', 0))); $JLMS_ACL =& JLMSFactory::getACL(); if (!$JLMS_ACL->CheckPermissions('quizzes', 'manage')) { if ($JLMS_ACL->CheckPermissions('quizzes', 'manage_pool')) { $quiz_id = -1; if ($id) { if ($row->c_quiz_id == 0) { } else { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$course_id}&page=quizzes")); } } } } if ($id) { if ($row->c_quiz_id == 0) { $row->c_quiz_id = -1; } } elseif (mosGetParam($_REQUEST, 'level_id_0')) { $row->bind($_POST); /*Fix params (Max)*/ if (isset($row->params) && count($row->params)) { $row_params = $row->params; $row->params = ''; $i = 0; if (isset($row_params) && is_array($row_params) && count($row_params)) { foreach ($row_params as $key => $item) { $row->params .= $key . '=' . $item; if ($i < count($row_params)) { $row->params .= "\n"; } $i++; } } } /*Fix params (Max)*/ } else { // do stuff for new records $row->ordering = 0; $row->c_quiz_id = $quiz_id; //intval( mosGetParam( $_REQUEST, 'quiz_id', $JLMS_SESSION->get('quiz_id', 0 )) ); $row->c_type = intval(mosGetParam($_REQUEST, 'new_qtype_id', 1)); $row->c_question = "Enter question text here"; //$row->c_qcat = 0; } $params = new JLMSParameters($row->params); $params->def('disable_quest_feedback', 0); $params->def('survey_question', 0); $params->def('case_sensivity', 0); $lists = array(); $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"', 'value', 'text', $row->c_qcat); $is_pool = false; if ($row->c_quiz_id == -1) { $is_pool = true; } $query = "SELECT a.ordering AS value, a.c_question AS text, a.c_type, a.c_id, a.c_pool, a.c_pool_gqp" . "\n FROM #__lms_quiz_t_question AS a" . "\n WHERE a.course_id = '" . $course_id . "' " . ($row->c_quiz_id ? "\n AND a.c_quiz_id = " . ($is_pool ? 0 : $row->c_quiz_id) : '') . "\n ORDER BY a.ordering, a.c_id"; //$text_new_order = _C M N_NEW_ITEM_FIRST; //if ( $id ) { if (true) { ### $chop = 30; $order = array(); $JLMS_DB->setQuery($query); $orders = $JLMS_DB->loadObjectList(); if (empty($orders)) { $order[] = mosHTML::makeOption(0, _JLMS_SB_FIRST_ITEM); } else { // QuestPool compatibility $q_from_pool = array(); foreach ($orders as $rowtmp) { if ($rowtmp->c_type == 20) { $q_from_pool[] = $rowtmp->c_pool; } } if (count($q_from_pool)) { $qp_ids = implode(',', $q_from_pool); $query = "SELECT a.* FROM #__lms_quiz_t_question as a" . "\n WHERE a.course_id = '" . $course_id . "' AND a.c_id IN ({$qp_ids})"; $JLMS_DB->setQuery($query); $orders2 = $JLMS_DB->loadObjectList(); for ($i = 0, $n = count($orders); $i < $n; $i++) { if ($orders[$i]->c_type == 20) { for ($j = 0, $m = count($orders2); $j < $m; $j++) { if ($orders[$i]->c_pool == $orders2[$j]->c_id) { $orders[$i]->text = $orders2[$j]->c_question; break; } } } } } // Global QuestPool compatibility $q_from_pool_gqp = array(); foreach ($orders as $rowtmp) { if ($rowtmp->c_type == 21) { $q_from_pool_gqp[] = $rowtmp->c_pool_gqp; } } if (count($q_from_pool_gqp)) { $qp_ids_gqp = implode(',', $q_from_pool_gqp); $query = "SELECT a.* FROM #__lms_quiz_t_question as a" . "\n WHERE a.course_id = 0 AND a.c_id IN ({$qp_ids_gqp})"; $JLMS_DB->setQuery($query); $orders2 = $JLMS_DB->loadObjectList(); for ($i = 0, $n = count($orders); $i < $n; $i++) { if ($orders[$i]->c_type == 21) { for ($j = 0, $m = count($orders2); $j < $m; $j++) { if ($orders[$i]->c_pool_gqp == $orders2[$j]->c_id) { $orders[$i]->text = $orders2[$j]->c_question; break; } } } } } $order[] = mosHTML::makeOption(0, '0 ' . _JLMS_SB_FIRST_ITEM); for ($i = 0, $n = count($orders); $i < $n; $i++) { $temp_txt = $orders[$i]->text; mosMakeHtmlSafe($temp_txt); $temp_txt = strip_tags($temp_txt); if (strlen($temp_txt) > $chop) { $text = substr($temp_txt, 0, $chop) . "..."; } else { $text = $temp_txt; } $order[] = mosHTML::makeOption($orders[$i]->c_id, $orders[$i]->value . ' (' . $text . ')'); } $order[] = mosHTML::makeOption(-1, $orders[$i - 1]->value + 1 . ' ' . _JLMS_SB_LAST_ITEM); } ### $ordering = mosHTML::selectList($order, 'q_ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->c_id ? $row->c_id : -1)); //set ordering to last element for new questions and without changes for existent questions } $lists['ordering'] = $ordering; $query = "SELECT c_id AS value, c_title AS text" . "\n FROM #__lms_quiz_t_quiz" . "\n WHERE course_id = '" . $course_id . "' " . "\n ORDER BY c_title"; $JLMS_DB->setQuery($query); $quizzes = array(); $quizzes[] = mosHTML::makeOption('-1', _JLMS_QUIZ_QUEST_POOL); $quizzes = array_merge($quizzes, $JLMS_DB->loadObjectList()); $quiz = mosHTML::selectList($quizzes, 'c_quiz_id', 'class="inputbox" size="1" ', 'value', 'text', intval($row->c_quiz_id)); $lists['quiz'] = $quiz; $lists['c_wrong_message'] = ''; $lists['c_right_message'] = ''; $query = "SELECT * FROM #__lms_quiz_t_question_fb WHERE quest_id = {$id}"; $JLMS_DB->SetQuery($query); $q_fbs = $JLMS_DB->LoadObjectList(); foreach ($q_fbs as $qfb) { if ($qfb->choice_id == -1) { $lists['c_wrong_message'] = $qfb->fb_text; } elseif (!$qfb->choice_id) { $lists['c_right_message'] = $qfb->fb_text; } } $JLMS_DB->SetQuery("SELECT c_qtype FROM #__lms_quiz_t_qtypes WHERE c_id = '" . $row->c_type . "'"); $qtype_str = $JLMS_DB->LoadResult(); $str = '_JLMS_QUIZ_QTYPE_' . $row->c_type; if (defined($str)) { $qtype_str = constant($str); } if (mosGetParam($_REQUEST, 'c_type')) { $row->c_type = mosGetParam($_REQUEST, 'c_type'); } //---------------------------------------kosmos if ($row->c_type == 21) { $javascript = 'onclick="read_filter();" onchange="javascript:write_filter();form.page.value=\'add_quest\';document.adminForm.submit();"'; } else { $javascript = 'onclick="read_filter();" onchange="javascript:write_filter();form.page.value=\'edit_quest_gqp\';document.adminForm.submit();"'; } //FLMS multicategories $levels = array(); //NEW MULTICAT if ($id) { $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++; } } } if (!$i) { $query = "SELECT c_qcat FROM #__lms_quiz_t_question WHERE c_id = '" . $id . "'"; $JLMS_DB->setQuery($query); $last_catid = $JLMS_DB->loadResult(); } $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; } } else { $tmp_level = array(); $last_catid = 0; $exist_in_request = 0; $i = 0; foreach ($_REQUEST as $key => $item) { if (preg_match('#level_id_(\\d+)#', $key, $result)) { if (isset($item)) { $exist_in_request = 1; if ($item) { $tmp_level[$i] = $result; $last_catid = intval($item); $i++; } } } } if (!$last_catid && !$exist_in_request) { $last_catid = $JLMS_SESSION->get('S_last_catid'); } $JLMS_SESSION->set('S_last_catid', $last_catid); $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 = isset($tmp_p->catid) ? $tmp_p->catid : 0; } } /* $query = "SELECT * FROM #__lms_gqp_cats_config ORDER BY id"; $JLMS_DB->setQuery($query); $levels = $JLMS_DB->loadObjectList(); */ 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) { $level_id[$i] = intval(mosGetParam($_REQUEST, 'level_id_' . $i, 0)); $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); } else { $level_id[$i] = intval(mosGetParam($_REQUEST, 'level_id_' . $i, $JLMS_SESSION->get('GQP_level_id_' . $i, 0))); $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); } if ($i == 0) { $parent_id[$i] = 0; } else { $parent_id[$i] = $level_id[$i - 1]; } $query = "SELECT count(id) FROM `#__lms_gqp_cats` WHERE parent = '" . $parent_id[$i] . "' ORDER BY c_category"; $JLMS_DB->setQuery($query); $groups = $JLMS_DB->loadResult(); if ($groups == 0) { $level_id[$i] = 0; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); } } for ($i = 0; $i < count($levels); $i++) { if ($i > 0 && $level_id[$i - 1] == 0) { $level_id[$i] = 0; $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); $parent_id[$i] = 0; } elseif ($i == 0 && $level_id[$i] == 0) { $level_id[$i] = 0; $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); $parent_id[$i] = 0; } } 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, ' '); 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, ' '); 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); } } } $multicat = array(); $i = 0; foreach ($lists as $key => $item) { if (substr($key, 0, 6) == 'level_') { $multicat[] = $lists['level_' . $i]; $i++; } } $data = new stdClass(); $i = 0; foreach ($multicat as $m) { if (isset($level_id[$i])) { $str_preobj = 'level_' . $i; $data->{$str_preobj} = $level_id[$i]; } $i++; } $lists['data'] = $data; //---------------------------------------------- //echo $row->c_type; die; switch ($row->c_type) { case 1: case 12: if ($row->c_type == 12) { $query = "SELECT a.*, b.imgs_name FROM #__lms_quiz_t_choice as a, #__lms_quiz_images as b WHERE a.c_question_id = '" . $row->c_id . "' AND b.imgs_id = a.c_choice ORDER BY a.ordering"; } else { $query = "SELECT * FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $lists['random_answers'] = mosHTML::yesnoradioList('params[random_answers]', '', $params->get('random_answers', 0)); } $JLMS_DB->SetQuery($query); $row->choices = array(); $row->choices = $JLMS_DB->LoadObjectList(); if ($row->c_type == 12) { $query = "SELECT imgs_id, imgs_name, c_id as i_id FROM #__lms_quiz_images WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $row->images = array(); $row->images = $JLMS_DB->LoadObjectList(); } $q_om_type = $row->c_type; JLMS_quiz_admin_html_class::JQ_editQuest_MChoice($row, $lists, $option, $page, $course_id, $q_om_type, $qtype_str, $params, $id, $gqp, $levels); break; case 2: case 13: if ($row->c_type == 13) { $query = "SELECT a.*, b.imgs_name FROM #__lms_quiz_t_choice as a, #__lms_quiz_images as b WHERE a.c_question_id = '" . $row->c_id . "' AND b.imgs_id = a.c_choice ORDER BY a.ordering"; } else { $query = "SELECT * FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $lists['random_answers'] = mosHTML::yesnoradioList('params[random_answers]', '', $params->get('random_answers', 0)); } $JLMS_DB->SetQuery($query); $row->choices = array(); $row->choices = $JLMS_DB->LoadObjectList(); if ($row->c_type == 13) { $query = "SELECT imgs_id, imgs_name, c_id as i_id FROM #__lms_quiz_images WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $row->images = array(); $row->images = $JLMS_DB->LoadObjectList(); } $q_om_type = $row->c_type; JLMS_quiz_admin_html_class::JQ_editQuest_MChoice($row, $lists, $option, $page, $course_id, $q_om_type, $qtype_str, $params, $id, $gqp, $levels); break; case 3: $query = "SELECT * FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->choices = array(); $row->choices = $JLMS_DB->LoadObjectList(); $row->choice_true = 1; foreach ($row->choices as $eee) { if (strtolower($eee->c_choice) == "false" && $eee->c_right == 1) { $row->choice_true = 0; } } JLMS_quiz_admin_html_class::JQ_editQuest_TrueFalse($row, $lists, $option, $page, $course_id, 3, $qtype_str, $params, $id, $gqp, $levels); break; case 4: $query = "SELECT * FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->matching = array(); $row->matching = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_MDragDrop($row, $lists, $option, $page, $course_id, 4, $qtype_str, $params, $id, $gqp, $levels); break; case 5: $query = "SELECT * FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->matching = array(); $row->matching = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_MDragDrop($row, $lists, $option, $page, $course_id, 5, $qtype_str, $params, $id, $gqp, $levels); break; case 6: $query = "SELECT b.*,a.c_default FROM #__lms_quiz_t_blank as a, #__lms_quiz_t_text as b WHERE a.c_question_id = '" . $row->c_id . "' and b.c_blank_id = a.c_id ORDER BY b.ordering"; $JLMS_DB->SetQuery($query); $row->blank_data = array(); $row->blank_data = $JLMS_DB->LoadObjectList(); $query = "SELECT c_default FROM #__lms_quiz_t_blank WHERE c_question_id = '" . $row->c_id . "'"; $JLMS_DB->SetQuery($query); $lists['c_def'] = $JLMS_DB->LoadResult(); JLMS_quiz_admin_html_class::JQ_editQuest_Blank($row, $lists, $option, $page, $course_id, 6, $qtype_str, $params, $id, $gqp, $levels); break; case 7: $directory_js = $JLMS_CONFIG->get('live_site') . '/images/joomlaquiz/images/'; $directory = 'images/joomlaquiz/images/'; $javascript = "onchange=\"javascript:if (document.adminForm.c_image.options[selectedIndex].value!='') {" . " document.imagelib.src='{$directory}' + document.adminForm.c_image.options[selectedIndex].value; } else {" . " document.imagelib.src='" . $JLMS_CONFIG->get('live_site') . "/images/blank.png'}\""; $imageFiles = mosReadDirectory($JLMS_CONFIG->get('absolute_path') . '/' . $directory); $images = array(mosHTML::makeOption('', '- Select Image -')); foreach ($imageFiles as $file) { if (preg_match("/bmp|gif|jpg|png/i", $file)) { $images[] = mosHTML::makeOption($file); } } $lists['images'] = mosHTML::selectList($images, 'c_image', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', $row->c_image); //$lists['images'] = mosAdminMenus::images('c_image', $row->c_image, $javascript, $directory); $query = "SELECT * FROM #__lms_quiz_t_hotspot WHERE c_question_id = '" . $row->c_id . "'"; $JLMS_DB->SetQuery($query); $row->hotspot_data = array(); $row->hotspot_data = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_HotSpot($row, $lists, $option, $page, $course_id, 7, $qtype_str, $params, $id, $gqp, $levels); break; case 8: JLMS_quiz_admin_html_class::JQ_editQuest_Survey($row, $lists, $option, $page, $course_id, 8, $qtype_str, $params, $id, $gqp, $levels); break; case 9: $query = "SELECT * FROM #__lms_quiz_t_scale WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->scale = array(); $row->scale = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_Scale($row, $lists, $option, $page, $course_id, 9, $qtype_str, $params, $id, $gqp, $levels); break; case 10: JLMS_quiz_admin_html_class::JQ_editQuest_Boilerplate($row, $lists, $option, $page, $course_id, 10, $qtype_str, $params, $id, $gqp, $levels); break; case 11: $query = "SELECT a.*, b.imgs_name as left_name, c.imgs_name as right_name FROM #__lms_quiz_t_matching as a, #__lms_quiz_images as b, #__lms_quiz_images as c WHERE a.c_question_id = '" . $row->c_id . "' AND b.imgs_id = a.c_left_text AND c.imgs_id = a.c_right_text ORDER BY a.ordering"; $JLMS_DB->SetQuery($query); $row->matching = array(); $row->matching = $JLMS_DB->LoadObjectList(); $query = "SELECT imgs_id, imgs_name, c_id as i_id FROM #__lms_quiz_images WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $row->images = array(); $row->images = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_MDragDrop2($row, $lists, $option, $page, $course_id, 11, $qtype_str, $params, $id, $gqp, $levels); break; case 20: //add question from pool $query = "SELECT a.c_id AS value, a.c_question AS text" . "\n FROM #__lms_quiz_t_question AS a" . "\n WHERE a.course_id = '" . $course_id . "' " . "\n AND a.c_quiz_id = 0" . "\n ORDER BY a.ordering"; $qp_array = array(); $JLMS_DB->setQuery($query); $qp_list = $JLMS_DB->loadObjectList(); $qp_array[] = mosHTML::makeOption(0, '- Select question -'); for ($i = 0, $n = count($qp_list); $i < $n; $i++) { if (strlen(strip_tags($qp_list[$i]->text)) > 30) { $text = substr(strip_tags($qp_list[$i]->text), 0, 30) . "..."; } else { $text = strip_tags($qp_list[$i]->text); } $qp_array[] = mosHTML::makeOption($qp_list[$i]->value, $text); } $pool_quests = mosHTML::selectList($qp_array, 'c_pool', 'class="inputbox" size="1"', 'value', 'text', intval($row->c_pool)); $lists['pool_quests'] = $pool_quests; JLMS_quiz_admin_html_class::JQ_editQuest_Pool($row, $lists, $option, $page, $course_id, 20, $qtype_str); break; case 21: //add question from pool if (!$row->c_id) { $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit')))); $JLMS_SESSION->set('list_limit', $limit); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); $qtype_id = mosGetParam($_REQUEST, 'qtype_id', 0); $query = "SELECT c_pool_gqp" . "\n FROM #__lms_quiz_t_question" . "\n WHERE c_pool_gqp > 0 AND c_quiz_id = {$quiz_id}"; $JLMS_DB->setQuery($query); $result_array = $JLMS_DB->loadResultArray(); $use_ids = implode(',', $result_array); if ($use_ids) { $sql_use_ids = "\n AND a.c_id NOT IN ( {$use_ids} )"; } else { $sql_use_ids = ''; } $str = ''; //NEW MUSLTICATS /* $tmp_level = array(); $last_catid = 0; if(isset($_REQUEST['category_filter']) && $_REQUEST['category_filter']){ $last_catid = $_REQUEST['category_filter']; } else { $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++; } } } } */ $query = "SELECT * FROM #__lms_gqp_cats" . "\n ORDER BY id"; $JLMS_DB->setQuery($query); $all_cats = $JLMS_DB->loadObjectList(); $tmp_cats_filter = array(); $children = array(); foreach ($all_cats as $cat) { $pt = $cat->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $cat->id); $children[$pt] = $list; } $tmp_cats_filter[0] = $last_catid; $i = 1; foreach ($children as $key => $childs) { if ($last_catid == $key) { foreach ($children[$key] as $v) { if (!in_array($v, $tmp_cats_filter)) { $tmp_cats_filter[$i] = $v; $i++; } } } } foreach ($children as $key => $childs) { if (in_array($key, $tmp_cats_filter)) { foreach ($children[$key] as $v) { if (!in_array($v, $tmp_cats_filter)) { $tmp_cats_filter[$i] = $v; $i++; } } } } $tmp_cats_filter = array_unique($tmp_cats_filter); $catids = implode(",", $tmp_cats_filter); if ($last_catid && count($tmp_cats_filter)) { $str .= "\n AND a.c_qcat IN (" . $catids . ")"; } //NEW MUSLTICATS /*Old kosmosa for ($i=count($level_id);$i>-1;$i--) { if(isset($level_id[$i]) && $level_id[$i]) { $str = "\n AND d.cat_id = ".$level_id[$i]." AND d.level = $i"; break; } } */ $qp_array = array(); $query = "SELECT a.*, b.c_qtype as qtype_full, qc1.c_category" . "\n FROM #__lms_quiz_t_question AS a" . "\n LEFT JOIN #__lms_quiz_t_qtypes b ON b.c_id = a.c_type" . "\n LEFT JOIN #__lms_quiz_t_category as qc ON a.c_qcat = qc.c_id" . "\n LEFT JOIN #__lms_gqp_cats AS qc1 ON a.c_qcat = qc1.id" . "\n WHERE a.course_id = 0 " . "\n AND a.c_quiz_id = 0" . "\n AND a.published = 1" . ($str ? $str : ' ') . ($sql_use_ids ? $sql_use_ids : ' ') . ($qtype_id ? "\n AND a.c_type = '" . $qtype_id . "'" : '') . "\n GROUP BY a.c_id" . "\n ORDER BY a.ordering"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $total = $JLMS_DB->getNumRows(); require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php"; $pageNav = new JLMSPageNav($total, $limitstart, $limit); $JLMS_DB->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $JLMS_DB->loadObjectList(); //Tooltip Right Answer (Max - 15.04.2011) for ($i = 0; $i < count($rows); $i++) { if (in_array($rows[$i]->c_type, array(1, 2, 3))) { $right_answer = ''; $query = "SELECT c_choice" . "\n FROM" . "\n #__lms_quiz_t_choice" . "\n WHERE 1" . "\n AND c_right = 1" . "\n AND c_question_id = '" . $rows[$i]->c_id . "'"; $JLMS_DB->setQuery($query); $right_answer = $JLMS_DB->loadResult(); if (strlen($right_answer)) { $rows[$i]->right_answer = $right_answer; } } else { if (in_array($rows[$i]->c_type, array(20, 21))) { if ($rows[$i]->c_type == 20) { $select_field = "c_pool"; } else { if ($rows[$i]->c_type == 21) { $select_field = "c_pool_gqp"; } } $query = "SELECT " . $select_field . "\n FROM" . "\n #__lms_quiz_t_question" . "\n WHERE 1" . "\n AND c_id = '" . $rows[$i]->c_id . "'"; $JLMS_DB->setQuery($query); $question_id = $JLMS_DB->loadResult(); $right_answer = ''; if (intval($question_id)) { $query = "SELECT b.c_choice" . "\n FROM" . "\n #__lms_quiz_t_question as a" . "\n, #__lms_quiz_t_choice as b" . "\n WHERE 1" . "\n AND a.c_id = '" . $question_id . "'" . "\n AND b.c_question_id = '" . $question_id . "'" . "\n AND a.c_type IN (" . implode(',', array(1, 2, 3)) . ")" . "\n AND b.c_right = 1"; $JLMS_DB->setQuery($query); $right_answer = $JLMS_DB->loadResult(); } if (strlen($right_answer)) { $rows[$i]->right_answer = $right_answer; } } } } //Tooltip Right Answer (Max - 15.04.2011) /*old kosmosa if(mosGetParam($_REQUEST,'filter_id_0') || isset($_SESSION['GQP_filter_id_0'])) { for($i=0;$i<count($rows);$i++) { $new_level = $rows[$i]->level+1; $query = "SELECT b.c_category FROM #__lms_gqp_levels AS a, #__lms_gqp_cats AS b WHERE a.quest_id = '".$rows[$i]->c_id."' AND a.cat_id = b.id AND a.level = '".$new_level."'"; $JLMS_DB->SetQuery($query); $cat_name = $JLMS_DB->LoadResult(); if($cat_name) { $rows[$i]->c_category = $cat_name; } } } */ // $qp_array[] = mosHTML::makeOption( 0, '- Select question -' ); // for ($i=0, $n=count( $rows ); $i < $n; $i++) { // if (strlen($rows[$i]->text) > 30) { // $text = substr($rows[$i]->text,0,30)."..."; // } else { // $text = $qp_list[$i]->text; // } // $qp_array[] = mosHTML::makeOption( $qp_list[$i]->value, $text ); // } // $pool_quests = mosHTML::selectList( $qp_array, 'c_pool', 'class="inputbox" size="1"', 'value', 'text', intval( $row->c_pool ) ); // $lists['pool_quests'] = $pool_quests; $query = "SELECT c_id AS value, c_qtype AS text" . "\n FROM #__lms_quiz_t_qtypes" . "\n ORDER BY c_id"; $JLMS_DB->setQuery($query); $qtypes_lang = $JLMS_DB->loadObjectList(); for ($i = 0; $i < count($qtypes_lang); $i++) { $j = $i + 1; $str = '_JLMS_QUIZ_QTYPE_' . $j; if (defined($str)) { $qtypes_lang[$i]->value = $j; $qtypes_lang[$i]->text = constant($str); } } $qtypes[] = mosHTML::makeOption('0', _JLMS_SB_QUIZ_SELECT_QTYPE); $qtypes = array_merge($qtypes, $qtypes_lang); $qtype = mosHTML::selectList($qtypes, 'qtype_id', 'class="inputbox" style="width:200px" size="1" ' . $javascript, 'value', 'text', $qtype_id); $lists['qtype'] = $qtype; $lists['qtype_id'] = $qtype_id; $lists['published'] = mosHTML::yesnoradioList('published', '', 1); JLMS_quiz_admin_html_class::JQ_editQuest_Pool_GQP($row, $lists, $option, $page, $course_id, 21, $qtype_str, $rows, $pageNav, $levels); } else { // $query = "SELECT a.c_id AS value, a.c_question AS text" // . "\n FROM #__lms_quiz_t_question AS a " // . "\n , #__lms_gqp_levels d, #__lms_gqp_cats qc1" // . "\n WHERE a.course_id = 0 " // . "\n AND a.c_quiz_id = 0" // . "\n AND d.quest_id = a.c_id AND d.cat_id =qc1.id " // . "\n GROUP BY d.quest_id" // . "\n ORDER BY a.ordering" // ; // // $qp_array = array(); // $JLMS_DB->setQuery( $query ); // $qp_list = $JLMS_DB->loadObjectList(); // // $qp_array[] = mosHTML::makeOption( 0, '- Select question -' ); // // for ($i=0, $n=count( $qp_list ); $i < $n; $i++) { // if (strlen($qp_list[$i]->text) > 30) { // $text = substr($qp_list[$i]->text,0,30)."..."; // } else { // $text = $qp_list[$i]->text; // } // $qp_array[] = mosHTML::makeOption( $qp_list[$i]->value, $text ); // } // // $pool_quests = mosHTML::selectList( $qp_array, 'c_pool', 'class="inputbox" size="1"', 'value', 'text', intval( $row->c_pool_gqp ) ); // $lists['pool_quests'] = $pool_quests; // JLMS_quiz_admin_html_class::JQ_editQuest_Pool_gqp_edit($row, $lists, $option, $page, $course_id, 21, $qtype_str); } break; } }