730fd187 |
1 | <?PHP // $Id$ |
2 | |
3 | // Library of function for module quiz |
4 | |
5 | $QUIZ_GRADE_METHOD = array ( "1" => get_string("gradehighest", "quiz"), |
6 | "2" => get_string("gradeaverage", "quiz"), |
7 | "3" => get_string("attemptfirst", "quiz"), |
8 | "4" => get_string("attemptlast", "quiz") |
9 | ); |
10 | |
11 | |
12 | function quiz_add_instance($quiz) { |
13 | // Given an object containing all the necessary data, |
14 | // (defined by the form in mod.html) this function |
15 | // will create a new instance and return the id number |
16 | // of the new instance. |
17 | |
18 | $quiz->timemodified = time(); |
19 | |
20 | # May have to add extra stuff in here # |
21 | |
22 | return insert_record("quiz", $quiz); |
23 | } |
24 | |
25 | |
26 | function quiz_update_instance($quiz) { |
27 | // Given an object containing all the necessary data, |
28 | // (defined by the form in mod.html) this function |
29 | // will update an existing instance with new data. |
30 | |
31 | $quiz->timemodified = time(); |
32 | $quiz->id = $quiz->instance; |
33 | |
34 | # May have to add extra stuff in here # |
35 | |
36 | return update_record("quiz", $quiz); |
37 | } |
38 | |
39 | |
40 | function quiz_delete_instance($id) { |
41 | // Given an ID of an instance of this module, |
42 | // this function will permanently delete the instance |
43 | // and any data that depends on it. |
44 | |
45 | if (! $quiz = get_record("quiz", "id", "$id")) { |
46 | return false; |
47 | } |
48 | |
49 | $result = true; |
50 | |
51 | # Delete any dependent records here # |
52 | |
53 | if (! delete_records("quiz", "id", "$quiz->id")) { |
54 | $result = false; |
55 | } |
56 | |
57 | return $result; |
58 | } |
59 | |
60 | function quiz_user_outline($course, $user, $mod, $quiz) { |
61 | // Return a small object with summary information about what a |
62 | // user has done with a given particular instance of this module |
63 | // Used for user activity reports. |
64 | // $return->time = the time they did it |
65 | // $return->info = a short text description |
66 | |
67 | return $return; |
68 | } |
69 | |
70 | function quiz_user_complete($course, $user, $mod, $quiz) { |
71 | // Print a detailed representation of what a user has done with |
72 | // a given particular instance of this module, for user activity reports. |
73 | |
74 | return true; |
75 | } |
76 | |
77 | function quiz_print_recent_activity(&$logs, $isteacher=false) { |
78 | // Given a list of logs, assumed to be those since the last login |
79 | // this function prints a short list of changes related to this module |
80 | // If isteacher is true then perhaps additional information is printed. |
81 | // This function is called from course/lib.php: print_recent_activity() |
82 | |
83 | global $CFG, $COURSE_TEACHER_COLOR; |
84 | |
85 | return $content; // True if anything was printed, otherwise false |
86 | } |
87 | |
88 | function quiz_cron () { |
89 | // Function to be run periodically according to the moodle cron |
90 | // This function searches for things that need to be done, such |
91 | // as sending out mail, toggling flags etc ... |
92 | |
93 | global $CFG; |
94 | |
95 | return true; |
96 | } |
97 | |
98 | |
99 | ////////////////////////////////////////////////////////////////////////////////////// |
100 | // Any other quiz functions go here. Each of them must have a name that |
101 | // starts with quiz_ |
102 | |
103 | |
104 | ?> |