in classes/api/base.php [649:690]
protected function prepare_feedback_postdata($submissionid, $assign, $student, $context, $isteacher, $gradeid) {
$boundary = hash('sha256', rand());
$postdata = null;
$a = new \stdClass;
$a->assign_name = $assign->name;
$a->student_firstname = $student->firstname;
$a->student_lastname = $student->lastname;
$pagetitle = get_string('feedbacktitle', 'local_onenote', $a);
// If previously saved feedback does not exist.
if (!$gradeid || !($files = $this->get_stored_page_data($context->id, 'feedback', $gradeid))) {
if ($isteacher) {
// This must be the first time teacher is looking at student's submission
// So prepare feedback page from submission zip package.
$files = $this->get_stored_page_data($context->id, 'submission', $submissionid);
if ($files) {
// Unzip the submission and prepare postdata from it.
$tempfolder = $this->create_temp_folder();
$fp = get_file_packer('application/zip');
$filelist = $fp->extract_to_pathname(reset($files), $tempfolder);
$folder = join(DIRECTORY_SEPARATOR, array(rtrim($tempfolder, DIRECTORY_SEPARATOR), '0'));
$postdata = $this->create_postdata_from_folder($pagetitle, $folder, $boundary);
} else {
// Student did not turn in a submission, so create an empty one.
$postdata = $this->create_postdata($pagetitle, $assign->intro, $context->id, $boundary);
}
} else {
$errstr = get_string('errorfeedbackinstudentcontext', 'local_onenote');
\local_onenote\utils::debug($errstr, 'prepare_feedback_postdata', $submissionid);
throw new \moodle_exception('errorfeedbackinstudentcontext', 'local_onenote');
}
} else {
// Create postdata from the zip package of teacher's feedback.
$tempfolder = $this->create_temp_folder();
$fp = get_file_packer('application/zip');
$filelist = $fp->extract_to_pathname(reset($files), $tempfolder);
$folder = join(DIRECTORY_SEPARATOR, array(rtrim($tempfolder, DIRECTORY_SEPARATOR), '0'));
$postdata = $this->create_postdata_from_folder($pagetitle, $folder, $boundary);
}
return [$postdata, $boundary];
}