course, $USER->id)){ error( get_string( 'only_teachers', 'game')); } $currenttab = 'reports'; include( 'tabs.php'); $attemptid = required_param('attempt', PARAM_INT); // A particular attempt ID for review if( $game->sourcemodule == 'glossary'){ game_review_glossary( $game, $attemptid); print_footer(); die; } function game_repair_queries( $game, &$rec){ if($game->gamekind == 'sudoku'){ if( $rec->sourcemodule == 'glossary') { $rec2 = get_record_select( 'glossary_entries', 'id='.$rec->glossaryentryid, 'id,concept,definition'); $rec->questiontext = $rec2->concept; $rec->answertext = $rec2->definition; }else { $rec2 = get_record_select( 'question', 'id='.$rec->questionid, 'id,questiontext'); $rec->questiontext = $rec2->questiontext; //$rec2 = get_record_select( 'question', 'id='.$rec->question, 'id,questiontext'); //$rec->answertext = $rec2->definition; } } } require_once($CFG->libdir."/questionlib.php"); $attempt = required_param('attempt', PARAM_INT); // A particular attempt ID for review $page = optional_param('page', 0, PARAM_INT); // The required page $showall = optional_param('showall', 0, PARAM_BOOL); if (! $attempt = get_record("game_attempts", "id", $attempt)) { error("No such attempt ID exists"); } if (! $game = get_record("game", "id", $attempt->gameid)) { error("The game with id $attempt->gameid belonging to attempt $attempt is missing"); } game_compute_attempt_layout( $game, $attempt); if (! $course = get_record("course", "id", $game->course)) { error("The course with id $game->course that the game with id $game->id belongs to is missing"); } if (! $cm = get_coursemodule_from_instance("game", $game->id, $course->id)) { error("The course module for the game with id $game->id is missing"); } $grade = game_score_to_grade( $attempt->score, $game); $feedback = game_feedback_for_grade( $grade, $attempt->gameid); require_login( $course->id, false, $cm); $context = get_context_instance( CONTEXT_MODULE, $cm->id); $coursecontext = get_context_instance( CONTEXT_COURSE, $cm->course); $isteacher = isteacher( $game->course, $USER->id); $options = game_get_reviewoptions( $game, $attempt, $context); add_to_log($course->id, "game", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$game->id", "$cm->id"); /// Print the page header $strgames = get_string('modulenameplural', 'game'); $strreview = get_string('review', 'game'); $strscore = get_string('score', 'game'); $strgrade = get_string('grade'); $strbestgrade = get_string('bestgrade', 'quiz'); $strtimetaken = get_string('timetaken', 'game'); $strtimecompleted = get_string('completedon', 'game'); $strupdatemodule = has_capability('moodle/course:manageactivities', $coursecontext) ? update_module_button($cm->id, $course->id, get_string('modulename', 'game')) : ""; $strgames = get_string('modulenameplural', 'game'); $strgame = get_string('modulename', 'game'); /* if( function_exists( 'build_navigation')){ $navigation = build_navigation('', $cm); print_header("$course->shortname: $game->name", "$course->shortname: $game->name", $navigation, "", "", true, update_module_button($cm->id, $course->id, $strgame), navmenu($course, $cm)); }else{ if ($course->category) { $navigation = "wwwroot}/course/view.php?id=$course->id\">$course->shortname ->"; } else { $navigation = ''; } print_header("$course->shortname: $game->name", "$course->fullname", "$navigation id>$strgames -> $game->name", "", "", true, update_module_button($cm->id, $course->id, $strgame), navmenu($course, $cm)); } */ echo '
'; // for overlib /// Print heading and tabs if this is part of a preview //if (has_capability('mod/game:preview', $context)) { /* if ($attempt->userid == $USER->id) { // this is the report on a preview $currenttab = 'preview'; } else { $currenttab = 'reports'; $mode = ''; } include('tabs.php'); //} else { // print_heading(format_string($game->name)); //} */ /// Load all the questions and states needed by this script // load the questions needed by page $pagelist = $showall ? game_questions_in_game( $attempt->layout) : game_questions_on_page( $attempt->layout, $page); $a = explode( ',', $pagelist); $pagelist = ''; foreach( $a as $item){ if( substr( $item, 0, 1)){ if( substr( $item, -1) != 'G'){ $pagelist .= ','.$item; } } } $pagelist = substr( $pagelist, 1); if( $pagelist != ''){ $sql = "SELECT q.*, i.id AS instance,i.id as iid,". "i.score AS score,i.studentanswer". " FROM {$CFG->prefix}question q,". " {$CFG->prefix}game_queries i". " WHERE i.attemptid = '$attempt->id' AND q.id = i.questionid AND (i.sourcemodule='question' or i.sourcemodule = 'quiz')". " AND q.id IN ($pagelist)"; if (!$questions = get_records_sql( $sql)) { error('No questions found'); } }else { $questions = array(); } // Load the question type specific information if (!get_question_options( $questions)) { error('Could not load question options'); } $states = game_compute_states( $game, $questions); /// Print infobox //$timelimit = (int)$game->timelimit * 60; $timelimit = 0; $overtime = 0; if ($attempt->timefinish) { if ($timetaken = ($attempt->timefinish - $attempt->timestart)) { if($timelimit && $timetaken > ($timelimit + 60)) { $overtime = $timetaken - $timelimit; $overtime = format_time($overtime); } $timetaken = format_time($timetaken); } else { $timetaken = "-"; } } else { $timetaken = get_string('unfinished', 'game'); } $table->align = array("right", "left"); if ($attempt->userid <> $USER->id) { $student = get_record('user', 'id', $attempt->userid); $picture = print_user_picture($student->id, $course->id, $student->picture, false, true); $table->data[] = array($picture, ''.fullname($student, true).''); } //if (has_capability('mod/game:grade', $context)){ if( count($attempts = get_records_select('game_attempts', "gameid = '$game->id' AND userid = '$attempt->userid'", 'attempt ASC')) > 1) { // print list of attempts $attemptlist = ''; foreach ($attempts as $at) { $attemptlist .= ($at->id == $attempt->id) ? ''.$at->attempt.', ' : ''.$at->attempt.', '; } $table->data[] = array(get_string('attempts', 'game').':', trim($attemptlist, ' ,')); } //} $table->data[] = array(get_string('startedon', 'game').':', userdate($attempt->timestart)); if ($attempt->timefinish) { $table->data[] = array("$strtimecompleted:", userdate($attempt->timefinish)); $table->data[] = array("$strtimetaken:", $timetaken); } //if the student is allowed to see their score if ($options->scores) { if ($game->grade) { if($overtime) { $result->sumgrades = "0"; $result->grade = "0.0"; } $a = new stdClass; $percentage = round($attempt->score*100, 0); $a->grade = game_score_to_grade( $attempt->score, $game); $a->maxgrade = $game->grade; $table->data[] = array("$strscore:", "{$a->grade}/{$game->grade} ($percentage %)"); //$table->data[] = array("$strgrade:", get_string('outof', 'game', $a)); } } if ($options->overallfeedback && $feedback) { $table->data[] = array(get_string('feedback', 'game'), $feedback); } if ($isteacher and $attempt->userid == $USER->id) { // the teacher is at the end of a preview. Print button to start new preview unset($buttonoptions); $buttonoptions['q'] = $game->id; $buttonoptions['forcenew'] = true; echo ''.get_string( 'question').' | '; echo ''.get_string( 'answer').' | '; echo ''.get_string( 'student').' | '; echo ''.get_string( 'grade').' | '; echo '
'.$rec->questiontext.' | '; echo ''.$rec->answertext.' | '; echo ''.$rec->studentanswer.' | '; echo ''.(round(100*$rec->score) >=1 ? round($rec->score*100, 0).' %' : '').' | '; echo '