]> git.mjollnir.org Git - moodle.git/commitdiff
New version which adds events and amends them in the event table.
authorrkingdon <rkingdon>
Fri, 8 Oct 2004 21:41:10 +0000 (21:41 +0000)
committerrkingdon <rkingdon>
Fri, 8 Oct 2004 21:41:10 +0000 (21:41 +0000)
mod/exercise/db/mysql.php
mod/exercise/lib.php
mod/exercise/version.php

index 24da494dc249e3a2678a127dfeee6de467c3a892..86b1d26575366cf0958cd2ba3019917cdeaa424f 100644 (file)
@@ -34,6 +34,12 @@ function exercise_upgrade($oldversion) {
         table_column("exercise_assessments","generalcomment","generalcomment","text","","","","NOT NULL");
         table_column("exercise_assessments","teachercomment","teachercomment","text","","","","NOT NULL");
     }
+
+    if ($oldversion < 2004100800) {
+        include_once("$CFG->dirroot/mod/exercise/lib.php");
+        exercise_refresh_events();
+    }
+
     return true;
 }
 
index d84b2414c2a18ac835d7a0cbd2f8403e95fefa5d..1567ce477e1ffcf171efb6ff8adebc7095c65370 100644 (file)
@@ -67,7 +67,25 @@ function exercise_add_instance($exercise) {
                unset($exercise->password);
        }
 
-    return insert_record("exercise", $exercise);
+    if ($returnid = insert_record("exercise", $exercise)) {
+
+        $event = NULL;
+        $event->name        = $exercise->name;
+        $event->description = $exercise->description;
+        $event->courseid    = $exercise->course;
+        $event->groupid     = 0;
+        $event->userid      = 0;
+        $event->modulename  = 'exercise';
+        $event->instance    = $returnid;
+        $event->eventtype   = 'deadline';
+        $event->timestart   = $exercise->deadline;
+        $event->timeduration = 0;
+
+        add_event($event);
+    }
+
+
+    return $returnid;
 }
 
 
@@ -490,7 +508,21 @@ function exercise_update_instance($exercise) {
 
     $exercise->id = $exercise->instance;
 
-    return update_record("exercise", $exercise);
+    if ($returnid = update_record("exercise", $exercise)) {
+
+        $event = NULL;
+
+        if ($event->id = get_field('event', 'id', 'modulename', 'exercise', 'instance', $exercise->id)) {
+
+            $event->name        = $exercise->name;
+            $event->description = $exercise->description;
+            $event->timestart   = $exercise->deadline;
+
+            update_event($event);
+        }
+    }
+
+    return $returnid;
 }
 
 
index 31647ad7ea87f9f7f0e3e1c687573fa0786aa4b7..63c196398fcddc1ea234c1b8c7b99a6216bf255d 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004091700;
+$module->version  = 2004100800;
 $module->requires = 2004091700;  // Requires this Moodle version
 $module->cron     = 60;