/** * Saves the initial signature in the feedback table, and signs it if needed. * * @param stdClass $grade * @param bool $showviewlink Set to true to show a link to view the full feedback * @return string */ public function process_initial_esigning($grade, $feedbacktoken = false) { global $DB; $user = $DB->get_record('user', array('id' => $grade->grader)); $esign = $this->get_signature($grade); if (!$esign) { $esign = new stdClass(); $esign->signedtoken = 'empty_token'; $esign->contextid = $this->assignment->get_context()->id; $esign->component = 'assignfeedback_esign'; $esign->grade = $grade->id; $esign->userid = $grade->grader; $esign->signee = fullname($user); $esign->timesigned = time(); $DB->insert_record('assignfeedback_esign', $esign); } if ($feedbacktoken) { $esign = $DB->get_record('assignfeedback_esign', array('grade' => $grade->id)); $esign->signedtoken = $_SESSION['assign' . $this->assignment->get_course_module()->id]['feedback_token']; $esign->timesigned = time(); $DB->update_record('assignfeedback_esign', $esign); $event = \assignfeedback_esign\event\grade_signed::create_from_grade($this->assignment, $grade); $event->trigger(); } return; }
if ($storkattributes) { $storktoken = $storkattributes['eIdentifier']; $_SESSION['assign' . $cmid]['feedback_token'] = $storktoken; if ($esignforall) { redirect('../../view.php?id=' . $cmid . '&action=grading', get_string('esignforalladded', 'assignfeedback_esign')); } $esign = $DB->get_record('assignfeedback_esign', array('grade' => $grade->id)); $esign->signedtoken = $storktoken; $esign->timesigned = time(); $DB->update_record('assignfeedback_esign', $esign); // Build a new assign object. $context = context_module::instance($cmid); $cm = get_coursemodule_from_id('assign', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $PAGE->set_context($context); $PAGE->set_url('/mod/assign/view.php', array('id' => $cmid)); $PAGE->set_course($course); $PAGE->set_cm($cm); $PAGE->set_title(get_string('pluginname', 'assignfeedback_esign')); $PAGE->set_pagelayout('standard'); $assignment = new assign($context, $cm, $course); $event = \assignfeedback_esign\event\grade_signed::create_from_grade($assignment, $grade); $event->trigger(); $assignment->save_grade($grade->userid, $data); if ($nextpageparams) { $nextpageurl = new moodle_url('/mod/assign/view.php', $nextpageparams); redirect($nextpageurl); } else { redirect('../../view.php?id=' . $cmid); } }