break; case 'debug': if (!$instance->debug and !$vpl->has_capability(VPL_GRADE_CAPABILITY)) { throw new Exception(get_string('notavailable')); } $outcome->response = mod_vpl_edit::execute($vpl, $userid, $action); break; case 'evaluate': if (!$instance->evaluate and !$vpl->has_capability(VPL_GRADE_CAPABILITY)) { throw new Exception(get_string('notavailable')); } $outcome->response = mod_vpl_edit::execute($vpl, $userid, $action); break; case 'retrieve': $outcome->response = mod_vpl_edit::retrieve_result($vpl, $userid); break; case 'cancel': $outcome->response = mod_vpl_edit::cancel($vpl, $userid); break; case 'getjails': $outcome->response->servers = vpl_jailserver_manager::get_https_server_list($vpl->get_instance()->jailservers); break; default: throw new Exception('ajax action error'); } } catch (Exception $e) { $outcome->success = false; $outcome->error = $e->getMessage(); } echo json_encode($outcome); die;
public static function get_result($id, $password) { global $USER; //Parameters validation $params = self::validate_parameters(self::get_result_parameters(), array('id' => $id, 'password' => $password)); $vpl = self::initial_checks($id, $password); $vpl->require_capability(VPL_SUBMIT_CAPABILITY); $instance = $vpl->get_instance(); if (!$vpl->is_submit_able()) { throw new Exception(get_string('notavailable')); } if ($instance->example or $instance->restrictededitor or !$instance->evaluate) { throw new Exception(get_string('notavailable')); } $CE = mod_vpl_edit::retrieve_result($vpl, $USER->id); return array('compilation' => $CE->compilation, 'evaluation' => $CE->evaluation, 'grade' => $CE->grade); }