$userid = required_param('userid', PARAM_INT); $detailed = abs(optional_param('detailed', 0, PARAM_INT)) % 2; $vpl = new mod_vpl($id); $vpl->prepare_page('views/previoussubmissionslist.php', array('id' => $id, 'userid' => $userid)); $course = $vpl->get_course(); $vpl->require_capability(VPL_GRADE_CAPABILITY); \mod_vpl\event\submission_previous_upload_viewed::log(array('objectid' => $vpl->get_instance()->id, 'context' => context_module::instance($id), 'relateduserid' => $userid)); //Load strings $strdatesubmitted = get_string('datesubmitted', VPL); $strdescription = get_string('description', VPL); if ($detailed) { $PAGE->requires->css(new moodle_url('/mod/vpl/css/sh.css')); $PAGE->requires->css(new moodle_url('/mod/vpl/editor/VPLIDE.css')); } //Print header $vpl->print_header(get_string('previoussubmissionslist', VPL)); $vpl->print_view_tabs(basename(__FILE__)); $table = new html_table(); $table->head = array('#', $strdatesubmitted, $strdescription); $table->align = array('right', 'left', 'right'); $table->nowrap = array(true, true, true); $submissionslist = $vpl->user_submissions($userid); $submissions = array(); $nsub = count($submissionslist); foreach ($submissionslist as $submission) { if ($detailed) { $link = '#f' . $nsub; } else { $link = vpl_mod_href('forms/submissionview.php', 'id', $id, 'userid', $userid, 'submissionid', $submission->id); } $date = '<a href="' . $link . '">' . userdate($submission->datesubmitted) . '</a>';
$mform->setDefault('evaluateonsubmission', 1); $mform->disabledIf('evaluateonsubmission', 'evaluate', 'eq', 0); $mform->addElement('selectyesno', 'automaticgrading', get_string('automaticgrading', VPL)); $mform->setDefault('automaticgrading', 1); $mform->disabledIf('automaticgrading', 'evaluate', 'eq', 0); $mform->addElement('submit', 'saveoptions', get_string('saveoptions', VPL)); } } require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->prepare_page('forms/executionoptions.php', array('id' => $id)); vpl_include_jsfile('hideshow.js'); $vpl->require_capability(VPL_MANAGE_CAPABILITY); //Display page $vpl->print_header(get_string('execution', VPL)); $vpl->print_heading_with_help('executionoptions'); $vpl->print_configure_tabs(basename(__FILE__)); $course = $vpl->get_course(); $fgp = $vpl->get_execution_fgm(); $mform = new mod_vpl_executionoptions_form('executionoptions.php', $vpl); if ($fromform = $mform->get_data()) { if (isset($fromform->saveoptions)) { $instance = $vpl->get_instance(); \mod_vpl\event\vpl_execution_options_updated::log($vpl); $instance->basedon = $fromform->basedon; $instance->run = $fromform->run; $instance->debug = $fromform->debug; $instance->evaluate = $fromform->evaluate; $instance->evaluateonsubmission = $fromform->evaluate && $fromform->evaluateonsubmission; $instance->automaticgrading = $fromform->evaluate && $fromform->automaticgrading;
$grader = FALSE; if ($submissionid && $vpl->has_capability(VPL_GRADE_CAPABILITY)) { $subinstance = $DB->get_record('vpl_submissions', array('id' => $submissionid)); } else { $subinstance = $vpl->last_user_submission($userid); } $vpl->password_check(); } //Check consistence if (!$subinstance) { throw new Exception(get_string('nosubmission', VPL)); } if ($subinstance->vpl != $vpl->get_instance()->id) { throw new Exception(get_string('invalidcourseid')); } $submissionid = $subinstance->id; if ($vpl->is_inconsistent_user($subinstance->userid, $userid)) { throw new Exception('vpl submission user inconsistence'); } if ($vpl->get_instance()->id != $subinstance->vpl) { throw new Exception('vpl submission vpl inconsistence'); } $submission = new mod_vpl_submission($vpl, $subinstance); $fgm = $submission->get_submitted_fgm(); $fgm->download_files($vpl->get_printable_name()); } catch (Exception $e) { $vpl->prepare_page('views/downloadsubmission.php', array('id' => $id)); $vpl->print_header(get_string('download', VPL)); echo $OUTPUT->box($e->getMessage()); $vpl->print_footer(); }
// // You should have received a copy of the GNU General Public License // along with VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Show URL to web service with token * * @package mod_vpl * @copyright 2014 Juan Carlos Rodríguez-del-Pino * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos Rodríguez-del-Pino <*****@*****.**> */ require_once dirname(__FILE__) . '/../../../config.php'; require_once dirname(__FILE__) . '/../vpl.class.php'; require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->prepare_page('views/show_webservice.php', array('id' => $id)); $vpl->require_capability(VPL_VIEW_CAPABILITY); $log_url = vpl_rel_url('views/show_webservice.php', 'id', $id); if (!$vpl->is_visible()) { notice(get_string('notavailable')); } $vpl->print_header(get_string('createtokenforuser', 'core_webservice')); $vpl->print_view_tabs('view.php'); echo '<h1>' . get_string('webservice', 'core_webservice') . '</h1>'; echo '<h3>' . get_string('createtokenforuserdescription', 'core_webservice') . '</h3>'; $service_url = vpl_get_webservice_urlbase($vpl); echo $OUTPUT->box('<div style="white-space: pre-wrap">' . s($service_url) . '</div>'); \mod_vpl\event\vpl_webservice_token_viewed::log($vpl); notice('', vpl_mod_href('view.php', 'id', $id)); $vpl->print_footer();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos Rodríguez-del-Pino <*****@*****.**> */ require_once dirname(__FILE__) . '/../../../config.php'; require_once dirname(__FILE__) . '/../locallib.php'; require_once dirname(__FILE__) . '/../vpl.class.php'; require_once dirname(__FILE__) . '/../editor/editor_utility.php'; vpl_editor_util::generate_requires(); require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $instance = $vpl->get_instance(); $vpl->prepare_page('forms/requiredfiles.php', array('id' => $id)); $vpl->require_capability(VPL_MANAGE_CAPABILITY); $fgp = $vpl->get_required_fgm(); $vpl->print_header(get_string('requestedfiles', VPL)); $vpl->print_heading_with_help('requestedfiles'); $vpl->print_configure_tabs(basename(__FILE__)); //TODO download in zip file $options = array(); $options['restrictededitor'] = false; $options['save'] = true; $options['run'] = false; $options['debug'] = false; $options['evaluate'] = false; $options['ajaxurl'] = "requiredfiles.json.php?id={$id}&action="; $options['download'] = "../views/downloadrequiredfiles.php?id={$id}"; $options['resetfiles'] = false; $options['minfiles'] = 0; $options['maxfiles'] = $instance->maxfiles; //Get files
} if (!$userid || $userid == $USER->id) { //Make own submission $userid = $USER->id; if ($vpl->get_instance()->restrictededitor) { $vpl->require_capability(VPL_MANAGE_CAPABILITY); } $vpl->require_capability(VPL_SUBMIT_CAPABILITY); $vpl->network_check(); $vpl->password_check(); } else { //Make other user submission $vpl->require_capability(VPL_MANAGE_CAPABILITY); } $instance = $vpl->get_instance(); $vpl->print_header(get_string('submission', VPL)); $vpl->print_view_tabs(basename(__FILE__)); $mform = new mod_vpl_submission_form('submission.php', $vpl); if ($mform->is_cancelled()) { vpl_inmediate_redirect(vpl_mod_href('view.php', 'id', $id)); die; } if ($fromform = $mform->get_data()) { $raw_POST_size = strlen(file_get_contents("php://input")); if ($_SERVER['CONTENT_LENGTH'] != $raw_POST_size) { $error = "NOT SAVED (Http POST error: CONTENT_LENGTH expected " . $_SERVER['CONTENT_LENGTH'] . " found {$raw_POST_size})"; notice($error, vpl_mod_href('forms/submission.php', 'id', $id, 'userid', $userid), $vpl->get_course()); die; } $rfn = $vpl->get_required_fgm(); $minfiles = count($rfn->getFilelist());
for ($i = 0; $i < $nf; $i++) { $filename = $req_filelist[$i]; $filedata = $req_fgm->getFileData($req_filelist[$i]); $files[$filename] = $filedata; } if ($lastsub) { $submission = new mod_vpl_submission($vpl, $lastsub); $fgp = $submission->get_submitted_fgm(); $filelist = $fgp->getFileList(); $nf = count($filelist); for ($i = 0; $i < $nf; $i++) { $filename = $filelist[$i]; $filedata = $fgp->getFileData($filelist[$i]); $files[$filename] = $filedata; } $CE = $submission->get_CE_for_editor(); \mod_vpl\event\submission_edited::log($submission); } session_write_close(); if ($copy && $grader) { $userid = $USER->id; } $vpl->print_header(get_string('edit', VPL)); $vpl->print_view_tabs(basename(__FILE__)); echo $OUTPUT->box_start(); vpl_editor_util::print_tag($options, $files, $lastsub && !$copy); echo $OUTPUT->box_end(); if ($lastsub) { echo vpl_editor_util::send_CE($CE); } $vpl->print_footer();
$userid = optional_param('userid', FALSE, PARAM_INT); if ((!$userid || $userid == $USER->id) && $vpl->get_instance()->evaluate) { //Evaluate own submission $userid = $USER->id; $vpl->require_capability(VPL_SUBMIT_CAPABILITY); } else { //Evaluate other user submission $vpl->prepare_page('forms/evaluation.php', array('id' => $id, 'userid' => $userid)); $vpl->require_capability(VPL_GRADE_CAPABILITY); } if ($USER->id == $userid) { $vpl->network_check(); $vpl->password_check(); } //Display page $vpl->print_header(get_string('evaluation', VPL)); flush(); $course = $vpl->get_course(); $instance = $vpl->get_instance(); echo '<h2>' . s(get_string('evaluating', VPL)) . '</h2>'; $userinfo = $DB->get_record('user', array('id' => $userid)); $text = ' ' . $vpl->user_picture($userinfo); $text .= ' ' . fullname($userinfo); echo $OUTPUT->box($text); $ajaxurl = "edit.json.php?id={$id}&userid={$userid}&action="; if (optional_param('grading', 0, PARAM_INT)) { $inpopup = optional_param('inpopup', 0, PARAM_INT); $nexturl = "../forms/gradesubmission.php?id={$id}&userid={$userid}&inpopup={$inpopup}"; } else { $nexturl = "../forms/submissionview.php?id={$id}&userid={$userid}"; }
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Redirect grade.php * * @package mod_vpl * @copyright 2012 Juan Carlos Rodríguez-del-Pino * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos Rodríguez-del-Pino <*****@*****.**> */ require_once dirname(__FILE__) . '/../../config.php'; require_once dirname(__FILE__) . '/lib.php'; require_once dirname(__FILE__) . '/vpl.class.php'; require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->prepare_page('grade.php', array('id' => $id)); $vpl->print_header(); if ($vpl->has_capability(VPL_GRADE_CAPABILITY)) { $userid = optional_param('userid', false, PARAM_INT); if ($userid) { vpl_inmediate_redirect(vpl_mod_href('forms/gradesubmission.php', 'id', $id, 'userid', $userid)); } else { vpl_inmediate_redirect(vpl_mod_href('views/submissionslist.php', 'id', $id)); } } else { vpl_inmediate_redirect(vpl_mod_href('view.php', 'id', $id)); }
* @copyright 2012 Juan Carlos Rodríguez-del-Pino * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos Rodríguez-del-Pino <*****@*****.**> */ require_once dirname(__FILE__) . '/../../../config.php'; require_once dirname(__FILE__) . '/../vpl.class.php'; require_once dirname(__FILE__) . '/../jail/jailserver_manager.class.php'; require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->prepare_page('views/checkjailservers.php', array('id' => $id)); $vpl->require_capability(VPL_MANAGE_CAPABILITY); //Display page $PAGE->requires->css(new moodle_url('/mod/vpl/css/checkjailservers.css')); $course = $vpl->get_course(); $vpl->print_header(get_string('check_jail_servers', VPL)); $vpl->print_heading_with_help('check_jail_servers'); $vpl->print_configure_tabs(basename(__FILE__)); \mod_vpl\event\vpl_jail_servers_tested::log($vpl); $servers = vpl_jailserver_manager::check_servers($vpl->get_instance()->jailservers); $table = new html_table(); $table->head = array('#', get_string('server', VPL), get_string('currentstatus', VPL), get_string('lasterror', VPL), get_string('lasterrordate', VPL), get_string('totalnumberoferrors', VPL)); $table->align = array('right', 'left', 'left', 'left', 'left', 'right'); $table->data = array(); $num = 0; $clean_url = !$vpl->has_capability(VPL_SETJAILS_CAPABILITY) || !$vpl->has_capability(VPL_MANAGE_CAPABILITY); foreach ($servers as $server) { $serverurl = $server->server; if ($clean_url) { $serverurl = parse_url($serverurl, PHP_URL_HOST); }
require_once dirname(__FILE__) . '/similarity_base.class.php'; require_once dirname(__FILE__) . '/similarity_form.class.php'; require_once dirname(__FILE__) . '/clusters.class.php'; require_once dirname(__FILE__) . '/../views/status_box.class.php'; ini_set('memory_limit', '256M'); $id = required_param('id', PARAM_INT); $userid = required_param('userid', PARAM_INT); $time_limit = 600; // 10 minutes $vpl = new mod_vpl($id); $vpl->prepare_page('similarity/user_similarity.php', array('id' => $id, 'userid' => $userid)); $vpl->require_capability(VPL_SIMILARITY_CAPABILITY); \mod_vpl\event\vpl_user_similarity_report_viewed::log(array('objectid' => $vpl->get_instance()->id, 'context' => context_module::instance($id), 'relateduserid' => $userid)); //Print header $PAGE->requires->css(new moodle_url('/mod/vpl/css/similarity.css')); $vpl->print_header(get_string('listsimilarity', VPL)); $subinstance = $vpl->last_user_submission($userid); if ($subinstance === false) { //No user submission $vpl->print_footer(); die; } $submission = new mod_vpl_submission($vpl, $subinstance); //Get required filenames $filelist = $vpl->get_required_fgm()->getFileList(); foreach ($filelist as $filename) { $filesselected[$filename] = true; } //prepare table head $firstname = get_string('firstname'); $lastname = get_string('lastname');
$menssage = addslashes(get_string('delete')); $onclick = 'onclick="return confirm(\'' . $menssage . '\')"'; $buttongroup[] = $mform->createElement('submit', 'delete', get_string('delete'), $onclick); } $mform->addGroup($buttongroup); } } require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->prepare_page('forms/variations.php', array('id' => $id)); vpl_include_jsfile('hideshow.js'); $vplid = $vpl->get_instance()->id; $vpl->require_capability(VPL_MANAGE_CAPABILITY); $href = vpl_mod_href('forms/variations.php', 'id', $id); $vpl->print_header(get_string('variations', VPL)); $vpl->print_heading_with_help('variations'); //Generate default form and check for action if (optional_param('varid', -13, PARAM_INT) == -13) { //No variation saved $oform = new mod_vpl_variation_option_form($href, $vpl); if ($oform->is_cancelled()) { vpl_inmediate_redirect($href); //Reload page } elseif ($fromform = $oform->get_data()) { $fromform->id = $vplid; vpl_truncate_string($fromform->variationtitle, 255); \mod_vpl\event\vpl_variation_updated::log($vpl); $DB->update_record(VPL, $fromform); vpl_inmediate_redirect($href); }
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos Rodríguez-del-Pino <*****@*****.**> */ require_once dirname(__FILE__) . '/../../../config.php'; require_once dirname(__FILE__) . '/../locallib.php'; require_once dirname(__FILE__) . '/../vpl.class.php'; require_once dirname(__FILE__) . '/../editor/editor_utility.php'; vpl_editor_util::generate_requires(); require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $instance = $vpl->get_instance(); $vpl->prepare_page('forms/testcasesfile.php', array('id' => $id)); $vpl->require_capability(VPL_MANAGE_CAPABILITY); $fgp = $vpl->get_required_fgm(); $vpl->print_header(get_string('testcases', VPL)); $vpl->print_heading_with_help('testcases'); $vpl->print_configure_tabs(basename(__FILE__)); $options = array(); $options['restrictededitor'] = false; $options['save'] = true; $options['run'] = false; $options['debug'] = false; $options['evaluate'] = false; $options['ajaxurl'] = "testcasesfile.json.php?id={$id}&action="; $options['download'] = "../views/downloadexecutionfiles.php?id={$id}"; $options['resetfiles'] = false; $options['minfiles'] = 1; $options['maxfiles'] = 1; //Get files $fgp = $vpl->get_execution_fgm();
$mform =& $this->_form; $mform->addElement('header', 'headersetjails', get_string('local_jail_servers', VPL)); $mform->addElement('hidden', 'id', required_param('id', PARAM_INT)); $mform->setType('id', PARAM_INT); $mform->addElement('textarea', 'jailservers', get_string('jail_servers_description', VPL), array('cols' => 45, 'rows' => 10, 'wrap' => 'off')); $mform->setType('jailservers', PARAM_RAW); $this->add_action_buttons(); } } require_login(); $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->prepare_page('forms/local_jail_servers.php', array('id' => $id)); vpl_include_jsfile('hideshow.js'); $vpl->require_capability(VPL_SETJAILS_CAPABILITY); $vpl->print_header(get_string('local_jail_servers', VPL)); $vpl->print_heading_with_help('local_jail_servers'); $vpl->print_configure_tabs(basename(__FILE__)); $mform = new mod_vpl_setjails_form('local_jail_servers.php'); //Display page $course = $vpl->get_course(); if (!$mform->is_cancelled() && ($fromform = $mform->get_data())) { if (isset($fromform->jailservers)) { \mod_vpl\event\vpl_execution_localjails_updated::log($vpl); $instance = $vpl->get_instance(); $instance->jailservers = s($fromform->jailservers); if ($DB->update_record(VPL, $instance)) { vpl_notice(get_string('saved', VPL)); } else { vpl_error(get_string('notsaved', VPL)); }
} else { curl_close($ch); return json_decode($raw_response); } } function vpl_call_print($res) { echo '<pre>'; s(print_r($res, false)); echo '</pre>'; } $id = required_param('id', PARAM_INT); $vpl = new mod_vpl($id); $vpl->require_capability(VPL_MANAGE_CAPABILITY); $vpl->prepare_page('tests/webservice_client.php', array('id' => $id)); $vpl->print_header('Web service test client'); echo '<h1>Web service test client</h1>'; echo '<h3>Session token generated (or reused)</h3>'; echo s(vpl_get_webservice_token($vpl)); $service_url = vpl_get_webservice_urlbase($vpl); echo '<h3>Base URL for web service</h3>'; echo s($service_url); echo '<h3>Get info from activity</h3>'; $res = vpl_call_service($service_url, 'mod_vpl_info'); vpl_call_print($res); echo '<h3>Get last submission</h3>'; $res = vpl_call_service($service_url, 'mod_vpl_open'); vpl_call_print($res); echo '<h3>Modify and save last submission</h3>'; if (isset($res->files)) { $files = $res->files;