MDL-11417 usermodified now stored properly in grade_grades table when update_(raw...
[moodle.git] / mod / assignment / type / offline / assignment.class.php
CommitLineData
b0f2597e 1<?php // $Id$
2
3/**
4 * Extend the base assignment class for offline assignments
5 *
6 */
7class assignment_offline extends assignment_base {
8
7bddd4b7 9 function assignment_offline($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL) {
10 parent::assignment_base($cmid, $assignment, $cm, $course);
b0f2597e 11 }
12
3994ef98 13 function display_lateness($timesubmitted) {
14 return '';
15 }
e768aabe 16 function print_student_answer($studentid){
17 return '';//does nothing!
18 }
45fa3412 19
16fc2088 20 function prepare_new_submission($userid) {
45fa3412 21 $submission = new Object;
16fc2088 22 $submission->assignment = $this->assignment->id;
23 $submission->userid = $userid;
24 $submission->timecreated = time(); // needed for offline assignments
25 $submission->timemodified = $submission->timecreated;
26 $submission->numfiles = 0;
27 $submission->data1 = '';
28 $submission->data2 = '';
29 $submission->grade = -1;
30 $submission->submissioncomment = '';
31 $submission->format = 0;
32 $submission->teacher = 0;
33 $submission->timemarked = 0;
34 $submission->mailed = 0;
35 return $submission;
36 }
45fa3412 37
16fc2088 38 // needed for the timemodified override
39 function process_feedback() {
40
41 global $USER;
42
43 if (!$feedback = data_submitted()) { // No incoming data?
44 return false;
45 }
46
47 ///For save and next, we need to know the userid to save, and the userid to go
48 ///We use a new hidden field in the form, and set it to -1. If it's set, we use this
49 ///as the userid to store
50 if ((int)$feedback->saveuserid !== -1){
51 $feedback->userid = $feedback->saveuserid;
52 }
53
54 if (!empty($feedback->cancel)) { // User hit cancel button
55 return false;
56 }
57
cc03871b 58 // store outcomes if needed
59 $this->process_outcomes($feedback->userid);
60
16fc2088 61 $submission = $this->get_submission($feedback->userid, true); // Get or make one
62
63 $submission->grade = $feedback->grade;
64 $submission->submissioncomment = $feedback->submissioncomment;
65 $submission->format = $feedback->format;
66 $submission->teacher = $USER->id;
67 $submission->mailed = 0; // Make sure mail goes out (again, even)
68 $submission->timemarked = time();
69
70 unset($submission->data1); // Don't need to update this.
71 unset($submission->data2); // Don't need to update this.
72
73 if (empty($submission->timemodified)) { // eg for offline assignments
74 $submission->timemodified = time();
75 }
76
77 if (! update_record('assignment_submissions', $submission)) {
78 return false;
79 }
80
7bddd4b7 81 // triger grade event
45fa3412 82 $this->update_grade($submission);
7bddd4b7 83
45fa3412 84 add_to_log($this->course->id, 'assignment', 'update grades',
16fc2088 85 'submissions.php?id='.$this->assignment->id.'&user='.$feedback->userid, $feedback->userid, $this->cm->id);
45fa3412 86
16fc2088 87 return $submission;
88
89 }
3994ef98 90
b0f2597e 91}
92
93?>