Beispiel #1
0
    function JQ_GetQuestData_review($q_data, $jq_language, $user_answer, $show_correct, $show_correct_answer, $q_survey)
    {
        global $JLMS_DB, $JLMS_CONFIG, $option, $Itemid;
        $ret_str = '';
        $ret_add_script = '';
        $cur_template = 'joomlaquiz_lms_template';
        if ($cur_template) {
            require_once dirname(__FILE__) . '/templates/' . $cur_template . '/jq_template.php';
            $tmp = JLMS_ShowText_WithFeatures($q_data->c_question, true, true);
            $ret_add_script .= $tmp['js'];
            $q_description = JLMS_ShowText_WithFeatures($q_data->c_question, true);
            $ret_str = "\t" . '<quest_data><![CDATA[<div>' . $q_description . '</div>]]></quest_data>' . "\n";
            $ret_str .= "\t" . '<quest_type>' . $q_data->c_type . '</quest_type>' . "\n";
            $ret_str .= "\t" . '<quest_id>' . $q_data->old_c_id . '</quest_id>' . "\n";
            //$q_data->c_id
            $ret_str .= "\t" . '<prev_quest_id>' . (isset($q_data->prev_c_id) && $q_data->prev_c_id ? $q_data->prev_c_id : 0) . '</prev_quest_id>' . "\n";
            //$q_data->c_id
            $ret_str .= "\t" . '<quest_score>' . $q_data->c_point . '</quest_score>' . "\n";
            switch ($q_data->c_type) {
                case 1:
                case 12:
                    $sql_var = '';
                    $sql_table = '';
                    $sql_where = '';
                    if ($q_data->c_type == 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, a.c_right, '1' as c_review" . $sql_var . " FROM #__lms_quiz_t_choice as a" . $sql_table . " WHERE a.c_question_id = '" . $q_data->c_id . "'" . $sql_where . " ORDER BY a.ordering";
                    $JLMS_DB->SetQuery($query);
                    $choice_data = $JLMS_DB->LoadObjectList();
                    $qhtml = '';
                    if ($show_correct_answer) {
                        $qhtml = JoomlaQuiz_template_class::JQ_createMChoice($choice_data, $q_data->c_type);
                    }
                    $quhtml = '';
                    if ($show_correct || $q_survey) {
                        for ($i = 0; $i < count($choice_data); $i++) {
                            if ($choice_data[$i]->value == $user_answer) {
                                $choice_data[$i]->c_right = 1;
                            } else {
                                $choice_data[$i]->c_right = 0;
                            }
                        }
                        $quhtml .= '<div style="width:100%;"><div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table width="100%" align="left" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td>';
                        $quhtml .= JoomlaQuiz_template_class::JQ_createMChoice($choice_data, $q_data->c_type);
                        $quhtml .= '</td></tr></table><div style="clear: both;"><!-- --></div></div>';
                    }
                    if ($q_survey) {
                        $qhtml = '';
                    }
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div style=\'width:100%;\'><table width="100%" align="left" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td><form name=\'quest_form\'>' . $qhtml . '</form></td></tr></table><div style="clear: both;"><!-- --></div></div>' . $quhtml . ']]></quest_data_user>' . "\n";
                    break;
                case 3:
                    $query = "SELECT c_id as value, c_choice as text, c_right, '1' as c_review FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $q_data->c_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 = '';
                    if ($show_correct_answer) {
                        $qhtml = JoomlaQuiz_template_class::JQ_createMChoice($choice_data, $q_data->c_type);
                    }
                    $quhtml = '';
                    if ($show_correct) {
                        for ($i = 0; $i < count($choice_data); $i++) {
                            if ($choice_data[$i]->value == $user_answer) {
                                $choice_data[$i]->c_right = 1;
                            } else {
                                $choice_data[$i]->c_right = 0;
                            }
                        }
                        $quhtml .= '<div style="width:100%;"><div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table align="left" width="100%" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td>';
                        $quhtml .= JoomlaQuiz_template_class::JQ_createMChoice($choice_data, $q_data->c_type);
                        $quhtml .= '</td></tr></table><div style="clear: both;"><!-- --></div></div>';
                    }
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div style=\'width:100%;\'><table width="100%" align="left" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td><form name=\'quest_form\'>' . $qhtml . '</form></td></tr></table></div>' . $quhtml . ']]></quest_data_user>' . "\n";
                    break;
                case 2:
                case 13:
                    $sql_var = '';
                    $sql_table = '';
                    $sql_where = '';
                    if ($q_data->c_type == 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, a.c_right, '1' as c_review" . $sql_var . " FROM #__lms_quiz_t_choice as a" . $sql_table . " WHERE a.c_question_id = '" . $q_data->c_id . "'" . $sql_where . " ORDER BY a.ordering";
                    $JLMS_DB->SetQuery($query);
                    $choice_data = $JLMS_DB->LoadObjectList();
                    $qhtml = '';
                    if ($show_correct_answer) {
                        $qhtml = JoomlaQuiz_template_class::JQ_createMResponse($choice_data, $q_data->c_type);
                    }
                    if ($show_correct || $q_survey) {
                        for ($i = 0; $i < count($choice_data); $i++) {
                            if (in_array($choice_data[$i]->value, $user_answer)) {
                                $choice_data[$i]->c_right = 1;
                            } else {
                                $choice_data[$i]->c_right = 0;
                            }
                        }
                        $quhtml = '';
                        $quhtml .= '<div style="width:100%;"><div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table width="100%" align="left" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td>';
                        $quhtml .= JoomlaQuiz_template_class::JQ_createMResponse($choice_data, $q_data->c_type);
                        $quhtml .= '</td></tr></table></div>';
                    }
                    if ($q_survey) {
                        $qhtml = '';
                    }
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div style=\'width:100%;\'><table width="100%" align="left" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td><form name=\'quest_form\'>' . $qhtml . '</form></td></tr></table></div>' . $quhtml . ']]></quest_data_user>' . "\n";
                    break;
                case 4:
                    $query = "SELECT *, c_right_text as c_val FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $q_data->c_id . "'" . "\n ORDER BY ordering";
                    $JLMS_DB->SetQuery($query);
                    $match_data = $JLMS_DB->LoadObjectList();
                    $shuffle_match = $match_data;
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div>' . "\n";
                    if ($show_correct_answer) {
                        $ret_str .= '<div style=\'width:100%;text-align:center\'><table id=\'quest_table\' align=\'center\' cellpadding="10" cellspacing="0" border="0" class="jlms_table_no_borders">';
                        for ($i = 0, $n = count($match_data); $i < $n; $i++) {
                            $ret_str .= '<tr><td style="padding:10px"><div id=\'cdiv_' . ($i + 1) . '\' class=\'jq_drop_pre\' align="center">' . $match_data[$i]->c_left_text . '</div></td><td style="padding:10px"><div id=\'ddiv_' . ($i + 1) . '\' class=\'jq_drag_pre\'>' . $shuffle_match[$i]->c_right_text . '</div></td></tr>';
                        }
                        $ret_str .= '</table></div>' . "\n";
                    }
                    if ($show_correct) {
                        $ret_str .= '<div style=\'width:100%;text-align:center\'><div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table id=\'quest_table2\' align="center" cellpadding="10" cellspacing="0" border="0" class="jlms_table_no_borders">';
                        for ($i = 0, $n = count($match_data); $i < $n; $i++) {
                            $ret_str .= '<tr><td style="padding:10px"><div id=\'cdiv_' . ($i + 1) . '\' class=\'jq_drop_pre\'>' . $match_data[$i]->c_left_text . '</div></td><td style="padding:10px"><div id=\'ddiv_' . ($i + 1) . '\' class=\'jq_drag_pre\'>' . $user_answer[$i] . '</div></td></tr>';
                        }
                        $ret_str .= '</table></div>' . "\n";
                    }
                    $ret_str .= '<form name=\'quest_form\'></form></div>]]></quest_data_user>' . "\n";
                    break;
                case 5:
                    $query = "SELECT *, c_right_text as c_val FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $q_data->c_id . "'" . "\n ORDER BY ordering";
                    $JLMS_DB->SetQuery($query);
                    $match_data = $JLMS_DB->LoadObjectList();
                    $shuffle_match = $match_data;
                    $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', 'class="inputbox" size="1" disabled', 'c_val', 'c_right_text', $shuffle_match1[$i + 1]->c_right_text);
                    }
                    $qhtml = '';
                    if ($show_correct_answer) {
                        $qhtml = JoomlaQuiz_template_class::JQ_createMDropDown($qdata);
                    }
                    $quhtml = '';
                    if ($show_correct) {
                        $quhtml .= '<div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table align="center" class="jlms_table_no_borders"><tr><td>';
                        for ($i = 0, $n = count($qdata); $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_u', 'class="inputbox" size="1" disabled', 'c_val', 'c_right_text', $user_answer[$i]);
                        }
                        $quhtml .= JoomlaQuiz_template_class::JQ_createMDropDown($qdata);
                        $quhtml .= '</td></tr></table>';
                    }
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div><form name=\'quest_form\'>' . $qhtml . $quhtml . '</form></div>]]></quest_data_user>' . "\n";
                    break;
                case 6:
                    $query = "SELECT t.c_text FROM #__lms_quiz_t_blank as b, #__lms_quiz_t_text as t" . "\n WHERE b.c_question_id = '" . $q_data->c_id . "' AND t.c_blank_id = b.c_id" . "\n ORDER BY t.ordering";
                    $JLMS_DB->SetQuery($query);
                    $blank_data = $JLMS_DB->LoadObjectList();
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div><form name=\'quest_form\'>' . "\n";
                    $qhtml = '';
                    if ($show_correct_answer) {
                        foreach ($blank_data as $bl_one) {
                            $qhtml .= JoomlaQuiz_template_class::JQ_createBlankReview($bl_one->c_text) . "<br />";
                        }
                    }
                    $quhtml = '';
                    if ($show_correct || $q_survey) {
                        $quhtml .= '<div><div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table align="center" cellpadding="0" cellspacing="0" class="jlms_table_no_borders"><tr><td>';
                        $quhtml .= JoomlaQuiz_template_class::JQ_createBlankReview($user_answer);
                        $quhtml .= '</td></tr></table></div>';
                    }
                    if ($q_survey) {
                        $qhtml = '';
                    }
                    $ret_str .= $qhtml . "\n" . "\t" . '</form>' . $quhtml . '</div>]]></quest_data_user>' . "\n";
                    break;
                case 7:
                    $query = "SELECT * FROM #__lms_quiz_t_hotspot WHERE c_question_id = '" . $q_data->c_id . "'";
                    $JLMS_DB->SetQuery($query);
                    $hotspot_data = $JLMS_DB->LoadObjectList();
                    $hs_lefttop_x = 0;
                    $hs_lefttop_y = 0;
                    $hs_rightbottom_x = 0;
                    $hs_rightbottom_y = 0;
                    if (isset($hotspot_data[0])) {
                        $hs_lefttop_x = $hotspot_data[0]->c_start_x;
                        $hs_lefttop_y = $hotspot_data[0]->c_start_y;
                        $hs_rightbottom_x = $hotspot_data[0]->c_width;
                        $hs_rightbottom_y = $hotspot_data[0]->c_height;
                    }
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div>';
                    $ret_str .= '<div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div>';
                    $ret_str .= '<center><table class="jlms_table_no_borders"><tr><td align="center"><div style="text-align:left; position:relative;">';
                    if ($show_correct) {
                        $ret_str .= '<div id="div_hotspot_rec2" style="background:url(\'' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/includes/quiz/templates/joomlaquiz_lms_template/images/hs_round.png\'); z-index:1002; width:12px; height:12px;  position:absolute; left:' . ($user_answer[0] - 6) . 'px; top:' . ($user_answer[1] + 6) . 'px;"></div>';
                    }
                    if ($show_correct_answer) {
                        $ret_str .= '<div id="div_hotspot_rec" style="background-color:#FFFFFF; z-index:1001; ' . (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT']) ? "filter:alpha(opacity=50);" : '') . ' -moz-opacity:.50; opacity:.50; border:1px solid #000000; position:absolute; left:' . $hs_lefttop_x . 'px; top:' . $hs_lefttop_y . 'px; width:' . $hs_rightbottom_x . 'px; height:' . $hs_rightbottom_y . 'px; "><img src="' . $JLMS_CONFIG->get('live_site') . '/images/blank.png" border="0" width="1" height="1"></div>';
                    }
                    $ret_str .= '<form name=\'quest_form\'><img id=\'img_hotspot\' style=\'position:relative; z-index:999;\' src=\'' . $JLMS_CONFIG->get('live_site') . '/images/joomlaquiz/images/' . $q_data->c_image . '\' />' . '<input type=\'hidden\' name=\'hotspot_x\' value=\'0\' />' . '<input type=\'hidden\' name=\'hotspot_y\' value=\'0\' /></form></div></td></tr></table></center></div>]]></quest_data_user>' . "\n";
                    break;
                case 8:
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<form name=\'quest_form\'>' . "\n";
                    $qhtml = JoomlaQuiz_template_class::JQ_createSurvey(1, $user_answer);
                    $ret_str .= $qhtml . "\n" . "\t" . '</form>]]></quest_data_user>' . "\n";
                    break;
                case 9:
                    $query = "SELECT * FROM #__lms_quiz_t_scale WHERE c_question_id = '" . $q_data->c_id . "'" . "\n ORDER BY ordering";
                    $JLMS_DB->SetQuery($query);
                    $scale_data = $JLMS_DB->LoadObjectList();
                    for ($i = 0; $i < count($scale_data); $i++) {
                        $scale_data[$i]->inchek = '';
                        if ($show_correct_answer) {
                            foreach ($user_answer as $uansw) {
                                if ($uansw[0] == $scale_data[$i]->c_id) {
                                    $scale_data[$i]->inchek = $uansw[1];
                                }
                            }
                        }
                    }
                    $qhtml = JoomlaQuiz_template_class::JQ_createScale($scale_data, 1);
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div><form name=\'quest_form\'>' . $qhtml . '</form></div>]]></quest_data_user>' . "\n";
                    break;
                case 10:
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<form name=\'quest_form\'>' . "\n";
                    $ret_str .= "\n" . "\t" . '</form>]]></quest_data_user>' . "\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 = '" . $q_data->c_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;
                    $ret_str .= "\t" . '<quest_data_user><![CDATA[<div>' . "\n\r";
                    if ($show_correct_answer) {
                        $ret_str .= '<div style=\'width:100%;text-align:center\'><table id=\'quest_table\' align="center" cellpadding="10" cellspacing="0" border="0" class="jlms_table_no_borders">';
                        for ($i = 0, $n = count($match_data); $i < $n; $i++) {
                            $ret_str .= '<tr><td style="padding:10px"><div id=\'cdiv_' . ($i + 1) . '\' class=\'jq_drop_pre\' 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 . '&Itemid=' . $Itemid . '&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 . '"/></div></td><td style="padding:10px"><div id=\'ddiv_' . ($i + 1) . '\' class=\'jq_drag_pre\' 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=' . $shuffle_match[$i]->c_right_text . '&Itemid=' . $Itemid . '&imgs_name=' . $shuffle_match[$i]->right_name . '&pic_width=' . $JLMS_CONFIG->get('quiz_match_max_width', 250) . '&pic_height=' . $JLMS_CONFIG->get('quiz_match_max_height', 250)) . '" border="0" alt="' . $shuffle_match[$i]->right_name . '"/></div></td></tr>';
                        }
                        $ret_str .= '</table></div>' . "\n";
                    }
                    if ($show_correct) {
                        $ret_str .= '<div style=\'width:100%;text-align:center\'><div class="contentheading">' . _JLMS_QUIZ_REVIEW_YOUR_ANSWER . '</div><table id=\'quest_table\' align="center" cellpadding="10" cellspacing="0" border="0" class="jlms_table_no_borders">';
                        for ($i = 0, $n = count($match_data); $i < $n; $i++) {
                            $ret_str .= '<tr><td style="padding:10px"><div id=\'cdiv_' . ($i + 1) . '\' class=\'jq_drop_pre\' 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 . '&Itemid=' . $Itemid . '&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 . '"/></div></td><td style="padding:10px"><div id=\'ddiv_' . ($i + 1) . '\' class=\'jq_drag_pre\' 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=' . $user_answer[$i] . '&Itemid=' . $Itemid . '&pic_width=' . $JLMS_CONFIG->get('quiz_match_max_width', 250) . '&pic_height=' . $JLMS_CONFIG->get('quiz_match_max_height', 250)) . '" border="0" alt=""/></div></td></tr>';
                        }
                        $ret_str .= '</table></div>' . "\n";
                    }
                    $ret_str .= '<form name=\'quest_form\'></form></div>]]></quest_data_user>' . "\n";
                    break;
            }
            $ret_str .= "\t" . '<exec_quiz_script>1</exec_quiz_script>' . "\n";
            $ret_str .= "\t" . '<quiz_script_data><![CDATA[' . $ret_add_script . ']]></quiz_script_data>' . "\n";
        }
        return $ret_str;
    }