/** * generic handler function for all events - triggers sending of files. * @return boolean */ public function event_handler($eventdata) { global $DB, $CFG; $supported_events = compilatio_supported_events(); if (!in_array($eventdata->eventtype, $supported_events)) { return true; // Don't need to handle this event. } $plagiarismsettings = $this->get_settings(); if (!$plagiarismsettings) { return true; } $cmid = !empty($eventdata->cm->id) ? $eventdata->cm->id : $eventdata->cmid; $plagiarismvalues = $DB->get_records_menu('plagiarism_compilatio_config', array('cm' => $cmid), '', 'name, value'); if (empty($plagiarismvalues['use_compilatio'])) { // Compilatio not in use for this cm - return. return true; } // Check if the module associated with this event still exists. if (!$DB->record_exists('course_modules', array('id' => $eventdata->cmid))) { return true; } if ($eventdata->eventtype == 'files_done' || $eventdata->eventtype == 'content_done') { // Assignment-specific functionality: // This is a 'finalize' event. No files from this event itself, // but need to check if files from previous events need to be submitted for processing. mtrace("finalise"); $result = true; if (isset($plagiarismvalues['compilatio_draft_submit']) && $plagiarismvalues['compilatio_draft_submit'] == PLAGIARISM_COMPILATIO_DRAFTSUBMIT_FINAL) { // Any files attached to previous events were not submitted. // These files are now finalized, and should be submitted for processing. if ($eventdata->modulename == 'assignment') { require_once "{$CFG->dirroot}/mod/assignment/lib.php"; // Hack to include filelib so that file_storage class is available // We need to get a list of files attached to this assignment and put them in an array, so that // We can submit each of them for processing $assignmentbase = new assignment_base($cmid); $submission = $assignmentbase->get_submission($eventdata->userid); $modulecontext = module_context::instance($eventdata->cmid); $fs = get_file_storage(); if ($files = $fs->get_area_files($modulecontext->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) { foreach ($files as $file) { $sendresult = compilatio_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; } } } else { if ($eventdata->modulename == 'assign') { require_once "{$CFG->dirroot}/mod/assign/locallib.php"; $modulecontext = context_module::instance($eventdata->cmid); $fs = get_file_storage(); if ($files = $fs->get_area_files($modulecontext->id, 'assignsubmission_file', ASSIGNSUBMISSION_FILE_FILEAREA, $eventdata->itemid, "id", false)) { foreach ($files as $file) { $sendresult = compilatio_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; } } $submission = $DB->get_record('assignsubmission_onlinetext', array('submission' => $eventdata->itemid)); if (!empty($submission)) { $eventdata->content = trim(format_text($submission->onlinetext, $submission->onlineformat, array('context' => $modulecontext))); $file = compilatio_create_temp_file($cmid, $eventdata); $sendresult = compilatio_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; unlink($file->filepath); //Delete temp file. } } } } return $result; } if (isset($plagiarismvalues['compilatio_draft_submit']) && $plagiarismvalues['compilatio_draft_submit'] == PLAGIARISM_COMPILATIO_DRAFTSUBMIT_FINAL) { // Assignment-specific functionality: // Files should only be sent for checking once "finalized". return true; } // Text is attached $result = true; if (!empty($eventdata->content)) { $file = compilatio_create_temp_file($cmid, $eventdata); $sendresult = compilatio_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; unlink($file->filepath); } // Normal situation: 1 or more assessable files attached to event, ready to be checked: if (!empty($eventdata->pathnamehashes)) { foreach ($eventdata->pathnamehashes as $hash) { $fs = get_file_storage(); $efile = $fs->get_file_by_hash($hash); if (empty($efile)) { mtrace("nofilefound!"); continue; } else { if ($efile->get_filename() === '.') { // This 'file' is actually a directory - nothing to submit. continue; } } $sendresult = compilatio_send_file($cmid, $eventdata->userid, $efile, $plagiarismsettings); $result = $result && $sendresult; } } return $result; }
function assignment_uploadsingle($cmid = 'staticonly', $assignment = NULL, $cm = NULL, $course = NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); $this->type = 'uploadsingle'; }
function process_feedback($formdata=null) { if (!$feedback = data_submitted() or !confirm_sesskey()) { // No incoming data? return false; } $userid = required_param('userid', PARAM_INT); $offset = required_param('offset', PARAM_INT); $mform = $this->display_submission($offset, $userid, false); parent::process_feedback($mform); }
function assignment_sloodleobject($cmid = 0, $assignment = NULL, $cm = NULL, $course = NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); $this->type = 'sloodleobject'; }
function delete_instance($assignment) { global $CFG; $result = true; // Delete review criteria checked values if (!delete_records_select('assignment_review_criterion', 'review IN ( SELECT id FROM ' . $CFG->prefix . 'assignment_review WHERE assignment = ' . $assignment->id . ' )')) { $result = false; } // Delete reviews if (!delete_records('assignment_review', 'assignment', $assignment->id)) { $result = false; } // Delete criteria settings if (!delete_records('assignment_criteria', 'assignment', $assignment->id)) { $result = false; } // Delete extra settings if (!delete_records('assignment_peerreview', 'assignment', $assignment->id)) { $result = false; } $retval = parent::delete_instance($assignment); return $retval && $result; }
function reset_userdata($data) { global $CFG; if (!empty($data->reset_assignment_submissions)) { delete_records_select('assignment_uploadpdf_comment', 'assignment_submission IN ( SELECT s.id FROM ' . $CFG->prefix . 'assignment_submissions s JOIN ' . $CFG->prefix . 'assignment a ON s.assignment = a.id WHERE a.course = ' . $data->courseid . ' )'); } return parent::reset_userdata($data); }
function assignment_uploadsingle($cmid = 0) { parent::assignment_base($cmid); }
function assignment_upload($cmid = 'staticonly', $assignment = NULL, $cm = NULL, $course = NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); }
function assignment_offline($cmid = 0) { parent::assignment_base($cmid); }
/** * Generic handler function for all events - triggers sending of files. * @return boolean */ public function event_handler($eventdata) { global $DB, $CFG; $supportedevents = urkund_supported_events(); if (!in_array($eventdata->eventtype, $supportedevents)) { return true; // Don't need to handle this event. } $plagiarismsettings = $this->get_settings(); if (!$plagiarismsettings) { return true; } $cmid = !empty($eventdata->cm->id) ? $eventdata->cm->id : $eventdata->cmid; $plagiarismvalues = $DB->get_records_menu('plagiarism_urkund_config', array('cm' => $cmid), '', 'name, value'); if (empty($plagiarismvalues['use_urkund'])) { // Urkund not in use for this cm - return. return true; } // Check if the module associated with this event still exists. if (!$DB->record_exists('course_modules', array('id' => $eventdata->cmid))) { return true; } if ($eventdata->eventtype == 'files_done' || $eventdata->eventtype == 'content_done' || $eventdata->eventtype == 'assessable_submitted' && $eventdata->params['submission_editable'] == false) { // Assignment-specific functionality: // This is a 'finalize' event. No files from this event itself, // but need to check if files from previous events need to be submitted for processing. mtrace("finalise"); $result = true; if (isset($plagiarismvalues['urkund_draft_submit']) && $plagiarismvalues['urkund_draft_submit'] == PLAGIARISM_URKUND_DRAFTSUBMIT_FINAL) { // Any files attached to previous events were not submitted. // These files are now finalized, and should be submitted for processing. if ($eventdata->modulename == 'assignment') { // Hack to include filelib so that file_storage class is available. require_once "{$CFG->dirroot}/mod/assignment/lib.php"; // We need to get a list of files attached to this assignment and put them in an array, so that // we can submit each of them for processing. $assignmentbase = new assignment_base($cmid); $submission = $assignmentbase->get_submission($eventdata->userid); $modulecontext = context_module::instance($eventdata->cmid); $fs = get_file_storage(); if ($files = $fs->get_area_files($modulecontext->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) { foreach ($files as $file) { $sendresult = urkund_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; } } } else { if ($eventdata->modulename == 'assign') { require_once "{$CFG->dirroot}/mod/assign/locallib.php"; require_once "{$CFG->dirroot}/mod/assign/submission/file/locallib.php"; $modulecontext = context_module::instance($eventdata->cmid); $fs = get_file_storage(); if ($files = $fs->get_area_files($modulecontext->id, 'assignsubmission_file', ASSIGNSUBMISSION_FILE_FILEAREA, $eventdata->itemid, "id", false)) { foreach ($files as $file) { $sendresult = urkund_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; } } $submission = $DB->get_record('assignsubmission_onlinetext', array('submission' => $eventdata->itemid)); if (!empty($submission)) { $eventdata->content = trim(format_text($submission->onlinetext, $submission->onlineformat, array('context' => $modulecontext))); $file = urkund_create_temp_file($cmid, $eventdata); $sendresult = urkund_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; unlink($file->filepath); // Delete temp file. } } } } return $result; } if (isset($plagiarismvalues['urkund_draft_submit']) && $plagiarismvalues['urkund_draft_submit'] == PLAGIARISM_URKUND_DRAFTSUBMIT_FINAL) { // Assignment-specific functionality: // Files should only be sent for checking once "finalized". return true; } // Text is attached. $result = true; if (!empty($eventdata->content)) { $file = urkund_create_temp_file($cmid, $eventdata); $sendresult = urkund_send_file($cmid, $eventdata->userid, $file, $plagiarismsettings); $result = $result && $sendresult; unlink($file->filepath); // Delete temp file. } // Normal situation: 1 or more assessable files attached to event, ready to be checked. if (!empty($eventdata->pathnamehashes)) { foreach ($eventdata->pathnamehashes as $hash) { $fs = get_file_storage(); $efile = $fs->get_file_by_hash($hash); if (empty($efile)) { mtrace("nofilefound!"); continue; } else { if ($efile->get_filename() === '.') { // This 'file' is actually a directory - nothing to submit. continue; } } // Check if assign group submission is being used. if ($eventdata->modulename == 'assign') { require_once "{$CFG->dirroot}/mod/assign/locallib.php"; $modulecontext = context_module::instance($eventdata->cmid); $assign = new assign($modulecontext, false, false); if (!empty($assign->get_instance()->teamsubmission)) { $mygroups = groups_get_user_groups($assign->get_course()->id, $eventdata->userid); if (count($mygroups) == 1) { $groupid = reset($mygroups)[0]; // Only users with single groups are supported - otherwise just use the normal userid on this record. // Get all users from this group. $userids = array(); $users = groups_get_members($groupid, 'u.id'); foreach ($users as $u) { $userids[] = $u->id; } // Find the earliest plagiarism record for this cm with any of these users. $sql = 'cm = ? AND userid IN (' . implode(',', $userids) . ')'; $previousfiles = $DB->get_records_select('plagiarism_urkund_files', $sql, array($eventdata->cmid), 'id'); $sanitycheckusers = 10; // Search through this number of users to find a valid previous submission. $i = 0; foreach ($previousfiles as $pf) { if ($pf->userid == $eventdata->userid) { break; // The submission comes from this user so break. } // Sanity Check to make sure the user isn't in multiple groups. $pfgroups = groups_get_user_groups($assign->get_course()->id, $pf->userid); if (count($pfgroups) == 1) { // This user made the first valid submission so use their id when sending the file. $eventdata->userid = $pf->userid; break; } if ($i >= $sanitycheckusers) { // don't cause a massive loop here and break at a sensible limit. break; } $i++; } } } } $sendresult = urkund_send_file($cmid, $eventdata->userid, $efile, $plagiarismsettings); $result = $result && $sendresult; } } return $result; }
public function event_handler($eventdata) { global $DB, $CFG; $plagiarismsettings = $this->get_settings(); $cmid = !empty($eventdata->cm->id) ? $eventdata->cm->id : $eventdata->cmid; $plagiarismvalues = $DB->get_records_menu('plagiarism_turnitin_config', array('cm' => $cmid), '', 'name,value'); if (!$plagiarismsettings || empty($plagiarismvalues['use_turnitin'])) { //nothing to do here... move along! return true; } if ($eventdata->eventtype == "mod_created") { return turnitin_update_assignment($plagiarismsettings, $plagiarismvalues, $eventdata, 'create'); } else { if ($eventdata->eventtype == "mod_updated") { return turnitin_update_assignment($plagiarismsettings, $plagiarismvalues, $eventdata, 'update'); } else { if ($eventdata->eventtype == "mod_deleted") { return turnitin_update_assignment($plagiarismsettings, $plagiarismvalues, $eventdata, 'delete'); } else { if ($eventdata->eventtype == "file_uploaded") { // check if the module associated with this event still exists $cm = $DB->get_record('course_modules', array('id' => $eventdata->cmid)); $modulename = $DB->get_field('modules', 'name', array('id' => $cm->module)); if (!$cm) { return true; } // If the assignment has only just been set up, we don't want to try to submit to it, or // we'll get a 1001 error $assignmentstarttime = $DB->get_field('plagiarism_turnitin_config', 'value', array('cm' => $cm->id, 'name' => 'turnitin_dtstart')); if ($assignmentstarttime > time()) { // May not be set up properly - we need to allow for wonky server clocks. mtrace("Warning: assignment start time is too early " . date('Y-m-d H:i:s', $assignmentstarttime) . " cmid:" . $eventdata->cmid . " will delay sending files until next cron"); return false; } if (!empty($eventdata->file) && empty($eventdata->files)) { //single assignment type passes a single file $eventdata->files[] = $eventdata->file; } if (empty($eventdata->files)) { // There are no files attached to this 'fileuploaded' event. // This is a 'finalize' event - assignment-focused functionality mtrace("finalise"); if (isset($plagiarismvalues['plagiarism_draft_submit']) && $plagiarismvalues['plagiarism_draft_submit'] == PLAGIARISM_TII_DRAFTSUBMIT_FINAL) { // Drafts haven't previously been sent // get assignment details, list of draft files and submit to TII. require_once "{$CFG->dirroot}/mod/{$modulename}/lib.php"; // we need to get a list of files attached to this assignment and put them in an array, so that // we can submit each of them for processing. $assignmentbase = new assignment_base($cmid); $submission = $assignmentbase->get_submission($eventdata->userid); $modulecontext = get_context_instance(CONTEXT_MODULE, $eventdata->cmid); $fs = get_file_storage(); $result = true; if ($files = $fs->get_area_files($modulecontext->id, 'mod_' . $modulename, 'submission', $submission->id, "timemodified", false)) { foreach ($files as $file) { $fileresult = false; //TODO: need to check if this file has already been sent! - possible that the file was sent before draft submit was set. $pid = plagiarism_update_record($cmid, $eventdata->userid, $file->get_pathnamehash()); if (!empty($pid)) { $fileresult = turnitin_send_file($pid, $plagiarismsettings, $file); } $result = $fileresult && $result; } } return $result; } } // Assignment-module focused functionality: if (isset($plagiarismvalues['plagiarism_draft_submit']) && $plagiarismvalues['plagiarism_draft_submit'] == PLAGIARISM_TII_DRAFTSUBMIT_FINAL) { // Files shouldn't be submitted to TII until 'finalize' file upload event. return true; } // Normal scenario - this is an upload event with one or more attached files // Attached file(s) are to be immediately submitted to TII $result = true; foreach ($eventdata->files as $efile) { $fileresult = false; if ($efile->get_filename() === '.') { // This is a directory - nothing to do. continue; } //hacky way to check file still exists $fs = get_file_storage(); $fileid = $fs->get_file_by_hash($efile->get_pathnamehash()); if (empty($fileid)) { mtrace("nofilefound!"); continue; } //check if this particular file has already been submitted. $pid = plagiarism_update_record($cmid, $eventdata->userid, $efile->get_pathnamehash()); if (!empty($pid)) { $fileresult = turnitin_send_file($pid, $plagiarismsettings, $efile); } else { $fileresult = true; //file already been sent. } $result = $result && $fileresult; } return $result; } else { if ($eventdata->eventtype == "quizattempt") { //get list of essay questions and the users answer in this quiz $sql = "SELECT s.* FROM {question} q, {quiz_question_instances} i, {question_states} s, {question_sessions} qs\n WHERE i.quiz = ? AND i.quiz=q.id AND q.qtype='essay'\n AND s.question = q.id AND qs.questionid= q.id AND qs.newest = s.id AND qs.attemptid = s.attempt AND s.attempt = ?"; $essayquestions = $DB->get_records_sql($sql, array($eventdata->quiz, $eventdata->attempt)); //check dir exists if (!file_exists($CFG->dataroot . "/temp/turnitin")) { if (!file_exists($CFG->dataroot . "/temp")) { mkdir($CFG->dataroot . "/temp", 0700); } mkdir($CFG->dataroot . "/temp/turnitin", 0700); } foreach ($essayquestions as $qid) { //get actual response //create file to send $pid = plagiarism_update_record($cmid, $eventdata->userid, $qid->id); if (!empty($pid)) { $file = new stdclass(); $file->type = "tempturnitin"; $file->filename = $pid . ".txt"; $file->timestamp = $qid->timestamp; $file->filepath = $CFG->dataroot . "/temp/turnitin/" . $pid . ".txt"; $fd = fopen($file->filepath, 'wb'); //create if not exist, write binary fwrite($fd, $qid->answer); fclose($fd); $result = turnitin_send_file($pid, $plagiarismsettings, $file); unlink($file->filepath); //delete temp file. } } return true; } else { return true; //Don't need to handle this event } } } } } }
/** * Update grade item for this submission. */ function update_grade($submission) { // get team $team = $this->get_user_team($submission->userid); // get team members $members = $this->get_members_from_team($team->id); // update each member grade and other info with current user's submissions data foreach ($members as $member) { $membersubmission = $this->get_submission($member->student, true); // Get or make one $membersubmission->grade = $submission->grade; $membersubmission->submissioncomment = $submission->submissioncomment; $membersubmission->teacher = $submission->teacher; $membersubmission->timemarked = $submission->timemarked; if (!update_record('assignment_submissions', $membersubmission)) { return false; } // make sure parent class function call is "fired" for each user parent::update_grade($this->assignment, $membersubmission->userid); // update table's info (submissions list UI) print $this->update_main_listing($membersubmission); // add special log entry for team grading add_to_log($this->course->id, 'assignment', 'update grades team', 'submissions.php?id=' . $this->assignment->id . '&user=' . $feedback->userid, $feedback->userid, $this->cm->id); } }
function crot_event_file_uploaded($eventdata) { global $DB, $CFG; $result = true; //mainly used by assignment finalize - used if you want to handle "submit for marking" events //a file has been uploaded/finalised - submit this to the plagiarism prevention service. // $plagiarismvalues = $DB->get_records_menu('plagiarism_crot_config', array('cm'=>$eventdata->cmid),'','name,value'); $cmid = !empty($eventdata->cm->id) ? $eventdata->cm->id : $eventdata->cmid; $plagiarismvalues = $DB->get_records_menu('plagiarism_crot_config', array('cm' => $cmid), '', 'name,value'); if (empty($plagiarismvalues['crot_use'])) { return $result; } else { //sw 21/02 $cm = $DB->get_record('course_modules', array('id' => $eventdata->cmid)); if (empty($cm)) { $cm = $DB->get_record('course_modules', array('id' => $cmid)); } //sw if (empty($cm)) { return $result; } $modulename = $DB->get_field('modules', 'name', array('id' => $cm->module)); //sw uncommented require_once "{$CFG->dirroot}/mod/{$modulename}/lib.php"; //sw $status_value = array('queue', 'in_processing', 'end_processing'); $modulecontext = get_context_instance(CONTEXT_MODULE, $eventdata->cmid); // put files that were submitted for marking into queue for check up //sw if ($eventdata->modulename == 'assignment') { require_once "{$CFG->dirroot}/mod/assignment/lib.php"; $assignmentbase = new assignment_base($cmid); $submission = $assignmentbase->get_submission($eventdata->userid); $fs = get_file_storage(); if ($files = $fs->get_area_files($modulecontext->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) { foreach ($files as $file) { if ($file->get_filename() === '.') { // This 'file' is actually a directory - nothing to submit. continue; } $newelement = new stdclass(); $newelement->file_id = $file->get_id(); $newelement->path = $file->get_contenthash(); $newelement->status = $status_value[0]; $newelement->time = time(); $newelement->cm = $eventdata->cmid; $newelement->courseid = $eventdata->courseid; $result = $DB->insert_record('plagiarism_crot_files', $newelement); echo "\nfile " . $file->get_filename() . " was queued up for plagiarism detection service\n"; } } } else { if ($eventdata->modulename == 'assign') { //sw foreach ($eventdata->pathnamehashes as $hash) { $fs = get_file_storage(); $file = $fs->get_file_by_hash($hash); if (empty($file) || $file->get_filename() === '.') { // This 'file' is actually a directory - nothing to submit. continue; } $newelement = new stdclass(); $newelement->file_id = $file->get_id(); $newelement->path = $file->get_contenthash(); $newelement->status = $status_value[0]; $newelement->time = time(); $newelement->cm = $eventdata->cmid; $newelement->courseid = $eventdata->courseid; $result = $DB->insert_record('plagiarism_crot_files', $newelement); echo "\nfile " . $file->get_filename() . " was queued up for plagiarism detection service\n"; } //ws } //end assign } ///ws return $result; } }
function assignment_poodlljournal($cmid = 'staticonly', $assignment = NULL, $cm = NULL, $course = NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); $this->type = 'poodlljournal'; }
/** * Prepares the data for the grading form. * * @param $course * @param $assignment * @param $submission * @param $user * @param $coursemodule * @param assignment_base $assignmentinstance * @global $USER * @global $CFG * @return array */ private function get_mform_data_object($course, $assignment, $submission, $user, $coursemodule, $assignmentinstance) { global $USER, $CFG; $context = context_module::instance($coursemodule->id); // Get grading information to see whether we should be allowed to make changed at all. $grading_info = grade_get_grades($course->id, 'mod', 'assignment', $assignment->id, array($user->id)); $locked = $grading_info->items[0]->grades[$user->id]->locked; $overridden = $grading_info->items[0]->grades[$user->id]->overridden; $gradingdisabled = $locked || $overridden; $mformdata = new stdClass(); $mformdata->context = $context; $mformdata->maxbytes = $course->maxbytes; $mformdata->courseid = $course->id; $mformdata->teacher = $USER; $mformdata->assignment = $assignment; $mformdata->submission = $submission; $mformdata->lateness = assignment_display_lateness($submission->timemodified, $assignment->timedue); $mformdata->user = $user; $mformdata->offset = false; $mformdata->userid = $user->id; $mformdata->cm = $coursemodule; $mformdata->grading_info = $grading_info; $mformdata->enableoutcomes = $CFG->enableoutcomes; $mformdata->grade = $assignment->grade; $mformdata->gradingdisabled = $gradingdisabled; // TODO set nextid to the nextnode id. $mformdata->nextid = false; $mformdata->submissioncomment = $submission->submissioncomment; $mformdata->submissioncommentformat = FORMAT_HTML; $mformdata->submission_content = $assignmentinstance->print_user_files($user->id, true); if ($assignment->assignmenttype == 'upload') { $mformdata->fileui_options = array('subdirs' => 1, 'maxbytes' => $assignment->maxbytes, 'maxfiles' => $assignment->var1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL); } else { if ($assignment->assignmenttype == 'uploadsingle') { $mformdata->fileui_options = array('subdirs' => 0, 'maxbytes' => $CFG->userquota, 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL); } } $advancedgradingwarning = false; $gradingmanager = get_grading_manager($context, 'mod_assignment', 'submission'); if ($gradingmethod = $gradingmanager->get_active_method()) { // This returns a gradingform_controller instance, not grading_controller as docs // say. /* @var gradingform_controller $controller */ $controller = $gradingmanager->get_controller($gradingmethod); if ($controller->is_form_available()) { $itemid = null; if (!empty($submission->id)) { $itemid = $submission->id; } if ($gradingdisabled && $itemid) { $mformdata->advancedgradinginstance = $controller->get_current_instance($USER->id, $itemid); return array($mformdata, $advancedgradingwarning); } else { if (!$gradingdisabled) { $instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT); $mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid); return array($mformdata, $advancedgradingwarning); } } return array($mformdata, $advancedgradingwarning); } else { $advancedgradingwarning = $controller->form_unavailable_notification(); return array($mformdata, $advancedgradingwarning); } } return array($mformdata, $advancedgradingwarning); }
function reset_userdata($data) { global $CFG, $DB; //UT if (!empty($data->reset_assignment_submissions)) { $DB->delete_records_select('assignment_uploadpdf_comment', 'assignment_submission IN ( SELECT s.id FROM {assignment_submissions} s JOIN {assignment} a ON s.assignment = a.id WHERE a.course = ? ) ', array($data->courseid)); $DB->delete_records_select('assignment_uploadpdf_annot', 'assignment_submission IN ( SELECT s.id FROM {assignment_submissions} s JOIN {assignment} a ON s.assignment = a.id WHERE a.course = ? ) ', array($data->courseid)); } return parent::reset_userdata($data); }
function assignment_online($cmid = 'staticonly', $assignment = NULL, $cm = NULL, $course = NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); $this->type = 'online'; }
function assignment_babelium($cmid = 'staticonly', $assignment = NULL, $cm = NULL, $course = NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); $this->type = 'babelium'; babelium_parse_settings(); }