/** * Unlock the student submission. * * @param int $userid * @return bool */ public function unlock_submission($userid) { global $USER, $DB; // Need grade permission. require_capability('mod/assign:grade', $this->context); // Give each submission plugin a chance to process the unlocking. $plugins = $this->get_submission_plugins(); $submission = $this->get_user_submission($userid, false); $flags = $this->get_user_flags($userid, true); $flags->locked = 0; $this->update_user_flags($flags); foreach ($plugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $plugin->unlock($submission, $flags); } } $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); $logmessage = get_string('unlocksubmissionforstudent', 'assign', array('id' => $user->id, 'fullname' => fullname($user))); $addtolog = $this->add_to_log('unlock submission', $logmessage, '', true); $params = array('context' => $this->context, 'objectid' => $flags->assignment, 'relateduserid' => $user->id); $event = \mod_assign\event\submission_unlocked::create($params); $event->set_legacy_logdata($addtolog); $event->trigger(); return true; }
/** * Unlock the student submission. * * @param int $userid * @return bool */ public function unlock_submission($userid) { global $USER, $DB; // Need grade permission. require_capability('mod/assign:grade', $this->context); // Give each submission plugin a chance to process the unlocking. $plugins = $this->get_submission_plugins(); $submission = $this->get_user_submission($userid, false); $flags = $this->get_user_flags($userid, true); $flags->locked = 0; $this->update_user_flags($flags); foreach ($plugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $plugin->unlock($submission, $flags); } } $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); \mod_assign\event\submission_unlocked::create_from_user($this, $user)->trigger(); return true; }