function ReplaceCBProfileOptions($font_text, $txt_mes_obj, $user_id, $course_id) { require_once _JOOMLMS_FRONT_HOME . '/includes/classes/lms.cb_join.php'; $all_cb_f = JLMSCBJoin::get_Assocarray(); foreach ($all_cb_f as $cbf) { $tstr = '#' . $cbf . '#'; $first_pos = strpos($font_text, $tstr); if ($first_pos !== false) { $c = JLMSCBJoin::getASSOC($cbf); $font_text = str_replace($tstr, $c, $font_text); } } return $font_text; }
function JQ_GetQuestData_nojs($q_data, $jq_language, $stu_quiz_id = 0) { global $JLMS_DB, $my, $option, $JLMS_CONFIG; $ret_str = ''; $cur_template = 'joomlaquiz_lms_template'; if ($cur_template) { require_once dirname(__FILE__) . '/templates/' . $cur_template . '/jq_template.php'; $ret_add = ''; $test_text = $q_data->c_question; require_once dirname(__FILE__) . '/../lms_certificates.php'; $a = new stdClass(); $a->quiz_id = $q_data->c_quiz_id; $a->stu_quiz_id = $stu_quiz_id; $test_text = JLMS_Certificates::ReplaceQuizAnswers($test_text, $a, $my->id, $q_data->course_id); $test_text = JLMS_Certificates::ReplaceEventOptions($test_text, $a, $my->id, $q_data->course_id); $test_text = str_replace('#date#', date('m-d-Y', time() - date('Z')), $test_text); $q_data->c_question = $test_text; if ($q_data->c_type == 7) { //temporary for 'hotspot' support $ret_add = '<div style="text-align:center;">' . $q_data->c_question . '</div>'; } else { $q_description = JLMS_ShowText_WithFeatures($q_data->c_question, true); $ret_add = '<div style="text-align:center;">' . $q_description . '</div>'; } // $ret_str = "\t" . '<quest_data>'.$ret_add.'</quest_data>' . "\n"; $ret_str = "\t" . $ret_add . "\n"; $ret_str .= "\t" . '<input type="hidden" name="quest_type" value="' . $q_data->c_type . '"/>' . "\n"; $ret_str .= "\t" . '<input type="hidden" name="quest_id" value="' . $q_data->c_id . '"/>' . "\n"; $ret_str .= "\t" . '<input type="hidden" name="quest_score" value="' . $q_data->c_point . '"/>' . "\n"; $qtype = $q_data->c_type; $qu_id = $q_data->c_id; if ($q_data->c_pool) { $qu_id = $q_data->c_pool; } $quest_params = new JLMSParameters($q_data->params); switch ($qtype) { case 1: case 12: if ($quest_params->get('mandatory') == 1 && $quest_params->get('survey_question') == 1) { $is_mandatory = 1; } else { $is_mandatory = 0; } $sql_var = ''; $sql_table = ''; $sql_where = ''; if ($qtype == 12) { $sql_var .= ', b.imgs_name'; $sql_table = ', #__lms_quiz_images as b'; $sql_where .= ' AND a.c_choice = b.imgs_id'; } $query = "SELECT a.c_id as value, a.c_choice as text, '0' as c_right, '0' as c_review" . $sql_var . " FROM #__lms_quiz_t_choice as a" . $sql_table . " WHERE a.c_question_id = '" . $qu_id . "'" . $sql_where . " ORDER BY a.ordering"; $JLMS_DB->SetQuery($query); $choice_data = $JLMS_DB->LoadObjectList(); $qhtml = JoomlaQuiz_template_class::JQ_createMChoice($choice_data, $qtype); // $ret_str .= "\t" . '<quest_data_user><div>'.$qhtml.'<input type="hidden" name="ismandatory" value="'.$is_mandatory.'" /></div></quest_data_user>' . "\n"; $ret_str .= "\t" . '<div>' . $qhtml . '<input type="hidden" name="ismandatory" value="' . $is_mandatory . '" /></div>' . "\n"; break; case 3: $query = "SELECT c_id as value, c_choice as text, '0' as c_right, '0' as c_review FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $qu_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $choice_data = $JLMS_DB->LoadObjectList(); $i = 0; while ($i < count($choice_data)) { if ($choice_data[$i]->text == 'true' || $choice_data[$i]->text == 'True') { $choice_data[$i]->text = $jq_language['quiz_simple_true']; } elseif ($choice_data[$i]->text == 'false' || $choice_data[$i]->text == 'False') { $choice_data[$i]->text = $jq_language['quiz_simple_false']; } $i++; } $qhtml = JoomlaQuiz_template_class::JQ_createMChoice($choice_data, $qtype); $ret_str .= "\t" . '<div style="text-align:center;">' . $qhtml . '</div>' . "\n"; break; case 2: case 13: $sql_var = ''; $sql_table = ''; $sql_where = ''; if ($qtype == 13) { $sql_var .= ', b.imgs_name'; $sql_table = ', #__lms_quiz_images as b'; $sql_where .= ' AND a.c_choice = b.imgs_id'; } $query = "SELECT a.c_id as value, a.c_choice as text, '0' as c_right, '0' as c_review" . $sql_var . " FROM #__lms_quiz_t_choice as a" . $sql_table . " WHERE a.c_question_id = '" . $qu_id . "'" . $sql_where . " ORDER BY a.ordering"; $JLMS_DB->SetQuery($query); $choice_data = $JLMS_DB->LoadObjectList(); $qhtml = JoomlaQuiz_template_class::JQ_createMResponse($choice_data, $qtype, 1); $ret_str .= "\t" . '<div>' . $qhtml . '</div>' . "\n"; break; case 4: $query = "SELECT *, c_right_text as c_val FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $qu_id . "'" . "\n ORDER BY ordering"; $JLMS_DB->SetQuery($query); $match_data = $JLMS_DB->LoadObjectList(); $shuffle_match = $match_data; shuffle($shuffle_match); for ($di = 0, $dn = count($shuffle_match); $di < $dn; $di++) { $shuffle_match[$di]->c_val = md5($shuffle_match[$di]->c_val); } // $ret_str .= "\t" . '<div>' // . '<div id="cont" class="d_cont"><div id="col_1" style="float:left; width:49%;">'; // for ($i=0, $n = count( $match_data ); $i < $n; $i++ ) { // $ret_str .= '<div id=\'cdiv_'.($i+1).'\' class=\'jq_drop\'>' // . $match_data[$i]->c_left_text . '</div>'; // } // $ret_str .= '</div><div id="col_2" style="float:left; width:49%;">'; // for ($i=0, $n = count( $shuffle_match ); $i < $n; $i++ ) { // $ret_str .= '<div id=\'ddiv_'.($i+1).'\' class=\'jq_drag\'>' //onmousedown=\'startDrag()\' onmouseup=\'stopDrag()\' // . $shuffle_match[$i]->c_right_text . '</div>'; // } // $ret_str .= '</div><div style="clear:both;"><!-- --></div></div>'; // $ret_str .= '</div>' . "\n"; $shuffle_match1 = array(); $shuffle_match1[0]->c_right_text = _JLMS_QUIZ_SHOW_SELECT_YOUR_ANSWER; $shuffle_match1[0]->c_val = '{0}'; $shuffle_match1 = array_merge($shuffle_match1, $shuffle_match); $qdata = array(); for ($i = 0, $n = count($match_data); $i < $n; $i++) { $qdata[$i]->c_left_text = '<div class=\'jq_drop\'>' . $match_data[$i]->c_left_text . '</div>'; $qdata[$i]->c_right_text = mosHTML::selectList($shuffle_match1, 'quest_match[' . $i . ']', 'class="inputbox" size="1" ', 'c_val', 'c_right_text', null); } $qhtml = JoomlaQuiz_template_class::JQ_createMDropDown($qdata); $ret_str .= "\t" . '<div>' . $qhtml . '</div>' . "\n"; break; case 5: $query = "SELECT *, c_right_text as c_val FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $qu_id . "'" . "\n ORDER BY ordering"; $JLMS_DB->SetQuery($query); $match_data = $JLMS_DB->LoadObjectList(); $shuffle_match = $match_data; shuffle($shuffle_match); for ($di = 0, $dn = count($shuffle_match); $di < $dn; $di++) { $shuffle_match[$di]->c_val = md5($shuffle_match[$di]->c_val); } $shuffle_match1 = array(); $shuffle_match1[0]->c_right_text = _JLMS_QUIZ_SHOW_SELECT_YOUR_ANSWER; $shuffle_match1[0]->c_val = '{0}'; $shuffle_match1 = array_merge($shuffle_match1, $shuffle_match); $qdata = array(); for ($i = 0, $n = count($match_data); $i < $n; $i++) { $qdata[$i]->c_left_text = $match_data[$i]->c_left_text; $qdata[$i]->c_right_text = mosHTML::selectList($shuffle_match1, 'quest_match[' . $i . ']', 'class="inputbox" size="1" ', 'c_val', 'c_right_text', null); } $qhtml = JoomlaQuiz_template_class::JQ_createMDropDown($qdata); $ret_str .= "\t" . '<div>' . $qhtml . '</div>' . "\n"; break; case 6: //$quest_params = new JLMSParameters($q_data->params); if ($quest_params->get('mandatory') == 1 && $quest_params->get('survey_question') == 1) { $is_mandatory = 1; } else { $is_mandatory = 0; } $def_cb = ''; $def_cb = ''; if ($quest_params->get('survey_question')) { $query = "SELECT c_default FROM #__lms_quiz_t_blank WHERE c_question_id = '" . $qu_id . "'"; $JLMS_DB->SetQuery($query); $blank_data = $JLMS_DB->LoadObjectList(); if (isset($blank_data[0]->c_default) && $blank_data[0]->c_default) { $def_cb = $blank_data[0]->c_default; } } if ($def_cb) { $def_cb = str_replace('{', '', $def_cb); $def_cb = str_replace('}', '', $def_cb); require _JOOMLMS_FRONT_HOME . '/includes/classes/lms.cb_join.php'; $def_cb2 = JLMSCBJoin::getASSOC($def_cb); if ($def_cb2) { $def_cb = $def_cb2; } $def_cb = str_replace('#date#', date('m-d-Y', time() - date('Z')), $def_cb); } $qhtml = JoomlaQuiz_template_class::JQ_createBlank('', $def_cb); $ret_str .= '<div style="text-align:center;">' . $qhtml . '</div>' . "\n" . "\t" . '<input type="hidden" name="ismandatory" value="' . $is_mandatory . '" />' . "\n"; break; case 7: global $JLMS_CONFIG; $is_hotspot_manual_correct = $JLMS_CONFIG->get('quiz_hs_offset_manual_correction'); $hs_div_offset_class = $JLMS_CONFIG->get('quiz_hs_offset_div_class'); $hs_manual_offset = $JLMS_CONFIG->get('quiz_hs_ofset_manual_value'); $src = 'images/joomlaquiz/images/' . $q_data->c_image . ''; $qhtml = '<input type="image" name="hotspot" value="hs" src="' . $src . '"/>'; $ret_str .= "\t" . '<div style="text-align:center;">' . $qhtml . '</div>' . "\n"; break; case 8: if ($quest_params->get('mandatory') == 1) { $is_mandatory = 1; } else { $is_mandatory = 0; } $qhtml = JoomlaQuiz_template_class::JQ_createSurvey(); // 'Survey' - question type $ret_str .= '<div style="text-align:center;">' . $qhtml . "</div>\n" . "\t" . '<input type="hidden" name="ismandatory" value="' . $is_mandatory . '" />' . "\n"; break; case 9: if ($quest_params->get('mandatory') == 1) { $is_mandatory = 1; } else { $is_mandatory = 0; } $query = "SELECT * FROM #__lms_quiz_t_scale WHERE c_question_id = '" . $qu_id . "'" . "\n ORDER BY ordering"; $JLMS_DB->SetQuery($query); $scale_data = $JLMS_DB->LoadObjectList(); $qhtml = JoomlaQuiz_template_class::JQ_createScale($scale_data, 0); $ret_str .= "\t" . '<div>' . $qhtml . '<input type="hidden" name="ismandatory" value="' . $is_mandatory . '" /></div>' . "\n"; break; case 10: $ret_str .= "\n" . "\t" . '' . "\n"; break; case 11: $query = "SELECT a.*, a.c_right_text as c_val, 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 c_question_id = '" . $qu_id . "' AND a.c_left_text = b.imgs_id AND a.c_right_text = c.imgs_id" . "\n ORDER BY a.ordering"; $JLMS_DB->SetQuery($query); $match_data = $JLMS_DB->LoadObjectList(); $shuffle_match = $match_data; shuffle($shuffle_match); for ($di = 0, $dn = count($shuffle_match); $di < $dn; $di++) { $shuffle_match[$di]->c_val = md5($shuffle_match[$di]->c_val); } $shuffle_match1 = array(); $shuffle_match1[0]->right_name = _JLMS_QUIZ_SHOW_SELECT_YOUR_ANSWER; $shuffle_match1[0]->c_val = '{0}'; $shuffle_match1 = array_merge($shuffle_match1, $shuffle_match); $qdata = array(); for ($i = 0, $n = count($match_data); $i < $n; $i++) { $link = 'index.php?tmpl=component&option=' . $option . '&task=quizzes&page=imgs_v&file_id=' . $match_data[$i]->c_left_text . '&imgs_name=' . $match_data[$i]->left_name; $qdata[$i]->c_left_text = '<div class=\'jq_drop\' style=\'width: ' . $JLMS_CONFIG->get('quiz_match_max_width', 250) . 'px; height: ' . $JLMS_CONFIG->get('quiz_match_max_height', 30) . 'px;\'> <img src="' . ampReplace($JLMS_CONFIG->get('live_site') . '/index.php?tmpl=component&option=' . $option . '&task=quizzes&page=imgs_v&id=' . $q_data->course_id . '&file_id=' . $match_data[$i]->c_left_text . '&imgs_name=' . $match_data[$i]->left_name . '&pic_width=' . $JLMS_CONFIG->get('quiz_match_max_width', 250) . '&pic_height=' . $JLMS_CONFIG->get('quiz_match_max_height', 250) . '&bg_color=dddddd" border="0" alt="' . $match_data[$i]->left_name) . '" title="' . $match_data[$i]->left_name . '"/> </div>'; $qdata[$i]->c_right_text = mosHTML::selectList($shuffle_match1, 'quest_match[' . $i . ']', 'class="inputbox" size="1" ', 'c_val', 'right_name', null); } $qhtml = JoomlaQuiz_template_class::JQ_createMDropDown($qdata); $ret_str .= "\t" . '<div>' . $qhtml . '</div>' . "\n"; break; } } return $ret_str; }
function JLMS_showSpecRegPage($option, $course_id) { global $my, $JLMS_DB, $JLMS_CONFIG, $Itemid; if ($JLMS_CONFIG->get('course_spec_reg', 0) && $JLMS_CONFIG->get('current_usertype') == 2) { $pathway = array(); $pathway[] = array('name' => _JLMS_PATHWAY_HOME, 'link' => sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"), 'is_home' => true); JLMSAppendPathWay($pathway); JLMS_ShowHeading($JLMS_CONFIG->get('jlms_heading')); $query = "SELECT tip_message FROM #__lms_page_tips WHERE tip_task = 'pre_enrollment'"; $JLMS_DB->SetQuery($query); $tip = $JLMS_DB->LoadResult(); JLMS_TMPL::RenderPageTip($tip); $JLMS_ACL =& JLMSFactory::getACL(); $sr_role = intval($JLMS_ACL->GetRole(1)); $query = "SELECT role_id, id, course_question, is_optional, default_answer FROM #__lms_spec_reg_questions WHERE course_id = {$course_id} AND (role_id = 0 OR role_id = {$sr_role}) ORDER BY role_id DESC, ordering"; $JLMS_DB->SetQuery($query); $sr_quests = $JLMS_DB->LoadObjectList(); if (!empty($sr_quests)) { if ($JLMS_CONFIG->get('use_secure_enrollment', false) && $JLMS_CONFIG->get('secure_url') && !$JLMS_CONFIG->get('under_ssl', false)) { JLMSRedirect($JLMS_CONFIG->get('secure_url') . "/index.php?option=com_joomla_lms&Itemid={$Itemid}&task=spec_reg&id={$course_id}"); } require_once _JOOMLMS_FRONT_HOME . '/includes/classes/lms.cb_join.php'; $all_cb_f = JLMSCBJoin::get_Assocarray(); foreach ($all_cb_f as $cbf) { $tstr = '#' . $cbf . '#'; $ijk = 0; while ($ijk < count($sr_quests)) { $tmp = $sr_quests[$ijk]->default_answer; $first_pos = strpos($tmp, $tstr); if ($first_pos !== false) { $c = JLMSCBJoin::getASSOC($cbf); $sr_quests[$ijk]->default_answer = str_replace($tstr, $c, $tmp); } $ijk++; } } $sr_role = $sr_quests[0]->role_id; $sr_ids = array(); $prepared_questions = array(); foreach ($sr_quests as $srq) { if ($srq->role_id == $sr_role) { $sr_ids[] = $srq->id; $srq->is_answered = 0; $prepared_questions[] = $srq; } } if (!empty($sr_ids)) { $sr_idss = implode(',', $sr_ids); $query = "SELECT * FROM #__lms_spec_reg_answers WHERE course_id = {$course_id} AND user_id = {$my->id} AND role_id = {$sr_role} AND quest_id IN ({$sr_idss})"; $JLMS_DB->SetQuery($query); $sr_answs = $JLMS_DB->LoadObjectList(); foreach ($sr_answs as $sra) { $i = 0; while ($i < count($prepared_questions)) { if ($prepared_questions[$i]->id == $sra->quest_id && $prepared_questions[$i]->role_id == $sra->role_id) { $prepared_questions[$i]->default_answer = $sra->user_answer; if ($sra->user_answer) { $prepared_questions[$i]->is_answered = 1; } } $i++; } } } joomla_lms_html::showSR_page($option, $course_id, $prepared_questions); } else { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}")); } } else { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}")); } }
function &getArrays($field, $usr = null, $db = null) { static $assoc_ar; ob_start(); if ($db === null) { global $JLMS_DB; $db =& $JLMS_DB; } if ($usr === null) { global $my; $usr = $my->id; } if (!is_object($assoc_ar[$field])) { $assoc_ar[$field] = JLMSCBJoin::_createArrays($field, $usr, $db); } ob_end_clean(); return $assoc_ar[$field]; }