mirror of
https://github.com/moodle/moodle.git
synced 2025-01-25 01:28:54 +01:00
cccb016ae4
ensure that the order they are displayed in is always the same as the order they have been defined in. See bug 553. This involved API changes to the function get_all_instances_in_course()
116 lines
3.6 KiB
PHP
116 lines
3.6 KiB
PHP
<?PHP // $Id$
|
|
|
|
// This page lists all the instances of quiz in a particular course
|
|
|
|
require_once("../../config.php");
|
|
require_once("lib.php");
|
|
|
|
require_variable($id); // course
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
error("Course ID is incorrect");
|
|
}
|
|
|
|
require_login($course->id);
|
|
|
|
add_to_log($course->id, "quiz", "view all", "index.php?id=$course->id", "");
|
|
|
|
|
|
// Print the header
|
|
|
|
$strquizzes = get_string("modulenameplural", "quiz");
|
|
$strquiz = get_string("modulename", "quiz");
|
|
|
|
if ($course->category) {
|
|
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
|
|
}
|
|
|
|
print_header("$course->shortname: $strquizzes", "$course->fullname", "$navigation $strquizzes",
|
|
"", "", true, "", navmenu($course));
|
|
|
|
// Get all the appropriate data
|
|
|
|
if (! $quizzes = get_all_instances_in_course("quiz", $course)) {
|
|
notice("There are no quizzes", "../../course/view.php?id=$course->id");
|
|
die;
|
|
}
|
|
|
|
// Print the list of instances (your module will probably extend this)
|
|
|
|
$timenow = time();
|
|
$strname = get_string("name");
|
|
$strweek = get_string("week");
|
|
$strtopic = get_string("topic");
|
|
$strbestgrade = get_string("bestgrade", "quiz");
|
|
$strquizcloses = get_string("quizcloses", "quiz");
|
|
$strattempts = get_string("attempts", "quiz");
|
|
|
|
if (isteacher($course->id)) {
|
|
$gradecol = $strattempts;
|
|
} else {
|
|
$gradecol = $strbestgrade;
|
|
}
|
|
|
|
if ($course->format == "weeks") {
|
|
$table->head = array ($strweek, $strname, $strquizcloses, $gradecol);
|
|
$table->align = array ("center", "left", "left", "left");
|
|
$table->width = array (10, "*", 10);
|
|
} else if ($course->format == "topics") {
|
|
$table->head = array ($strtopic, $strname, $strquizcloses, $gradecol);
|
|
$table->align = array ("center", "left", "left", "left");
|
|
$table->width = array (10, "*", 10);
|
|
} else {
|
|
$table->head = array ($strname, $strquizcloses, $gradecol);
|
|
$table->align = array ("left", "left", "left");
|
|
$table->width = array ("*", 10);
|
|
}
|
|
|
|
foreach ($quizzes as $quiz) {
|
|
if (!$quiz->visible) {
|
|
//Show dimmed if the mod is hidden
|
|
$link = "<A class=\"dimmed\" HREF=\"view.php?id=$quiz->coursemodule\">$quiz->name</A>";
|
|
} else {
|
|
//Show normal if the mod is visible
|
|
$link = "<A HREF=\"view.php?id=$quiz->coursemodule\">$quiz->name</A>";
|
|
}
|
|
|
|
$bestgrade = quiz_get_best_grade($quiz->id, $USER->id);
|
|
|
|
if ($quiz->section) {
|
|
$section = "$quiz->section";
|
|
} else {
|
|
$section = "";
|
|
}
|
|
|
|
$closequiz = userdate($quiz->timeclose);
|
|
|
|
if (isteacher($course->id)) {
|
|
if ($allanswers = get_records("quiz_grades", "quiz", $quiz->id)) {
|
|
$answercount = count($allanswers);
|
|
$gradecol = "<a href=\"report.php?id=$quiz->coursemodule\">" .
|
|
get_string("viewallanswers","quiz",$answercount)."</a>";
|
|
} else {
|
|
$answercount = 0;
|
|
$gradecol = "";
|
|
}
|
|
} else {
|
|
$gradecol = "$bestgrade / $quiz->grade";
|
|
}
|
|
|
|
if ($course->format == "weeks" or $course->format == "topics") {
|
|
$table->data[] = array ($section, $link, $closequiz, $gradecol);
|
|
} else {
|
|
$table->data[] = array ($link, $closequiz, $gradecol);
|
|
}
|
|
}
|
|
|
|
echo "<br />";
|
|
|
|
print_table($table);
|
|
|
|
// Finish the page
|
|
|
|
print_footer($course);
|
|
|
|
?>
|