$category_list[$category_id]['score'] += $my_total_score;
         $category_list[$category_id]['total'] += $my_total_weight;
         $category_was_added_for_this_test = true;
     }
 }
 //No category for this question!
 if ($category_was_added_for_this_test == false) {
     $category_list['none']['score'] += $my_total_score;
     $category_list['none']['total'] += $my_total_weight;
 }
 if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
     $my_total_score = 0;
 }
 $score = array();
 if ($show_results) {
     $score['result'] = get_lang('Score') . " : " . show_score($my_total_score, $my_total_weight, false, false);
     $score['pass'] = $my_total_score >= $my_total_weight ? true : false;
     $score['type'] = $answerType;
     $score['score'] = $my_total_score;
     $score['weight'] = $my_total_weight;
     $score['comments'] = isset($comnt) ? $comnt : null;
 }
 unset($objAnswerTmp);
 $i++;
 $contents = ob_get_clean();
 $question_content = '<div class="question_row">';
 if ($show_results) {
     //Shows question title an description
     $question_content .= $objQuestionTmp->return_header(null, $counter, $score);
 }
 $counter++;
Example #2
0
    /**
     * Shows the user detail progress (when clicking in the details link)
     * @param   int     user id
     * @param   string  course code
     * @param   int     session id
     * @return  string  html code
     */
    static function show_course_detail($user_id, $course_code, $session_id)
    {
        $html = '';
        if (isset($course_code)) {

            $user_id                    = intval($user_id);
            $session_id                 = intval($session_id);
            $course                     = Database::escape_string($course_code);
            $course_info                = CourseManager::get_course_information($course);

            //$course_id                  = $course_info['real_id'];
            //$session_name               = api_get_session_name($session_id);

            $html .= Display::page_subheader($course_info['title']);

            $html .= '<table class="data_table" width="100%">';

            //Course details
            $html .= '
                <tr>
                <th class="head" style="color:#000">'.get_lang('Exercices').'</th>
                <th class="head" style="color:#000">'.get_lang('Attempts').'</th>
                <th class="head" style="color:#000">'.get_lang('BestAttempt').'</th>
                <th class="head" style="color:#000">'.get_lang('Ranking').'</th>
                <th class="head" style="color:#000">'.get_lang('BestResultInCourse').'</th>
                <th class="head" style="color:#000">'.get_lang('Statistics').' '.Display :: return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>
                </tr>';

            if (empty($session_id)) {
                $user_list  = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, STUDENT);
            } else {
                $user_list  = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, 0);
            }

            //$exercise_list = get_all_exercises($course_info, $session_id, true);
            // Show exercise results of invisible exercises? see BT#4091
            $exercise_list = get_all_exercises(
                $course_info,
                $session_id,
                false,
                null,
                false,
                1
            );

            $to_graph_exercise_result = array();

            if (!empty($exercise_list)) {
                $score = $weighting = $exe_id = 0;
                foreach ($exercise_list as $exercices) {

                    $exercise_obj = new Exercise($course_info['real_id']);
                    $exercise_obj->read($exercices['id']);
                    $visible_return = $exercise_obj->is_visible();

                    $score = $weighting = $attempts = 0;

                    //Getting count of attempts by user
                    $attempts      = count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);

                    $html .= '<tr class="row_even">';
                    $url = api_get_path(WEB_CODE_PATH)."exercice/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";

                    if ($visible_return['value'] == true) {
                        $exercices['title'] = Display::url($exercices['title'], $url, array('target'=>SESSION_LINK_TARGET));
                    }

                    $html .= Display::tag('td', $exercices['title']);

                    //Exercise configuration show results or show only score
                    if ($exercices['results_disabled'] == 0 || $exercices['results_disabled'] == 2) {
                        //For graphics
                        $best_exercise_stats = get_best_exercise_results_by_user($exercices['id'], $course_info['code'], $session_id);
                        $to_graph_exercise_result[$exercices['id']] = array('title'=>$exercices['title'], 'data'=>$best_exercise_stats);

                        $latest_attempt_url = '';
                        $best_score = $position = $percentage_score_result  = '-';
                        $graph = $normal_graph = null;

                        //Getting best results
                        $best_score_data = get_best_attempt_in_course($exercices['id'], $course_info['code'], $session_id);
                        $best_score      = show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);

                        if ($attempts > 0) {
                            $exercise_stat = get_best_attempt_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);
                            if (!empty($exercise_stat)) {

                                //Always getting the BEST attempt
                                $score          = $exercise_stat['exe_result'];
                                $weighting      = $exercise_stat['exe_weighting'];
                                $exe_id         = $exercise_stat['exe_id'];

                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH).'exercice/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
                                $percentage_score_result = Display::url(show_score($score, $weighting), $latest_attempt_url);
                                $my_score = 0;
                                if (!empty($weighting) && intval($weighting) != 0) {
                                    $my_score = $score/$weighting;
                                }
                                //@todo this function slows the page
                                $position = get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);

                                $graph         = self::generate_exercise_result_thumbnail_graph($to_graph_exercise_result[$exercices['id']]);
                                $normal_graph  = self::generate_exercise_result_graph($to_graph_exercise_result[$exercices['id']]);
                            }
                        }

                        $html .= Display::div($normal_graph, array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none') );

                        if (empty($graph)) {
                            $graph = '-';
                        } else {
                            $graph = Display::url($graph, '#', array('id'=>$exercices['id'], 'class'=>'opener'));
                        }

                        $html .= Display::tag('td', $attempts,                 array('align'=>'center'));
                        $html .= Display::tag('td', $percentage_score_result,  array('align'=>'center'));
                        $html .= Display::tag('td', $position,                 array('align'=>'center'));
                        $html .= Display::tag('td', $best_score,               array('align'=>'center'));
                        $html .= Display::tag('td', $graph,                    array('align'=>'center'));
                        //$html .= Display::tag('td', $latest_attempt_url,       array('align'=>'center', 'width'=>'25'));

                    } else {
                        // Exercise configuration NO results
                        $html .= Display::tag('td', $attempts,    array('align'=>'center'));
                        $html .= Display::tag('td', '-',          array('align'=>'center'));
                        $html .= Display::tag('td', '-',          array('align'=>'center'));
                        $html .= Display::tag('td', '-',          array('align'=>'center'));
                        $html .= Display::tag('td', '-',          array('align'=>'center'));
                    }
                    $html .= '</tr>';
                }
            } else {
                $html .= '<tr><td colspan="5" align="center">'.get_lang('NoEx').'</td></tr>';
            }
            $html .= '</table>';


            //LP table results
            $html .='<table class="data_table">';
            $html .= Display::tag('th', get_lang('Learnpaths'),         array('class'=>'head', 'style'=>'color:#000'));
            $html .= Display::tag('th', get_lang('LatencyTimeSpent'),   array('class'=>'head', 'style'=>'color:#000'));
            $html .= Display::tag('th', get_lang('Progress'),           array('class'=>'head', 'style'=>'color:#000'));
            $html .= Display::tag('th', get_lang('Score'),              array('class'=>'head', 'style'=>'color:#000'));
            $html .= Display::tag('th', get_lang('LastConnexion'),      array('class'=>'head', 'style'=>'color:#000'));
            $html .= '</tr>';

            $list = new LearnpathList(api_get_user_id(), $course_info['code'], $session_id, 'publicated_on ASC', true);
            $lp_list        = $list->get_flat_list();

            if (!empty($lp_list) > 0) {
                foreach($lp_list as $lp_id => $learnpath) {

                    $progress               = Tracking::get_avg_student_progress($user_id, $course, array($lp_id), $session_id);
                    $last_connection_in_lp  = Tracking::get_last_connection_time_in_lp($user_id, $course, $lp_id, $session_id);
                    $time_spent_in_lp       = Tracking::get_time_spent_in_lp($user_id, $course, array($lp_id), $session_id);
                    $percentage_score 		= Tracking::get_avg_student_score($user_id, $course, array($lp_id), $session_id);
                    if (is_numeric($percentage_score)) {
                        $percentage_score = $percentage_score.'%';
                    } else {
                        $percentage_score = '0%';
                    }

                    $time_spent_in_lp       = api_time_to_hms($time_spent_in_lp);

                    $html .= '<tr class="row_even">';
                    $url = api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
                    $html .= Display::tag('td', Display::url($learnpath['lp_name'], $url, array('target'=>SESSION_LINK_TARGET)));
                    $html .= Display::tag('td', $time_spent_in_lp, array('align'=>'center'));
                    if (is_numeric($progress)) {
                        $progress = $progress.'%';
                    }
                    $html .= Display::tag('td', $progress, array('align'=>'center'));
                    $html .= Display::tag('td', $percentage_score);

                    $last_connection = '-';
                    if (!empty($last_connection_in_lp)) {
                        $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
                    }
                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
                    $html .= "</tr>";
                }
            } else {
                $html .= '<tr>
                        <td colspan="4" align="center">
                            '.get_lang('NoLearnpath').'
                        </td>
                      </tr>';
            }
            $html .='</table>';
        }
        return $html;
    }
Example #3
0
/**
 * @param Exercise $objExercise
 * @param float $score
 * @param float $weight
 * @param bool $check_pass_percentage
 * @return string
 */
function get_question_ribbon($objExercise, $score, $weight, $check_pass_percentage = false)
{
    $ribbon = '<div class="ribbon">';
    if ($check_pass_percentage) {
        $is_success = is_success_exercise_result($score, $weight, $objExercise->selectPassPercentage());
        // Color the final test score if pass_percentage activated
        $ribbon_total_success_or_error = "";
        if (is_pass_pourcentage_enabled($objExercise->selectPassPercentage())) {
            if ($is_success) {
                $ribbon_total_success_or_error = ' ribbon-total-success';
            } else {
                $ribbon_total_success_or_error = ' ribbon-total-error';
            }
        }
        $ribbon .= '<div class="rib rib-total ' . $ribbon_total_success_or_error . '">';
    } else {
        $ribbon .= '<div class="rib rib-total">';
    }
    $ribbon .= '<h3>' . get_lang('YourTotalScore') . ":&nbsp;";
    $ribbon .= show_score($score, $weight, false, true);
    $ribbon .= '</h3>';
    $ribbon .= '</div>';
    if ($check_pass_percentage) {
        $ribbon .= show_success_message($score, $weight, $objExercise->selectPassPercentage());
    }
    $ribbon .= '</div>';
    return $ribbon;
}
Example #4
0
                        $best_score = show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
                    }
                    // Exercise results
                    $counter = 1;

                    foreach ($exercise_data as $exercise_item) {
                        $result_list     = $exercise_item['results'];
                        $exercise_info   = $exercise_item['exercise_data'];
                        if ($exercise_info->start_time == '0000-00-00 00:00:00') {
                            $start_date  = '-';
                        } else {
                            $start_date = $exercise_info->start_time;
                        }
                        if (!empty($result_list)) {
                            foreach ($result_list as $exercise_result) {
                                $platform_score = show_score($exercise_result['exe_result'], $exercise_result['exe_weighting']);
                                $my_score = 0;
                                if(!empty($exercise_result['exe_weighting']) && intval($exercise_result['exe_weighting']) != 0) {
                                    $my_score = $exercise_result['exe_result']/$exercise_result['exe_weighting'];
                                }
                                $position = get_exercise_result_ranking(
                                    $my_score,
                                    $exercise_result['exe_id'],
                                    $my_exercise_id,
                                    $my_course_code,
                                    $session_id,
                                    $user_list
                                );

                                $exercise_info->exercise = Display::url(
                                    $exercise_info->exercise,
Example #5
0
<?php

// Include Files
include "includes.inc.php";
// Session Identification
session_identification();
print_header();
print_title("Scoring board");
$cmd = input_check("show", "!tbl", "ofs", "uid", 0);
if ($cmd == "show") {
    if ($uid == "") {
        $uid = user_ourself();
    }
    show_score($tbl, $ofs, $uid);
    score_showuser($uid);
}
print_footer();
exit;
// ============================================================================================
//
//
// Description:
//
//
// Parameters:
//
//
// Returns:
//
//
function show_score($table, $offset, $user_id)
Example #6
0
             // else if not active
             $actions .= '    <a href="' . $exercicePath . '?' . api_get_cidreq() . '&hpchoice=enable&amp;page=' . $page . '&amp;file=' . $path . '">' . Display::return_icon('invisible.png', get_lang('Activate'), '', ICON_SIZE_SMALL) . '</a>';
         }
         $actions .= '<a href="' . $exercicePath . '?' . api_get_cidreq() . '&amp;hpchoice=delete&amp;file=' . $path . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('AreYouSureToDelete'), ENT_QUOTES, $charset) . ' ' . $title . "?") . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
         $item .= Display::tag('td', $actions);
         echo Display::tag('tr', $item, array('class' => $class));
     } else {
         // Student only
         if ($active == 1) {
             $attempt = getLatestHotPotatoResult($path, $userId, api_get_course_int_id(), api_get_session_id());
             $nbrActiveTests = $nbrActiveTests + 1;
             $item .= Display::tag('td', '<img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /> <a href="showinframes.php?' . api_get_cidreq() . '&file=' . $path . '&cid=' . api_get_course_id() . '&uid=' . $userId . '" ' . (!$active ? 'class="invisible"' : '') . ' >' . $title . '</a>');
             if (!empty($attempt)) {
                 $actions = '<a href="hotpotatoes_exercise_report.php?' . api_get_cidreq() . '&path=' . $path . '&filter_by_user='******'">' . Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL) . '</a>';
                 $attemptText = get_lang('LatestAttempt') . ' : ';
                 $attemptText .= show_score($attempt['exe_result'], $attempt['exe_weighting']) . ' ';
                 $attemptText .= $actions;
             } else {
                 // No attempts.
                 $attemptText = get_lang('NotAttempted') . ' ';
             }
             $item .= Display::tag('td', $attemptText);
             if ($isDrhOfCourse) {
                 $actions = '<a href="hotpotatoes_exercise_report.php?' . api_get_cidreq() . '&path=' . $path . '">' . Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL) . '</a>';
                 $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
             }
             echo Display::tag('tr', $item, array('class' => $class));
         }
     }
     $count++;
 }
Example #7
0
/**
 * Display the exercise results
 * @param obj   exercise obj
 * @param int   attempt id (exe_id)
 * @param bool  save users results (true) or just show the results (false)
 */
function display_question_list_by_attempt($objExercise, $exe_id, $save_user_result = false)
{
    global $origin, $debug;
    //Getting attempt info
    $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
    //Getting question list
    $question_list = array();
    if (!empty($exercise_stat_info['data_tracking'])) {
        $question_list = explode(',', $exercise_stat_info['data_tracking']);
    } else {
        //Try getting the question list only if save result is off
        if ($save_user_result == false) {
            $question_list = $objExercise->get_validated_question_list();
        }
        error_log("Data tracking is empty! exe_id: {$exe_id}");
    }
    $counter = 1;
    $total_score = $total_weight = 0;
    $exercise_content = null;
    //Hide results
    $show_results = false;
    $show_only_score = false;
    if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS) {
        $show_results = true;
    }
    if (in_array($objExercise->results_disabled, array(RESULT_DISABLE_SHOW_SCORE_ONLY, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES))) {
        $show_only_score = true;
    }
    // Not display expected answer, but score, and feedback
    $show_all_but_expected_answer = false;
    if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) {
        $show_all_but_expected_answer = true;
        $show_results = true;
        $show_only_score = false;
    }
    if ($show_results || $show_only_score) {
        $user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
        //Shows exercise header
        echo $objExercise->show_exercise_result_header($user_info['complete_name'], api_convert_and_format_date($exercise_stat_info['start_date'], DATE_TIME_FORMAT_LONG), $exercise_stat_info['duration']);
    }
    // Display text when test is finished #4074 and for LP #4227
    $end_of_message = $objExercise->selectTextWhenFinished();
    if (!empty($end_of_message)) {
        Display::display_normal_message($end_of_message, false);
        echo "<div class='clear'>&nbsp;</div>";
    }
    $question_list_answers = array();
    $media_list = array();
    $category_list = array();
    // Loop over all question to show results for each of them, one by one
    if (!empty($question_list)) {
        if ($debug) {
            error_log('Looping question_list ' . print_r($question_list, 1));
        }
        foreach ($question_list as $questionId) {
            // creates a temporary Question object
            $objQuestionTmp = Question::read($questionId);
            //this variable commes from exercise_submit_modal.php
            ob_start();
            // We're inside *one* question. Go through each possible answer for this question
            $result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null, 'exercise_result', array(), $save_user_result, true, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
            if (empty($result)) {
                continue;
            }
            $total_score += $result['score'];
            $total_weight += $result['weight'];
            $question_list_answers[] = array('question' => $result['open_question'], 'answer' => $result['open_answer'], 'answer_type' => $result['answer_type']);
            $my_total_score = $result['score'];
            $my_total_weight = $result['weight'];
            //Category report
            $category_was_added_for_this_test = false;
            if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
                $category_list[$objQuestionTmp->category]['score'] += $my_total_score;
                $category_list[$objQuestionTmp->category]['total'] += $my_total_weight;
                $category_was_added_for_this_test = true;
            }
            if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
                foreach ($objQuestionTmp->category_list as $category_id) {
                    $category_list[$category_id]['score'] += $my_total_score;
                    $category_list[$category_id]['total'] += $my_total_weight;
                    $category_was_added_for_this_test = true;
                }
            }
            //No category for this question!
            if ($category_was_added_for_this_test == false) {
                $category_list['none']['score'] += $my_total_score;
                $category_list['none']['total'] += $my_total_weight;
            }
            if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
                $my_total_score = 0;
            }
            $comnt = null;
            if ($show_results) {
                $comnt = get_comments($exe_id, $questionId);
                if (!empty($comnt)) {
                    echo '<b>' . get_lang('Feedback') . '</b>';
                    echo '<div id="question_feedback">' . $comnt . '</div>';
                }
            }
            $score = array();
            if ($show_results) {
                $score['result'] = get_lang('Score') . " : " . show_score($my_total_score, $my_total_weight, false, true);
                $score['pass'] = $my_total_score >= $my_total_weight ? true : false;
                $score['score'] = $my_total_score;
                $score['weight'] = $my_total_weight;
                $score['comments'] = $comnt;
            }
            $contents = ob_get_clean();
            $question_content = '<div class="question_row">';
            if ($show_results) {
                $show_media = false;
                /*if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
                      $show_media = true;
                      $media_list[] = $objQuestionTmp->parent_id;
                  }*/
                //Shows question title an description
                $question_content .= $objQuestionTmp->return_header(null, $counter, $score);
            }
            $counter++;
            $question_content .= $contents;
            $question_content .= '</div>';
            $exercise_content .= $question_content;
        }
        // end foreach() block that loops over all questions
    }
    $total_score_text = null;
    if ($origin != 'learnpath') {
        if ($show_results || $show_only_score) {
            $total_score_text .= $objExercise->get_question_ribbon($total_score, $total_weight, true);
        }
    }
    if (!empty($category_list) && ($show_results || $show_only_score)) {
        //Adding total
        $category_list['total'] = array('score' => $total_score, 'total' => $total_weight);
        echo Testcategory::get_stats_table_by_attempt($objExercise->id, $category_list);
    }
    if ($show_all_but_expected_answer) {
        $exercise_content .= "<div class='normal-message'>" . get_lang("ExerciseWithFeedbackWithoutCorrectionComment") . "</div>";
    }
    echo $total_score_text;
    echo $exercise_content;
    if (!$show_only_score) {
        echo $total_score_text;
    }
    if ($save_user_result) {
        // Tracking of results
        $learnpath_id = $exercise_stat_info['orig_lp_id'];
        $learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
        $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
        if (api_is_allowed_to_session_edit()) {
            update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $exercise_stat_info['exe_duration'], $question_list, '', array(), $end_date);
        }
        // Send notification ..
        if (!api_is_allowed_to_edit(null, true)) {
            $objExercise->send_notification_for_open_questions($question_list_answers, $origin, $exe_id);
            $objExercise->send_notification_for_oral_questions($question_list_answers, $origin, $exe_id);
        }
    }
}
 /**
  * Returns a category summary report
  * @params int exercise id
  * @params array pre filled array with the category_id, score, and weight
  * example: array(1 => array('score' => '10', 'total' => 20));
  */
 public static function get_stats_table_by_attempt($exercise_id, $category_list = array())
 {
     if (empty($category_list)) {
         return null;
     }
     $category_name_list = Testcategory::getListOfCategoriesNameForTest($exercise_id);
     $table = new HTML_Table(array('class' => 'data_table'));
     $table->setHeaderContents(0, 0, get_lang('Categories'));
     $table->setHeaderContents(0, 1, get_lang('AbsoluteScore'));
     $table->setHeaderContents(0, 2, get_lang('RelativeScore'));
     $row = 1;
     $none_category = array();
     if (isset($category_list['none'])) {
         $none_category = $category_list['none'];
         unset($category_list['none']);
     }
     $total = array();
     if (isset($category_list['total'])) {
         $total = $category_list['total'];
         unset($category_list['total']);
     }
     if (count($category_list) > 1) {
         foreach ($category_list as $category_id => $category_item) {
             $table->setCellContents($row, 0, $category_name_list[$category_id]);
             $table->setCellContents($row, 1, show_score($category_item['score'], $category_item['total'], false));
             $table->setCellContents($row, 2, show_score($category_item['score'], $category_item['total'], true, false, true));
             $row++;
         }
         if (!empty($none_category)) {
             $table->setCellContents($row, 0, get_lang('None'));
             $table->setCellContents($row, 1, show_score($none_category['score'], $none_category['total'], false));
             $table->setCellContents($row, 2, show_score($none_category['score'], $none_category['total'], true, false, true));
             $row++;
         }
         if (!empty($total)) {
             $table->setCellContents($row, 0, get_lang('Total'));
             $table->setCellContents($row, 1, show_score($total['score'], $total['total'], false));
             $table->setCellContents($row, 2, show_score($total['score'], $total['total'], true, false, true));
         }
         return $table->toHtml();
     }
     return null;
 }
Example #9
0
$table_content = '';
/* Make a special case for IE, which doesn't seem to be able to handle the
 * results popup -> send it to the full results page */
require_once api_get_path(LIBRARY_PATH) . 'browser/Browser.php';
$browser = new Browser();
$current_browser = $browser->getBrowser();
$url_suffix = '';
$btn_class = 'ajax ';
if ($current_browser == 'Internet Explorer') {
    $url_suffix = '&amp;show_headers=1';
    $btn_class = '';
}
if (!empty($attempts)) {
    $i = $counter;
    foreach ($attempts as $attempt_result) {
        $score = show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']);
        $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&amp;id=' . $attempt_result['exe_id'] . '&amp;id_session=' . api_get_session_id() . '&amp;height=500&amp;width=950' . $url_suffix;
        $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class' => $btn_class . 'btn'));
        $teacher_revised = Display::label(get_lang('Validated'), 'success');
        //$attempt_link = get_lang('NoResult');
        //$attempt_link = Display::return_icon('quiz_na.png', get_lang('NoResult'), array(), ICON_SIZE_SMALL);
        if ($attempt_result['attempt_revised'] == 0) {
            $teacher_revised = Display::label(get_lang('NotValidated'), 'info');
        }
        $row = array('count' => $i, 'date' => api_convert_and_format_date($attempt_result['start_date'], DATE_TIME_FORMAT_LONG));
        $attempt_link .= "&nbsp;&nbsp;&nbsp;" . $teacher_revised;
        if (in_array($objExercise->results_disabled, array(RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS, RESULT_DISABLE_SHOW_SCORE_ONLY, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES))) {
            $row['result'] = $score;
        }
        if (in_array($objExercise->results_disabled, array(RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES)) || $objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) {
            $row['attempt_link'] = $attempt_link;
         $exercise_stat_info = get_exercise_results_by_user($user_id, $exerciseId, api_get_course_id(), api_get_session_id());
         if (!empty($exercise_stat_info)) {
             $max_exe_id = max(array_keys($exercise_stat_info));
             $last_attempt_info = $exercise_stat_info[$max_exe_id];
             $attempt_html .= Display::div(get_lang('Date') . ': ' . api_get_local_time($last_attempt_info['exe_date']), array('id' => ''));
             $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
             if (!empty($last_attempt_info['question_list'])) {
                 foreach ($last_attempt_info['question_list'] as $question_data) {
                     $question_id = $question_data['question_id'];
                     $marks = $question_data['marks'];
                     $question_info = Question::read($question_id);
                     $attempt_html .= Display::div($question_info->question, array('class' => 'question_title'));
                     $attempt_html .= Display::div(get_lang('Score') . ' ' . $marks, array('id' => 'question_score'));
                 }
             }
             $score = show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
             $attempt_html .= Display::div(get_lang('YourTotalScore') . ' ' . $score, array('id' => 'question_score'));
         } else {
             $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
         }
     } else {
         $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
     }
 } else {
     $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
 }
 if ($origin == 'learnpath') {
     Display::display_reduced_header();
 } else {
     Display::display_header($nameTools, 'Exercises');
 }