More monir tweaks
[moodle.git] / mod / assignment / lib.php
CommitLineData
04eba58f 1<?PHP // $Id$
2
3function assignment_add_instance($assignment) {
4// Given an object containing all the necessary data,
5// (defined by the form in mod.html) this function
6// will create a new instance and return the id number
7// of the new instance.
8
9 $assignment->timemodified = time();
10
11 return insert_record("assignment", $assignment);
12}
13
14
15function assignment_update_instance($assignment) {
16// Given an object containing all the necessary data,
17// (defined by the form in mod.html) this function
18// will update an existing instance with new data.
19
20 $assignment->timemodified = time();
21 $assignment->id = $assignment->instance;
22
23 return update_record("assignment", $assignment);
24}
25
26
27function assignment_delete_instance($id) {
28// Given an ID of an instance of this module,
29// this function will permanently delete the instance
30// and any data that depends on it.
31
32 if (! $assignment = get_record("assignment", "id", "$id")) {
33 return false;
34 }
35
36 $result = true;
37
38 if (! delete_records("assignment_submissions", "assignment", "$assignment->id")) {
39 $result = false;
40 }
41
42 if (! delete_records("assignment", "id", "$assignment->id")) {
43 $result = false;
44 }
45
46 return $result;
47}
48
49
50?>