Permalink
Browse files

Skeleton version of the quiz module. It won't break an installation,

but it doesn't do anything yet.
  • Loading branch information...
1 parent 518d371 commit 730fd187c825ca8e71bf78a130a4d7ca4e1785bb moodler committed Oct 4, 2002
Showing with 571 additions and 0 deletions.
  1. +21 −0 lang/en/quiz.php
  2. +173 −0 mod/quiz/db/mysql.sql
  3. BIN mod/quiz/icon.gif
  4. +73 −0 mod/quiz/index.php
  5. +104 −0 mod/quiz/lib.php
  6. +115 −0 mod/quiz/mod.html
  7. +24 −0 mod/quiz/version.php
  8. +61 −0 mod/quiz/view.php
View
@@ -0,0 +1,21 @@
+<?PHP // $Id$
+
+#------------------------------------------------------------
+$string['modulename'] = "Quiz";
+$string['modulenameplural'] = "Quizzes";
+#------------------------------------------------------------
+
+$string['alwaysavailable'] = "Always available";
+$string['attempt'] = "Attempt \$a";
+$string['attemptfirst'] = "First attempt";
+$string['attemptlast'] = "Last attempt";
+$string['attempts'] = "Attempts";
+$string['attemptsallowed'] = "Attempts allowed";
+$string['attemptsunlimited'] = "Unlimited attempts";
+$string['daysavailable'] = "Days available";
+$string['gradeaverage'] = "Average grade";
+$string['gradehighest'] = "Highest grade";
+$string['grademethod'] = "Grading method";
+$string['introduction'] = "Introduction";
+$string['showfeedback'] = "After answering, show feedback?";
+$string['showcorrectanswer'] = "After answering, show correct answers?";
View
@@ -0,0 +1,173 @@
+# phpMyAdmin MySQL-Dump
+# version 2.3.2-dev
+# http://www.phpmyadmin.net/ (download page)
+#
+# Host: localhost
+# Generation Time: Oct 03, 2002 at 11:15 PM
+# Server version: 3.23.49
+# PHP Version: 4.2.3
+# Database : `moodle`
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz`
+#
+
+CREATE TABLE `quiz` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `course` int(10) unsigned NOT NULL default '0',
+ `name` varchar(255) NOT NULL default '',
+ `intro` text NOT NULL,
+ `days` smallint(6) NOT NULL default '0',
+ `attempts` smallint(6) NOT NULL default '0',
+ `feedback` tinyint(4) NOT NULL default '0',
+ `correctanswers` tinyint(4) NOT NULL default '1',
+ `grademethod` tinyint(4) NOT NULL default '1',
+ `questions` text NOT NULL,
+ `sumgrades` int(10) NOT NULL default '0',
+ `grade` int(10) NOT NULL default '0',
+ `timecreated` int(10) unsigned NOT NULL default '0',
+ `timemodified` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Main information about each quiz';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_answers`
+#
+
+CREATE TABLE `quiz_answers` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `question` int(10) unsigned NOT NULL default '0',
+ `answer` int(10) unsigned NOT NULL default '0',
+ `grade` float NOT NULL default '0',
+ `feedback` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Answers, with a percentage grade and feedback';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_attempts`
+#
+
+CREATE TABLE `quiz_attempts` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `quiz` int(10) unsigned NOT NULL default '0',
+ `user` int(10) unsigned NOT NULL default '0',
+ `attempt` smallint(6) NOT NULL default '0',
+ `grade` float NOT NULL default '0',
+ `timemodified` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Stores various attempts on a quiz';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_categories`
+#
+
+CREATE TABLE `quiz_categories` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `course` int(10) unsigned NOT NULL default '0',
+ `name` varchar(255) NOT NULL default '',
+ `info` text NOT NULL,
+ `publish` tinyint(4) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Categories are for grouping questions';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_grades`
+#
+
+CREATE TABLE `quiz_grades` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `quiz` int(10) unsigned NOT NULL default '0',
+ `user` int(10) unsigned NOT NULL default '0',
+ `grade` float NOT NULL default '0',
+ `timemodified` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Final quiz grade (may be best of several attempts)';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_multichoice`
+#
+
+CREATE TABLE `quiz_multichoice` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `question` int(10) unsigned NOT NULL default '0',
+ `layout` tinyint(4) NOT NULL default '0',
+ `answers` varchar(255) NOT NULL default '',
+ `single` tinyint(4) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Options for multiple choice questions';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_question_grades`
+#
+
+CREATE TABLE `quiz_question_grades` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `quiz` int(10) unsigned NOT NULL default '0',
+ `question` int(10) unsigned NOT NULL default '0',
+ `grade` smallint(6) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='The grade for a question in a quiz';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_questions`
+#
+
+CREATE TABLE `quiz_questions` (
+ `id` int(10) NOT NULL auto_increment,
+ `course` int(10) NOT NULL default '0',
+ `name` varchar(255) NOT NULL default '',
+ `question` text NOT NULL,
+ `type` smallint(6) NOT NULL default '0',
+ `options` int(10) NOT NULL default '0',
+ `category` int(10) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='The quiz questions themselves';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_responses`
+#
+
+CREATE TABLE `quiz_responses` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `attempt` int(10) unsigned NOT NULL default '0',
+ `question` int(10) unsigned NOT NULL default '0',
+ `answer` varchar(255) NOT NULL default '',
+ `grade` float NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Stores user responses to a quiz, and percentage grades';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_shortanswer`
+#
+
+CREATE TABLE `quiz_shortanswer` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `question` int(10) unsigned NOT NULL default '0',
+ `answer` int(10) NOT NULL default '0',
+ `case` tinyint(4) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Options for short answer questions';
+# --------------------------------------------------------
+
+#
+# Table structure for table `quiz_truefalse`
+#
+
+CREATE TABLE `quiz_truefalse` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `question` int(10) unsigned NOT NULL default '0',
+ `true` int(10) unsigned NOT NULL default '0',
+ `false` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Options for True-False questions';
+
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,73 @@
+<?PHP // $Id$
+
+// This page lists all the instances of quiz in a particular course
+
+ require("../../config.php");
+ require("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");
+
+// 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 = "<A HREF=\"view.php?id=$quiz->coursemodule\">$quiz->name</A>";
+
+ if ($course->format == "weeks" or $course->format == "topics") {
+ $table->data[] = array ($quiz->section, $link);
+ } else {
+ $table->data[] = array ($link);
+ }
+ }
+
+ echo "<BR>";
+
+ print_table($table);
+
+// Finish the page
+
+ print_footer($course);
+
+?>
View
@@ -0,0 +1,104 @@
+<?PHP // $Id$
+
+// Library of function for module quiz
+
+$QUIZ_GRADE_METHOD = array ( "1" => 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_
+
+
+?>
Oops, something went wrong.

0 comments on commit 730fd18

Please sign in to comment.