in classes/api/base.php [702:732]
protected function prepare_submission_postdata($submissionid, $assign, $student, $context, $isteacher) {
$postdata = null;
$boundary = hash('sha256', rand());
$a = new \stdClass;
$a->assign_name = $assign->name;
$a->student_firstname = $student->firstname;
$a->student_lastname = $student->lastname;
$pagetitle = get_string('submissiontitle', 'local_onenote', $a);
if (!$submissionid || !($files = $this->get_stored_page_data($context->id, 'submission', $submissionid))) {
if ($isteacher) {
$errstr = get_string('errorsubmissioninteachercontext', 'local_onenote');
\local_onenote\utils::debug($errstr, 'prepare_submission_postdata', $submissionid);
throw new \moodle_exception('errorsubmissioninteachercontext', 'local_onenote');
} else {
// This is a student and they are just starting to work on this assignment.
// So prepare page from the assignment prompt.
$postdata = $this->create_postdata($pagetitle, $assign->intro, $context->id, $boundary);
}
} else {
// 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);
}
return [$postdata, $boundary];
}