Exemplo n.º 1
0
        $table->setCellContents($row, $column, $cell);
        $table->updateCellAttributes($row, $column, 'align="center"');
        $column++;
    }
    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
    $row++;
}
$content = $table->toHtml();
// Format B
$headers = array(get_lang('Question'), get_lang('Answer'), get_lang('Correct'), get_lang('NumberStudentWhoSelectedIt'));
$data = array();
if (!empty($question_list)) {
    $id = 0;
    foreach ($question_list as $question_id) {
        $question_obj = Question::read($question_id);
        $exercise_stats = ExerciseLib::get_student_stats_by_question($question_id, $exercise_id, $courseCode, $sessionId);
        $answer = new Answer($question_id);
        $answer_count = $answer->selectNbrAnswers();
        for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
            $answer_info = $answer->selectAnswer($answer_id);
            $is_correct = $answer->isCorrect($answer_id);
            $correct_answer = $is_correct == 1 ? get_lang('Yes') : get_lang('No');
            $real_answer_id = $answer->selectAutoId($answer_id);
            // Overwriting values depending of the question
            switch ($question_obj->type) {
                case FILL_IN_BLANKS:
                    $answer_info_db = $answer_info;
                    $answer_info = substr($answer_info, 0, strpos($answer_info, '::'));
                    $correct_answer = $is_correct;
                    $answers = $objExercise->fill_in_blank_answer_to_array($answer_info);
                    $counter = 0;
Exemplo n.º 2
0
        $table->updateCellAttributes($row, $column, 'align="center"');
        $column++;
    }
    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
    $row++;
}
$content = $table->toHtml();
// Format B.
$headers = array(get_lang('Question'), get_lang('Answer'), get_lang('Correct'), get_lang('NumberStudentWhoSelectedIt'));
$data = array();
if (!empty($question_list)) {
    $id = 0;
    foreach ($question_list as $row) {
        $question_id = $row['question_id'];
        $question_obj = Question::read($question_id);
        $exercise_stats = ExerciseLib::get_student_stats_by_question($question_id, $exercise_id, api_get_course_int_id(), api_get_session_id());
        $answer = new Answer($question_id);
        $answer->read();
        $mainCounter = 1;
        $counter = 1;
        foreach ($answer->answer as $answer_id => $answer_item) {
            $answer_info = $answer->selectAnswer($answer_id);
            $is_correct = $answer->isCorrect($answer_id);
            $correct_answer = $is_correct == 1 ? get_lang('Yes') : get_lang('No');
            // Overwriting values depending of the question.
            switch ($question_obj->type) {
                case FILL_IN_BLANKS:
                    $answer_info_db = $answer_info;
                    $answer_info = substr($answer_info, 0, strpos($answer_info, '::'));
                    $correct_answer = $is_correct;
                    $answers = $objExercise->fill_in_blank_answer_to_array($answer_info);