From 730fd187c825ca8e71bf78a130a4d7ca4e1785bb Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 4 Oct 2002 02:59:05 +0000 Subject: [PATCH] Skeleton version of the quiz module. It won't break an installation, but it doesn't do anything yet. --- lang/en/quiz.php | 21 +++++ mod/quiz/db/mysql.sql | 173 ++++++++++++++++++++++++++++++++++++++++++ mod/quiz/icon.gif | Bin 0 -> 101 bytes mod/quiz/index.php | 73 ++++++++++++++++++ mod/quiz/lib.php | 104 +++++++++++++++++++++++++ mod/quiz/mod.html | 115 ++++++++++++++++++++++++++++ mod/quiz/version.php | 24 ++++++ mod/quiz/view.php | 61 +++++++++++++++ 8 files changed, 571 insertions(+) create mode 100644 lang/en/quiz.php create mode 100644 mod/quiz/db/mysql.sql create mode 100755 mod/quiz/icon.gif create mode 100644 mod/quiz/index.php create mode 100644 mod/quiz/lib.php create mode 100644 mod/quiz/mod.html create mode 100644 mod/quiz/version.php create mode 100644 mod/quiz/view.php diff --git a/lang/en/quiz.php b/lang/en/quiz.php new file mode 100644 index 0000000000..4874421255 --- /dev/null +++ b/lang/en/quiz.php @@ -0,0 +1,21 @@ +AXBLf37gAR}jloeoLU^1K2XL(wP|9;|W z*B2~X%~#xtm6Biz3Ql^Fx++2XfO;m=rtP=P{f_<4Xn0d`aKh@0FFry(&lWH+SOWlX CKP2M- literal 0 HcmV?d00001 diff --git a/mod/quiz/index.php b/mod/quiz/index.php new file mode 100644 index 0000000000..e7e4a36ed5 --- /dev/null +++ b/mod/quiz/index.php @@ -0,0 +1,73 @@ +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 = "id\">$course->shortname ->"; + } + + print_header("$course->shortname: $strquizzes", "$course->fullname", "$navigation $strquizzes"); + +// Get all the appropriate data + + if (! $quizzes = get_all_instances_in_course("quiz", $course->id, "cw.section ASC")) { + 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"); + + if ($course->format == "weeks") { + $table->head = array ($strweek, $strname); + $table->align = array ("CENTER", "LEFT"); + } else if ($course->format == "topics") { + $table->head = array ($strtopic, $strname); + $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT"); + } else { + $table->head = array ($strname); + $table->align = array ("LEFT", "LEFT", "LEFT"); + } + + foreach ($quizzes as $quiz) { + $link = "coursemodule\">$quiz->name"; + + if ($course->format == "weeks" or $course->format == "topics") { + $table->data[] = array ($quiz->section, $link); + } else { + $table->data[] = array ($link); + } + } + + echo "
"; + + print_table($table); + +// Finish the page + + print_footer($course); + +?> diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php new file mode 100644 index 0000000000..79d5a28b08 --- /dev/null +++ b/mod/quiz/lib.php @@ -0,0 +1,104 @@ + get_string("gradehighest", "quiz"), + "2" => get_string("gradeaverage", "quiz"), + "3" => get_string("attemptfirst", "quiz"), + "4" => get_string("attemptlast", "quiz") + ); + + +function quiz_add_instance($quiz) { +// Given an object containing all the necessary data, +// (defined by the form in mod.html) this function +// will create a new instance and return the id number +// of the new instance. + + $quiz->timemodified = time(); + + # May have to add extra stuff in here # + + return insert_record("quiz", $quiz); +} + + +function quiz_update_instance($quiz) { +// Given an object containing all the necessary data, +// (defined by the form in mod.html) this function +// will update an existing instance with new data. + + $quiz->timemodified = time(); + $quiz->id = $quiz->instance; + + # May have to add extra stuff in here # + + return update_record("quiz", $quiz); +} + + +function quiz_delete_instance($id) { +// Given an ID of an instance of this module, +// this function will permanently delete the instance +// and any data that depends on it. + + if (! $quiz = get_record("quiz", "id", "$id")) { + return false; + } + + $result = true; + + # Delete any dependent records here # + + if (! delete_records("quiz", "id", "$quiz->id")) { + $result = false; + } + + return $result; +} + +function quiz_user_outline($course, $user, $mod, $quiz) { +// Return a small object with summary information about what a +// user has done with a given particular instance of this module +// Used for user activity reports. +// $return->time = the time they did it +// $return->info = a short text description + + return $return; +} + +function quiz_user_complete($course, $user, $mod, $quiz) { +// Print a detailed representation of what a user has done with +// a given particular instance of this module, for user activity reports. + + return true; +} + +function quiz_print_recent_activity(&$logs, $isteacher=false) { +// Given a list of logs, assumed to be those since the last login +// this function prints a short list of changes related to this module +// If isteacher is true then perhaps additional information is printed. +// This function is called from course/lib.php: print_recent_activity() + + global $CFG, $COURSE_TEACHER_COLOR; + + return $content; // True if anything was printed, otherwise false +} + +function quiz_cron () { +// Function to be run periodically according to the moodle cron +// This function searches for things that need to be done, such +// as sending out mail, toggling flags etc ... + + global $CFG; + + return true; +} + + +////////////////////////////////////////////////////////////////////////////////////// +// Any other quiz functions go here. Each of them must have a name that +// starts with quiz_ + + +?> diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html new file mode 100644 index 0000000000..1ad49e2132 --- /dev/null +++ b/mod/quiz/mod.html @@ -0,0 +1,115 @@ + + + +dirroot/mod/quiz/lib.php") ?> + +

This module is not ready for use

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

:

+ +

:

+ + +

:

+ days == "") { + $form->days == "14"; + } + choose_from_menu($options, "days", "$form->days", ""); + ?> +

:

+ attempts", ""); + ?> +

:

+ grademethod", ""); + ?> +

:

+ feedback", ""); + ?> +

:

+ correctanswers", ""); + ?> +

:

+ =0; $i--) { + $grades[$i] = $i; + } + choose_from_menu($grades, "grade", "$form->grade", ""); + ?> +
+ + + + + + + + +"> +
+
diff --git a/mod/quiz/version.php b/mod/quiz/version.php new file mode 100644 index 0000000000..a8ccabd5ef --- /dev/null +++ b/mod/quiz/version.php @@ -0,0 +1,24 @@ +version = 2002100300; // The (date) version of this module +$module->cron = 0; // How often should cron check this module (seconds)? + +function quiz_upgrade($oldversion) { +// This function does anything necessary to upgrade +// older versions to match current functionality + + global $CFG; + + if ($oldversion < 2002100300) { + + } + + return true; +} + +?> diff --git a/mod/quiz/view.php b/mod/quiz/view.php new file mode 100644 index 0000000000..5e941c4fc1 --- /dev/null +++ b/mod/quiz/view.php @@ -0,0 +1,61 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $quiz = get_record("quiz", "id", $cm->instance)) { + error("Course module is incorrect"); + } + + } else { + if (! $quiz = get_record("quiz", "id", $a)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $quiz->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) { + error("Course Module ID was incorrect"); + } + } + + require_login($course->id); + + add_to_log($course->id, "quiz", "view", "view.php?id=$cm->id", "$quiz->id"); + +// Print the page header + + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } + + $strquizzes = get_string("modulenameplural", "quiz"); + $strquiz = get_string("modulename", "quiz"); + + print_header("$course->shortname: $quiz->name", "$course->fullname", + "$navigation id>$strquizzes -> $quiz->name", + "", "", true, update_module_icon($cm->id, $course->id)); + +// Print the main part of the page + + echo "YOUR CODE GOES HERE"; + + +// Finish the page + print_footer($course); + +?> -- 2.39.5