Added event handling to new assignment. Whopos!

This commit is contained in:
moodler 2005-05-31 23:00:20 +00:00
parent a5893b087c
commit 736f191c1d
4 changed files with 60 additions and 4 deletions

View File

@ -154,6 +154,11 @@ function assignment_upgrade($oldversion) {
table_column('assignment', '', 'preventlate', 'integer', '2', 'unsigned', '0', 'not null', 'resubmit');
}
if ($oldversion < 2005060100) {
include_once("$CFG->dirroot/mod/assignment/lib.php");
assignment_refresh_events();
}
/// These lines ALWAYS need to be here at the end of this file. Don't mess with them. :-)
include_once("$CFG->dirroot/mod/assignment/lib.php");

View File

@ -152,6 +152,11 @@ function assignment_upgrade($oldversion) {
table_column('assignment', '', 'preventlate', 'integer', '2', 'unsigned', '0', 'not null', 'resubmit');
}
if ($oldversion < 2005060100) {
include_once("$CFG->dirroot/mod/assignment/lib.php");
assignment_refresh_events();
}
/// These lines ALWAYS need to be here at the end of this file. Don't mess with them. :-)
include_once("$CFG->dirroot/mod/assignment/lib.php");

View File

@ -342,11 +342,42 @@ class assignment_base {
$assignment->availableminute);
}
return insert_record('assignment', $assignment);
if ($returnid = insert_record("assignment", $assignment)) {
$event = NULL;
$event->name = $assignment->name;
$event->description = $assignment->description;
$event->courseid = $assignment->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'assignment';
$event->instance = $returnid;
$event->eventtype = 'due';
$event->timestart = $assignment->timedue;
$event->timeduration = 0;
add_event($event);
}
return $returnid;
}
function delete_instance($assignment) {
return delete_records('assignment', 'id', $assignment->id);
$result = true;
if (! delete_records('assignment_submissions', 'assignment', $assignment->id)) {
$result = false;
}
if (! delete_records('assignment', 'id', $assignment->id)) {
$result = false;
}
if (! delete_records('event', 'modulename', 'assignment', 'instance', $assignment->id)) {
$result = false;
}
return $result;
}
function update_instance($assignment) {
@ -374,7 +405,22 @@ class assignment_base {
}
$assignment->id = $assignment->instance;
return update_record('assignment', $assignment);
if ($returnid = update_record('assignment', $assignment)) {
$event = NULL;
if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) {
$event->name = $assignment->name;
$event->description = $assignment->description;
$event->timestart = $assignment->timedue;
update_event($event);
}
}
return $returnid;
}

View File

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2005051706;
$module->version = 2005060100;
$module->requires = 2005031000; // Requires this Moodle version
$module->cron = 60;