mirror of
https://github.com/moodle/moodle.git
synced 2025-02-23 03:18:07 +01:00
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
83 lines
2.6 KiB
PHP
83 lines
2.6 KiB
PHP
<?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_record("course_modules", "id", $id)) {
|
|
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)) {
|
|
error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
|
|
}
|
|
|
|
} else {
|
|
if (! $quiz = get_record("quiz", "id", $q)) {
|
|
error("There is no quiz with id $q");
|
|
}
|
|
if (! $course = get_record("course", "id", $quiz->course)) {
|
|
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)) {
|
|
error("The course module for the quiz with id $q is missing");
|
|
}
|
|
}
|
|
|
|
require_login($course->id, false);
|
|
|
|
if (!isteacher($course->id)) {
|
|
error("You are not allowed to use this script");
|
|
}
|
|
|
|
// if no questions have been set up yet redirect to edit.php
|
|
if (!$quiz->questions and isteacheredit($course->id)) {
|
|
redirect('edit.php?quizid='.$quiz->id);
|
|
}
|
|
|
|
// 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.*".
|
|
" 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_filename($mode);
|
|
|
|
if (! is_readable("report/$mode/report.php")) {
|
|
error("Report not known (".clean_text($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);
|
|
|
|
?>
|