Пример #1
0
 public static function save($vpl, $userid, $files)
 {
     global $USER;
     if ($subid = $vpl->add_submission($userid, $files, '', $error_message)) {
         $id = $vpl->get_course_module()->id;
         \mod_vpl\event\submission_uploaded::log(array('objectid' => $subid, 'context' => $vpl->get_context(), 'relateduserid' => $USER->id != $userid ? $userid : null));
     } else {
         throw new Exception(get_string('notsaved', VPL) . ': ' . $error_message);
     }
 }
Пример #2
0
            $encode = mb_detect_encoding($data, 'UNICODE, UTF-16, UTF-8, ISO-8859-1', true);
            if ($encode > '') {
                //If code detected
                $data = iconv($encode, 'UTF-8', $data);
            }
            $files[] = array('name' => $name, 'data' => $data);
        } else {
            if ($i < $minfiles) {
                //add empty file if required
                $files[] = array('name' => '', 'data' => '');
            }
        }
    }
    $error_message = '';
    if ($subid = $vpl->add_submission($userid, $files, $fromform->comments, $error_message)) {
        \mod_vpl\event\submission_uploaded::log(array('objectid' => $subid, 'context' => $vpl->get_context(), 'relateduserid' => $USER->id != $userid ? $userid : null));
        //if evaluate on submission
        if ($instance->evaluate && $instance->evaluateonsubmission) {
            notice(get_string('saved', VPL), vpl_mod_href('forms/evaluation.php', 'id', $id, 'userid', $userid));
        }
        notice(get_string('saved', VPL), vpl_mod_href('forms/submissionview.php', 'id', $id, 'userid', $userid));
    } else {
        echo $OUTPUT->box(get_string('notsaved', VPL));
        notice($error_message, vpl_mod_href('forms/submission.php', 'id', $id, 'userid', $userid), $vpl->get_course());
    }
}
//Display page
$data = new stdClass();
$data->id = $id;
$data->userid = $userid;
$mform->set_data($data);