moodle/mod/quiz/report.php

81 lines
2.7 KiB
PHP
Raw Normal View History

<?php // $Id$
// This script uses installed report plugins to print quiz reports
require_once("../../config.php");
require_once("locallib.php");
$id = optional_param('id',0,PARAM_INT); // Course Module ID, or
$q = optional_param('q',0,PARAM_INT); // quiz ID
$mode = optional_param('mode', 'overview', PARAM_ALPHA); // Report mode
if ($id) {
if (! $cm = get_coursemodule_from_id('quiz', $id)) {
2005-06-04 09:58:35 +00:00
error("There is no coursemodule with id $id");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $quiz = get_record("quiz", "id", $cm->instance)) {
2005-06-04 09:58:35 +00:00
error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
}
} else {
if (! $quiz = get_record("quiz", "id", $q)) {
2005-06-04 09:58:35 +00:00
error("There is no quiz with id $q");
}
if (! $course = get_record("course", "id", $quiz->course)) {
2005-06-04 09:58:35 +00:00
error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
}
if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
2005-06-04 09:58:35 +00:00
error("The course module for the quiz with id $q is missing");
}
}
require_login($course->id, false);
2006-08-22 09:04:23 +00:00
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
2006-08-25 11:23:00 +00:00
require_capability('mod/quiz:viewreports', $context);
// if no questions have been set up yet redirect to edit.php
2006-08-22 09:04:23 +00:00
if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) {
redirect('edit.php?cmid='.$cm->id);
}
2002-10-22 04:25:58 +00:00
// Upgrade any attempts that have not yet been upgraded to the
// Moodle 1.5 model (they will not yet have the timestamp set)
if ($attempts = get_records_sql("SELECT a.*".
Towards removing reference to quiz module from the question code Renaming tables: quiz_questions -> question quiz_states -> question_states Renaming functions: quiz_delete_question -> delete_question quiz_get_question_options -> get_question_options quiz_get_states -> get_question_states quiz_restore_state -> restore_question_state quiz_save_question_session -> save_question_session quiz_state_is_graded -> question_state_is_graded quiz_extract_responses -> question_extract_responses quiz_regrade_question_in_attempt -> regrade_question_in_attempt quiz_process_responses -> question_process_responses quiz_isgradingevent -> question_isgradingevent($event) quiz_search_for_duplicate_responses -> question_search_for_duplicate_responses quiz_apply_penalty_and_timelimit -> question_apply_penalty_and_timelimit quiz_print_question_icon -> print_question_icon quiz_get_image -> get_question_image quiz_make_name_prefix -> question_make_name_prefix quiz_get_id_from_name_prefix -> question_get_id_from_name_prefix quiz_new_attempt_uniqueid -> question_new_attempt_uniqueid quiz_get_renderoptions -> question_get_renderoptions quiz_print_quiz_question -> print_question quiz_get_question_responses -> get_question_responses quiz_get_question_actual_response -> get_question_actual_response quiz_get_question_fraction_grade -> get_question_fraction_grade quiz_get_default_category -> get_default_question_category Renaming constants: QUIZ_EVENT.... -> QUESTION_EVENT.... QUIZ_MAX_NUMBER_ANSWERS -> QUESTION_NUMANS
2006-02-28 09:26:00 +00:00
" FROM {$CFG->prefix}quiz_attempts a, {$CFG->prefix}question_states s".
" WHERE a.quiz = '$quiz->id' AND s.attempt = a.uniqueid AND s.timestamp = 0")) {
foreach ($attempts as $attempt) {
quiz_upgrade_states($attempt);
}
}
add_to_log($course->id, "quiz", "report", "report.php?id=$cm->id", "$quiz->id", "$cm->id");
/// Open the selected quiz report and display it
$mode = clean_param($mode, PARAM_SAFEDIR);
2004-09-29 07:02:22 +00:00
if (! is_readable("report/$mode/report.php")) {
error("Report not known ($mode)");
}
include("report/default.php"); // Parent class
include("report/$mode/report.php");
$report = new quiz_report();
if (! $report->display($quiz, $cm, $course)) { // Run the report!
error("Error occurred during pre-processing!");
}
/// Print footer
print_footer($course);
?>