Example #1
0
 public static function info($id, $password)
 {
     //Parameters validation
     $params = self::validate_parameters(self::info_parameters(), array('id' => $id, 'password' => $password));
     $vpl = self::initial_checks($id, $password);
     $vpl->require_capability(VPL_VIEW_CAPABILITY);
     if (!$vpl->is_visible()) {
         throw new Exception(get_string('notavailable'));
     }
     $instance = $vpl->get_instance();
     $ret = array('name' => $instance->name, 'shortdescription' => $instance->shortdescription, 'intro' => $instance->intro, 'introformat' => (int) $instance->introformat, 'reqpassword' => $instance->password > '' ? 1 : 0, 'example' => (int) $instance->example, 'restrictededitor' => (int) $instance->restrictededitor, 'maxfiles' => (int) $instance->maxfiles, 'reqfiles' => array());
     $files = mod_vpl_edit::get_requested_files($vpl);
     //Adapt array[name]=content to array[]=array(name,data)
     $files = mod_vpl_edit::files2object($files);
     $ret['reqfiles'] = $files;
     return $ret;
 }
Example #2
0
 } else {
     // Make other user submission
     $vpl->require_capability(VPL_MANAGE_CAPABILITY);
 }
 $instance = $vpl->get_instance();
 switch ($action) {
     case 'save':
         $postfiles = (array) $data;
         $files = array();
         foreach ($postfiles as $name => $data) {
             $files[] = array('name' => $name, 'data' => $data);
         }
         mod_vpl_edit::save($vpl, $userid, $files);
         break;
     case 'resetfiles':
         $outcome->response->files = mod_vpl_edit::get_requested_files($vpl);
         break;
     case 'run':
         if (!$instance->run and !$vpl->has_capability(VPL_GRADE_CAPABILITY)) {
             throw new Exception(get_string('notavailable'));
         }
         $outcome->response = mod_vpl_edit::execute($vpl, $userid, $action);
         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)) {