Example #1
0
}
$iconExercise = Display::return_icon('test-quiz.png', null, array(), ICON_SIZE_MEDIUM);
// Exercise name.
$html .= Display::page_header($iconExercise . $objExercise->name . ' ' . $edit_link);
//Exercise description
if (!empty($objExercise->description)) {
    $html .= Display::div($objExercise->description, array('class' => 'exercise_description'));
}
$extra_params = '';
if (isset($_GET['preview'])) {
    $extra_params = '&preview=1';
}
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, 0);
$attempt_list = null;
if (isset($exercise_stat_info['exe_id'])) {
    $attempt_list = Event::getAllExerciseEventByExeId($exercise_stat_info['exe_id']);
}
//1. Check if this is a new attempt or a previous
$label = get_lang('StartTest');
if ($time_control && !empty($clock_expired_time) || !empty($attempt_list)) {
    $label = get_lang('ContinueTest');
}
if (!empty($attempt_list)) {
    $message = Display::return_message(get_lang('YouTriedToResolveThisExerciseEarlier'));
}
// 2. Exercise button
// Notice we not add there the lp_item_view_id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_submit.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '&origin=' . $origin . '&learnpath_id=' . $learnpath_id . '&learnpath_item_id=' . $learnpath_item_id . $extra_params;
$exercise_url_button = Display::url($label, $exercise_url, array('class' => 'btn btn-success btn-large'));
//3. Checking visibility of the exercise (overwrites the exercise button)
$visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id, null, false);
    function save_remind_item(obj, question_id) {
        var action = "";
        if ($(obj).is(\':checked\')) {
            action = "add";
        } else {
            action = "delete";
        }
        $.ajax({
            url: "' . api_get_path(WEB_AJAX_PATH) . 'exercise.ajax.php?a=add_question_to_reminder",
            data: "question_id="+question_id+"&exe_id=' . $exe_id . '&action="+action,
            success: function(return_value) {
            }
        });
    }
</script>';
$attempt_list = Event::getAllExerciseEventByExeId($exe_id);
$remind_list = $exercise_stat_info['questions_to_check'];
$remind_list = explode(',', $remind_list);
$exercise_result = array();
foreach ($attempt_list as $question_id => $options) {
    foreach ($options as $item) {
        $question_obj = Question::read($item['question_id']);
        switch ($question_obj->type) {
            case FILL_IN_BLANKS:
                $item['answer'] = $objExercise->fill_in_blank_answer_to_string($item['answer']);
                break;
            case HOT_SPOT:
                break;
        }
        if ($item['answer'] != '0' && !empty($item['answer'])) {
            $exercise_result[] = $question_id;
    // Delineation
    if ($hotspot['hotspot_type'] == 'delineation') {
        $hotSpot['type'] = 'delineation';
    }
    // No error
    if ($hotspot['hotspot_type'] == 'noerror') {
        $hotSpot['type'] = 'noerror';
    }
    // This is a good answer, count + 1 for nmbr of clicks
    if ($hotspot['hotspot_type'] > 0) {
        $nmbrTries++;
    }
    $hotSpot['coord'] = $hotspot['hotspot_coordinates'];
    $data['hotspots'][] = $hotSpot;
}
$attemptList = Event::getAllExerciseEventByExeId($exerciseId);
if (!empty($attemptList)) {
    $questionAttempt = $attemptList[$questionId][0];
    if (!empty($questionAttempt->getAnswer())) {
        $coordinates = explode('|', $questionAttempt->getAnswer());
        foreach ($coordinates as $coordinate) {
            $data['answers'][] = Geometry::decodePoint($coordinate);
        }
    }
}
$data['nmbrTries'] = $nmbrTries;
$data['done'] = 'done';
if (Session::has('hotspot_ordered')) {
    $tempHotspots = [];
    $hotspotOrdered = Session::read('hotspot_ordered');
    foreach ($hotspotOrdered as $hotspotOrder) {