/** * Load the submission object for a particular user * * @param $userid int The id of the user whose submission we want or 0 in which case USER->id is used * @param $createnew boolean optional Defaults to false. If set to true a new submission object will be created in the database * @return object The submission */ function get_submission($createnew = false) { $submission = get_record('webquestscorm_submissions', 'webquestscorm', $this->webquestscorm, 'userid', $this->userid); if ($submission || !$createnew) { return $submission; } $newsubmission = $this->prepare_new_submission(); if (!insert_record("webquestscorm_submissions", $newsubmission)) { error("Could not insert a new empty submission"); } else { if ($CFG->version > 2007101500) { update_grade_for_webquestscorm($webquestscorm); } else { error($CFG->version); } } return get_record('webquestscorm_submissions', 'webquestscorm', $this->webquestscorm, 'userid', $this->userid); }
/** * Process teacher feedback submission * * This is called by submissions() when a grading even has taken place. * It gets its data from the submitted form. * @return object The updated submission object */ function process_feedback() { global $USER, $CFG; if (!($feedback = data_submitted())) { // No incoming data? return false; } ///For save and next, we need to know the userid to save, and the userid to go ///We use a new hidden field in the form, and set it to -1. If it's set, we use this ///as the userid to store if ((int) $feedback->saveuserid !== -1) { $feedback->userid = $feedback->saveuserid; } if (!empty($feedback->cancel)) { // User hit cancel button return false; } $submission = $this->get_submission($feedback->userid, true); // Get or make one $submission->grade = $feedback->grade; $submission->submissioncomment = $feedback->submissioncomment; $submission->format = $feedback->format; $submission->teacher = $USER->id; $submission->mailed = 0; // Make sure mail goes out (again, even) $submission->timemarked = time(); unset($submission->data1); // Don't need to update this. unset($submission->data2); // Don't need to update this. if (empty($submission->timemodified)) { // eg for offline assignments $submission->timemodified = time(); } if (!update_record('webquestscorm_submissions', $submission)) { return false; } else { if ($CFG->version > 2007101500) { update_grade_for_webquestscorm($webquestscorm); } } add_to_log($this->course->id, 'webquestscorm', 'update grades', 'editsubmissions.php?cmid=' . $this->cm->id . '&user='******'&element=uploadedTasks&subelement=all', $feedback->userid, $this->cm->id); return $submission; }
if ($newsubmission) { if (!insert_record('webquestscorm_submissions', $submission)) { return false; } else { if ($CFG->version > 2007101500) { update_grade_for_webquestscorm($webquestscorm); } else { error($CFG->version); } } } else { if (!update_record('webquestscorm_submissions', $submission)) { return false; } else { if ($CFG->version > 2007101500) { update_grade_for_webquestscorm($webquestscorm); } else { error($CFG->version); } } } //add to log only if updating add_to_log($submissionsinstance->course->id, 'webquestscorm', 'update grades', 'editsubmissions.php?cmid=' . $submissionsinstance->cm->id . '&user='******'&element=uploadedTasks&subelement=all', $submission->userid, $submissionsinstance->cm->id); } } print_heading(get_string('changessaved')); $submissionsinstance->display_submissions(); break; case 'next': /// We are currently in pop up, but we want to skip to next one without saving. /// This turns out to be similar to a single case