]> git.mjollnir.org Git - moodle.git/commitdiff
Some work so far on the assignment module ... NOT FINISHED YET!
authormartin <martin>
Thu, 1 Aug 2002 03:49:01 +0000 (03:49 +0000)
committermartin <martin>
Thu, 1 Aug 2002 03:49:01 +0000 (03:49 +0000)
I just want to get it out the way of some other commits

mod/assignment/lib.php [new file with mode: 0644]
mod/assignment/mod.html [new file with mode: 0644]
mod/assignment/mod.php [new file with mode: 0644]

diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/mod/assignment/mod.html b/mod/assignment/mod.html
new file mode 100644 (file)
index 0000000..d24841b
--- /dev/null
@@ -0,0 +1,35 @@
+<form name="form" method="post" action="<?=$ME ?>">
+<table cellpadding=5>
+<tr valign=top>
+    <td align=right><P><B>Assignment Name:</B></P></TD>
+    <td>
+        <input type="text" name="name" size=30 value="<? p($form->name) ?>">
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><P><B>Description:</B></P></TD>
+    <td>
+        <textarea name="description" rows=15 cols=30 wrap="virtual"><? p($form->description) ?></textarea>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><P><B>Due date:</B></td>
+    <td><?
+           print_date_selector("dueday", "duemonth", "dueyear", $form->dueday, $form->duemonth, $form->dueyear);
+           echo "-";
+           print_time_selector("duehour", "dueminute", $form->duehour, $form->dueminute);
+           formerr($err["duedate"]);
+    ?></td>
+</tr>
+</table>
+<CENTER>
+<input type="hidden" name=course     value="<? p($form->course) ?>">
+<input type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
+<input type="hidden" name=section       value="<? p($form->section) ?>">
+<input type="hidden" name=module     value="<? p($form->module) ?>">
+<input type="hidden" name=modulename value="<? p($form->modulename) ?>">
+<input type="hidden" name=instance   value="<? p($form->instance) ?>">
+<input type="hidden" name=mode       value="<? p($form->mode) ?>">
+<input type="submit" value="Save these settings">
+</CENTER>
+</FORM>
diff --git a/mod/assignment/mod.php b/mod/assignment/mod.php
new file mode 100644 (file)
index 0000000..8e588b5
--- /dev/null
@@ -0,0 +1,59 @@
+<?PHP  // $Id$
+
+/////////////////////////////////////////////////////////////
+//
+// MOD.PHP - contains functions to add, update and delete
+//           an instance of this module
+//           
+//           Generally called from /course/mod.php
+//
+/////////////////////////////////////////////////////////////
+
+function add_instance($assignment) {
+// 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.
+
+    $assignment->timemodified = time();
+
+    return insert_record("assignment", $assignment);
+}
+
+
+function update_instance($assignment) {
+// 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.
+
+    $assignment->timemodified = time();
+    $assignment->id = $assignment->instance;
+
+    return update_record("assignment", $assignment);
+}
+
+
+function 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 (! $assignment = get_record("assignment", "id", "$id")) {
+        return false;
+    }
+
+    $result = true;
+
+    if (! delete_records("assignment_submissions", "assignment", "$assignment->id")) {
+        $result = false;
+    }
+
+    if (! delete_records("assignment", "id", "$assignment->id")) {
+        $result = false;
+    }
+
+    return $result;
+}
+
+
+?>