예제 #1
0
 static function initial_checks($id, $password)
 {
     $vpl = new mod_vpl($id);
     //No context validation (session is OK)
     //self::validate_context($vpl->get_context());
     if (!$vpl->pass_network_check()) {
         throw new Exception(get_string('opnotallowfromclient', VPL) . ' ' . getremoteaddr());
     }
     if (!$vpl->pass_password_check($password)) {
         throw new Exception(get_string('requiredpassword', VPL));
     }
     return $vpl;
 }
예제 #2
0
 function definition()
 {
     $mform =& $this->_form;
     $id = $this->vpl->get_course_module()->id;
     $mform->addElement('hidden', 'id', $id);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('header', 'header_execution_options', get_string('executionoptions', VPL));
     $strbasedon = get_string('basedon', VPL);
     $basedonlist = array();
     $basedonlist[0] = '';
     $courseid = $this->vpl->get_course()->id;
     $listcm = get_coursemodules_in_course(VPL, $courseid);
     $instance = $this->vpl->get_instance();
     $vplid = $instance->id;
     foreach ($listcm as $aux) {
         if ($aux->instance != $vplid) {
             $vpl = new mod_vpl($aux->id);
             $basedonlist[$aux->instance] = $vpl->get_printable_name();
         }
     }
     asort($basedonlist);
     $basedonlist[0] = get_string('select');
     $mform->addElement('select', 'basedon', $strbasedon, $basedonlist);
     $mform->setDefault('basedon', $instance->basedon);
     $mform->addElement('selectyesno', 'run', get_string('run', VPL));
     $mform->setDefault('run', 1);
     $mform->addElement('selectyesno', 'debug', get_string('debug', VPL));
     $mform->setDefault('debug', $instance->debug);
     $mform->addElement('selectyesno', 'evaluate', get_string('evaluate', VPL));
     $mform->setDefault('evaluate', 1);
     $mform->addElement('selectyesno', 'evaluateonsubmission', get_string('evaluateonsubmission', VPL));
     $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));
 }
 function list_activities($vplid)
 {
     global $DB;
     $list = array('' => '');
     $cn = $this->vpl->get_course()->shortname;
     //Low privilegies
     $courses = get_user_capability_course(VPL_VIEW_CAPABILITY, null, true, 'shortname');
     //Reorder courses by name similar to current
     usort($courses, function ($a, $b) use($cn) {
         $na = $a->shortname;
         $nb = $b->shortname;
         $da = levenshtein($na, $cn);
         $db = levenshtein($nb, $cn);
         if ($da != $db) {
             return $da < $db ? -1 : 1;
         }
         if ($na == $cn) {
             return -1;
         }
         if ($nb == $cn) {
             return 1;
         }
         if ($na != $nb) {
             return $na < $nb ? -1 : 1;
         }
         return 0;
     });
     foreach ($courses as $course) {
         $vpls = $DB->get_records(VPL, array('course' => $course->id));
         foreach ($vpls as $vplinstace) {
             if ($vplinstace->id == $vplid) {
                 continue;
             }
             $othervpl = new mod_vpl(false, $vplinstace->id);
             if (!$othervpl->get_course_module()) {
                 continue;
             }
             if ($othervpl->has_capability(VPL_SIMILARITY_CAPABILITY)) {
                 $list[$othervpl->get_course_module()->id] = $othervpl->get_course()->shortname . ' ' . $othervpl->get_printable_name();
             }
         }
         if (count($list) > 1000) {
             break;
             //Stop loading instances
         }
     }
     $list[''] = get_string('select');
     return $list;
 }
예제 #4
0
// along with VPL for Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @version        $Id: requiredfiles.php,v 1.2 2013-06-10 08:15:42 juanca Exp $
 * @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__) . '/../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=";
예제 #5
0
die;
require_once dirname(__FILE__) . '/../../../config.php';
require_once dirname(__FILE__) . '/../locallib.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission.class.php';
require_once dirname(__FILE__) . '/similarity_factory.class.php';
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();
예제 #6
0
define('AJAX_SCRIPT', true);
$outcome = new stdClass();
$outcome->success = true;
$outcome->response = new stdClass();
$outcome->error = '';
try {
    require_once dirname(__FILE__) . '/../../../config.php';
    require_once dirname(__FILE__) . '/edit.class.php';
    if (!isloggedin()) {
        throw new Exception(get_string('loggedinnot'));
    }
    $id = required_param('id', PARAM_INT);
    // course id
    $action = required_param('action', PARAM_ALPHANUMEXT);
    $userid = optional_param('userid', FALSE, PARAM_INT);
    $vpl = new mod_vpl($id);
    //TODO use or not sesskey
    //require_sesskey();
    require_login($vpl->get_course(), false);
    $PAGE->set_url(new moodle_url('/mod/vpl/forms/editor.json.php', array('id' => $id, 'action' => $action)));
    echo $OUTPUT->header();
    // Send headers.
    $raw_data = file_get_contents("php://input");
    $raw_data_size = strlen($raw_data);
    if ($_SERVER['CONTENT_LENGTH'] != $raw_data_size) {
        throw new Exception("Ajax POST error: CONTENT_LENGTH expected " . $_SERVER['CONTENT_LENGTH'] . " found {$raw_data_size})");
    }
    $data = json_decode($raw_data);
    if (!$vpl->is_submit_able()) {
        throw new Exception(get_string('notavailable'));
    }
 * List previous submissions for a vpl and user
 *
 * @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__) . '/../locallib.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission.class.php';
require_login();
$id = required_param('id', PARAM_INT);
$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();
예제 #8
0
//
// 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();
예제 #9
0
 *
 * @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__) . '/../similarity/watermark.php';
require_once dirname(__FILE__) . '/../../../config.php';
global $CFG, $USER;
require_once dirname(__FILE__) . '/../locallib.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission.class.php';
try {
    require_login();
    $id = required_param('id', PARAM_INT);
    $vpl = new mod_vpl($id);
    $userid = optional_param('userid', FALSE, PARAM_INT);
    $submissionid = optional_param('submissionid', FALSE, PARAM_INT);
    if (!$vpl->has_capability(VPL_GRADE_CAPABILITY)) {
        $userid = FALSE;
        $submissionid = FALSE;
    }
    //Read record
    if ($userid && $userid != $USER->id) {
        //Grader
        $vpl->require_capability(VPL_GRADE_CAPABILITY);
        $grader = TRUE;
        if ($submissionid) {
            $subinstance = $DB->get_record('vpl_submissions', array('id' => $submissionid));
        } else {
            $subinstance = $vpl->last_user_submission($userid);
예제 #10
0
    }
    if (isset($names[$ret])) {
        $names[$ret]++;
        $ret .= $names[$ret];
    } else {
        $names[$ret] = 0;
    }
    return $ret;
}
require_login();
$id = required_param('id', PARAM_INT);
$group = optional_param('group', -1, PARAM_INT);
//Undocumented feature, add &CE=1 to the query string
$includeCE = optional_param('CE', 0, PARAM_INT);
$subselection = vpl_get_set_session_var('subselection', 'allsubmissions', 'selection');
$vpl = new mod_vpl($id);
$cm = $vpl->get_course_module();
$vpl->require_capability(VPL_SIMILARITY_CAPABILITY);
\mod_vpl\event\vpl_all_submissions_downloaded::log($vpl);
//get students
$currentgroup = groups_get_activity_group($cm);
if (!$currentgroup) {
    $currentgroup = '';
}
$list = $vpl->get_students($currentgroup);
$submissions = $vpl->all_last_user_submission();
//Get all information
$all_data = array();
foreach ($list as $userinfo) {
    if ($vpl->is_group_activity() && $userinfo->id != $vpl->get_group_leaderid($userinfo->id)) {
        continue;
예제 #11
0
echo '<html>
<body>';
$subselection = vpl_get_set_session_var('subselection','allsubmissions','selection');
$options = array('height' => 550, 'width' => 780, 'directories' =>0, 'location' =>0, 'menubar'=>0,
    'personalbar'=>0,'status'=>0,'toolbar'=>0);
$group = optional_param('group', -1, PARAM_INT);
$sort = 'dategraded';
$sortdir = 'up';

//print_r($secname);

//$loggedinusers=get_loggedin_users_by_section($secname);
    $loggedinstudents=0;
//print_r($acivitystatus);

$vpl = new mod_vpl($id);
$vpl->prepare_page('views/submissionslist.php',array('id' => $id));

$course = $vpl->get_course();
$cm = $vpl->get_course_module();
$context_module = $vpl->get_context();

//get students
$currentgroup = groups_get_activity_group($cm, true);
if(!$currentgroup){
    $currentgroup='';
}
$list = $vpl->get_students($currentgroup);
   // var_dump (count($list));
$submissions = $vpl->all_last_user_submission();
$submissions_number = $vpl->get_submissions_number();
예제 #12
0
 function display()
 {
     $id = optional_param('update', FALSE, PARAM_INT);
     if ($id) {
         $vpl = new mod_vpl($id);
         $vpl->print_configure_tabs('edit');
         if ($vpl->get_grade_info() !== false) {
             $vpl->get_instance()->visiblegrade = $vpl->get_grade_info()->hidden ? 0 : 1;
         } else {
             $vpl->get_instance()->visiblegrade = false;
         }
         $this->set_data($vpl->get_instance());
     }
     parent::display();
 }
예제 #13
0
//
// 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/>.
/**
 * Check jail servers
 * @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__) . '/../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;
예제 #14
0
// 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));
}
예제 #15
0
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// VPL for Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// 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/>.
/**
 * Download required files in ZIP format
 * @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__) . '/../locallib.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_login();
$id = required_param('id', PARAM_INT);
$vpl = new mod_vpl($id);
$vpl->password_check();
$vpl->network_check();
if (!$vpl->is_visible()) {
    notice(get_string('notavailable'));
}
$filegroup = $vpl->get_required_fgm();
$filegroup->download_files($vpl->get_printable_name());
die;
예제 #16
0
    $num++;
}
$usernumber = 0;
$nwm = 0;
$simil = array();
//Preprocess current VPL instance
@set_time_limit($time_limit);
$activity_load_box = new vpl_progress_bar(s($vpl->get_printable_name()));
//debugging("Adding activity files", DEBUG_DEVELOPER);
vpl_similarity::scan_activity($simil, $vpl, $filesselected, $activity_load_box);
//debugging("Files to check ".count($simil), DEBUG_DEVELOPER);
$il = count($simil);
//Preprocess other VPL instance
if (isset($fromform->scanactivity) && $fromform->scanactivity > 0) {
    @set_time_limit($time_limit);
    $othervpl = new mod_vpl($fromform->scanactivity);
    $other_activity_load_box = new vpl_progress_bar(s($othervpl->get_printable_name()));
    //debugging("Adding other activity files", DEBUG_DEVELOPER);
    vpl_similarity::scan_activity($simil, $othervpl, $filesselected, $other_activity_load_box);
    //debugging("Files to check ".count($simil), DEBUG_DEVELOPER);
}
//Preprocess files in a ZIP file
$name = $form->get_new_filename('scanzipfile0');
$data = $form->get_file_content('scanzipfile0');
if ($data !== false && $name !== false) {
    @set_time_limit($time_limit);
    $zip_load_box0 = new vpl_progress_bar(s($name));
    //debugging("Adding files in zip file", DEBUG_DEVELOPER);
    vpl_similarity::scan_zip($simil, $name, $data, $vpl, $filesselected, $zip_load_box0);
    //debugging("Files to check ".count($simil), DEBUG_DEVELOPER);
}
예제 #17
0
 */
require_once dirname(__FILE__) . '/../../config.php';
require_once dirname(__FILE__) . '/locallib.php';
require_once dirname(__FILE__) . '/vpl.class.php';
global $CFG, $PGAE;
/******************* BY ANUSHA ************************
FOR HIDING LEFT SIDE NAVIGATION *********************/
$context = context_course::instance($COURSE->id);
if (user_has_role_assignment($USER->id, 5)) {
    $PAGE->requires->css('/student/custom.css');
}
require_login();
$id = optional_param('id', null, PARAM_INT);
// Course Module ID, or
//$a  = optional_param('a', null, PARAM_INT);  // vpl ID
$vpl = new mod_vpl($id);
$vpl->prepare_page('view.php', array('id' => $id));
$vpl->require_capability(VPL_VIEW_CAPABILITY);
$id = $vpl->get_course_module()->id;
$log_url = vpl_rel_url('view.php', 'id', $id);
if (!$vpl->is_visible()) {
    notice(get_string('notavailable'));
}
if (!$vpl->has_capability(VPL_MANAGE_CAPABILITY) && !$vpl->has_capability(VPL_GRADE_CAPABILITY)) {
    $vpl->network_check();
    $vpl->password_check();
    $userid = $USER->id;
} else {
    $userid = optional_param('userid', $USER->id, PARAM_INT);
}
\mod_vpl\event\vpl_description_viewed::log($vpl);
예제 #18
0
 * @package mod_vpl. View a submission
 * @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';
global $CFG, $USER;
require_once dirname(__FILE__) . '/../locallib.php';
require_once dirname(__FILE__) . '/grade_form.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission.class.php';
try {
    require_login();
    $id = required_param('id', PARAM_INT);
    $userid = optional_param('userid', FALSE, PARAM_INT);
    $vpl = new mod_vpl($id);
    if ($userid) {
        $vpl->prepare_page('forms/submissionview.php', array('id' => $id, 'userid' => $userid));
    } else {
        $vpl->prepare_page('forms/submissionview.php', array('id' => $id));
    }
    if (!$vpl->is_visible()) {
        notice(get_string('notavailable'));
    }
    $course = $vpl->get_course();
    $instance = $vpl->get_instance();
    $submissionid = optional_param('submissionid', FALSE, PARAM_INT);
    //Read records
    if ($userid && $userid != $USER->id) {
        //Grader
        $vpl->require_capability(VPL_GRADE_CAPABILITY);
예제 #19
0
/**
 * @version        $Id: submission.php,v 1.34 2013-06-10 08:15:42 juanca Exp $
 * @package mod_vpl. Process submission form
 * @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__) . '/../locallib.php';
require_once dirname(__FILE__) . '/submission_form.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission.class.php';
require_login();
$id = required_param('id', PARAM_INT);
$userid = optional_param('userid', FALSE, PARAM_INT);
$vpl = new mod_vpl($id);
if ($userid) {
    $vpl->prepare_page('forms/submission.php', array('id' => $id, 'userid' => $userid));
} else {
    $vpl->prepare_page('forms/submission.php', array('id' => $id));
}
if (!$vpl->is_submit_able()) {
    notice(get_string('notavailable'));
}
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);
예제 #20
0
                            case "complete":
                                $user_complete = $mod->modname."_user_complete";
                                $image = $OUTPUT->pix_icon('icon', $mod->modfullname, 'mod_'.$mod->modname, array('class'=>'icon'));
                                echo "<h4>$image $mod->modfullname: ".format_string($instance->name,true).
                                     "</h4>";

                               // echo '<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
                            //format_string($instance->name,true)."</a>';

                                ob_start();

                                echo "<ul>";
                                if (function_exists($user_complete)) {
                                    //$user_complete($course, $user, $mod, $instance);
                                    if($mod->modname=='vpl'){
                                        $vpl = new mod_vpl(null,$instance->id);
                                        $sub = $vpl->last_user_submission($user->id);
                                        if(!$sub) {
                                            $return = null;
                                        }
                                        else{
                                            $submission = new mod_vpl_submission($vpl,$sub);
                                            $submission->student_print_info(true);
                                            $submission->print_grade(true);
                                        }
                                    }
                                    else{
                                        $user_complete($course, $user, $mod, $instance);
                                    }
                                } else {
                                    //echo 'modname='.$mod->modname;
예제 #21
0
        $mform->addElement('select', 'maxexefilesize', get_string('maxexefilesize', VPL), vpl_get_select_sizes(1024 * 256, (int) $plugincfg->maxexefilesize));
        $mform->setType('maxexefilesize', PARAM_INT);
        if ($instance->maxexefilesize) {
            $mform->setDefault('maxexefilesize', $instance->maxexefilesize);
        }
        $mform->addElement('text', 'maxexeprocesses', get_string('maxexeprocesses', VPL));
        $mform->setType('maxexeprocesses', PARAM_INT);
        if ($instance->maxexeprocesses) {
            $mform->setDefault('maxexeprocesses', $instance->maxexeprocesses);
        }
        $mform->addElement('submit', 'savelimitoptions', get_string('saveoptions', VPL));
    }
}
require_login();
$id = required_param('id', PARAM_INT);
$vpl = new mod_vpl($id);
$vpl->prepare_page('forms/executionlimits.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('resourcelimits');
$vpl->print_configure_tabs(basename(__FILE__));
$course = $vpl->get_course();
$fgp = $vpl->get_execution_fgm();
$mform = new mod_vpl_executionlimits_form('executionlimits.php', $vpl);
if ($fromform = $mform->get_data()) {
    if (isset($fromform->savelimitoptions)) {
        $instance = $vpl->get_instance();
        \mod_vpl\event\vpl_execution_limits_updated::log($vpl);
        $instance->maxexetime = $fromform->maxexetime;
예제 #22
0
    if ($inpopup) {
        $vpl->print_header_simple();
    } else {
        $vpl->print_header(get_string('grade'));
        $vpl->print_view_tabs(basename(__FILE__));
    }
}
require_login();
vpl_include_jsfile('grade.js', false);
vpl_include_jsfile('hide_footer.js', false);
vpl_include_jsfile('updatesublist.js', false);
$PAGE->requires->css(new moodle_url('/mod/vpl/css/sh.css'));
$PAGE->requires->css(new moodle_url('/mod/vpl/editor/VPLIDE.css'));
$id = required_param('id', PARAM_INT);
$userid = required_param('userid', PARAM_INT);
$vpl = new mod_vpl($id);
$vpl->prepare_page('forms/gradesubmission.php', array('id' => $id, 'userid' => $userid));
$jscript = '';
$inpopup = optional_param('inpopup', 0, PARAM_INT);
$vpl->require_capability(VPL_GRADE_CAPABILITY);
//Read records
$submissionid = optional_param('submissionid', FALSE, PARAM_INT);
if ($submissionid) {
    $subinstance = $DB->get_record('vpl_submissions', array('id' => $submissionid));
} else {
    $subinstance = $vpl->last_user_submission($userid);
}
//Check consistence
if (!$subinstance) {
    vpl_grade_header($vpl, $inpopup);
    notice(get_string('nosubmission', VPL), vpl_mod_href('view.php', 'id', $id, 'userid', $userid));
예제 #23
0
파일: lib.php 프로젝트: go38/moodle-mod_vpl
/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all posts from the specified vpl instance
 * and clean up any related data.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function vpl_reset_userdata($data)
{
    global $CFG, $DB;
    $status = array();
    if ($data->reset_vpl_submissions) {
        $componentstr = get_string('modulenameplural', VPL);
        if ($cms = get_coursemodules_in_course(VPL, $data->courseid)) {
            foreach ($cms as $cmid => $cm) {
                //For each vpl instance in course
                $vpl = new mod_vpl($cmid);
                $instance = $vpl->get_instance();
                //Delete submissions records
                $DB->delete_records(VPL_SUBMISSIONS, array('vpl' => $instance->id));
                //Delete variations assigned
                $DB->delete_records(VPL_ASSIGNED_VARIATIONS, array('vpl' => $instance->id));
                //Delete submission files
                fulldelete($CFG->dataroot . '/vpl_data/' . $data->courseid . '/' . $instance->id . '/usersdata');
                $status[] = array('component' => $componentstr, 'item' => get_string('resetvpl', VPL, $instance->name), 'error' => false);
            }
        }
    }
    return $status;
}
예제 #24
0
 /**
  * return an array with variations for this user
  **/
 function get_variation_identification($userid = 0, &$already = array())
 {
     if (!$this->instance->usevariations || isset($already[$this->instance->id])) {
         //Avoid infinite recursion
         return array();
     }
     $already[$this->instance->id] = true;
     if ($this->instance->basedon) {
         $basevpl = new mod_vpl(false, $this->instance->basedon);
         $ret = $basevpl->get_variation_identification($userid, $already);
     } else {
         $ret = array();
     }
     $variation = $this->get_variation($userid);
     if ($variation !== false) {
         $ret[] = $variation->identification;
     }
     return $ret;
 }
예제 #25
0
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// 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/>.
/**
 * Show a graph that represent for an antivity the time dedicated by student
 *
 * @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__) . '/../locallib.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/activityworkinggraph.php', array('id' => $id));
$course = $vpl->get_course();
$instance = $vpl->get_instance();
$vpl->require_capability(VPL_GRADE_CAPABILITY);
//Print header
$vpl->print_header_simple();
echo '<div class="clearer"> </div>';
echo '<div style="text-align: center">';
echo '<img src="' . vpl_rel_url('workinggraph.php', 'id', $id, 'userid', -1) . '" alt="Working periods" />';
echo '</div>';
$vpl->print_footer_simple();
예제 #26
0
 static function vpl_get_similfile($f, $vpl, &$HTMLheader, &$filename, &$data)
 {
     global $DB;
     $HTMLheader = '';
     $filename = '';
     $data = '';
     $type = required_param('type' . $f, PARAM_INT);
     if ($type == 1) {
         $subid = required_param('subid' . $f, PARAM_INT);
         $filename = required_param('filename' . $f, PARAM_TEXT);
         $subinstance = $DB->get_record('vpl_submissions', array('id' => $subid));
         if ($subinstance !== false) {
             $vpl = new mod_vpl(false, $subinstance->vpl);
             $vpl->require_capability(VPL_SIMILARITY_CAPABILITY);
             $submission = new mod_vpl_submission($vpl, $subinstance);
             $user = $DB->get_record('user', array('id' => $subinstance->userid));
             if ($user) {
                 $HTMLheader .= '<a href="' . vpl_mod_href('/forms/submissionview.php', 'id', $vpl->get_course_module()->id, 'userid', $subinstance->userid) . '">';
             }
             $HTMLheader .= s($filename) . ' ';
             if ($user) {
                 $HTMLheader .= '</a>';
                 $HTMLheader .= $vpl->user_fullname_picture($user);
             }
             $fg = $submission->get_submitted_fgm();
             $data = $fg->getFileData($filename);
             \mod_vpl\event\vpl_diff_viewed::log($submission);
         }
     } elseif ($type == 2) {
         //FIXME adapt to moodle 2.x
         /*
         global $CFG;
         $dirname = required_param('dirname'.$f,PARAM_RAW);
         $filename = required_param('filename'.$f,PARAM_RAW);
         $base=$CFG->dataroot.'/'.$vpl->get_course()->id.'/';
         $data = file_get_contents($base.$dirname.'/'.$filename);
         $HTMLheader .= $filename.' '.optional_param('username'.$f,'',PARAM_TEXT);
         */
     } elseif ($type == 3) {
         global $CFG;
         $data = '';
         $zipname = required_param('zipfile' . $f, PARAM_RAW);
         $filename = required_param('filename' . $f, PARAM_RAW);
         $HTMLheader .= $filename . ' ' . optional_param('username' . $f, '', PARAM_TEXT);
         $ext = strtoupper(pathinfo($zipfile, PATHINFO_EXTENSION));
         if ($ext != 'ZIP') {
             print_error('nozipfile');
         }
         $zip = new ZipArchive();
         $zipfilename = self::get_zip_filepath($zipname);
         if ($zip->open($zipfilename)) {
             $data = $zip->getFromName($filename);
             $zip->close();
         }
     } else {
         print_error('type error');
     }
 }
예제 #27
0
// VPL for Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// VPL for Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// 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/>.
/**
 * Execute post-uninstall custom actions for VPL
 *
 * @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 <*****@*****.**>
 */
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/mod/vpl/vpl.class.php';
$ret = true;
$vpls = $DB->get_records('vpl', null, '', 'id');
foreach ($vpls as $vplinstance) {
    $vpl = new mod_vpl(null, $vplinstance->id);
    $ret = $ret && $vpl->delete_all();
}
if (!$ret) {
    print_error('error deleting VPL');
}
예제 #28
0
define('AJAX_SCRIPT', true);
$outcome = new stdClass();
$outcome->success = true;
$outcome->response = new stdClass();
$outcome->error = '';
try {
    require_once dirname(__FILE__) . '/../../../config.php';
    require_once dirname(__FILE__) . '/../locallib.php';
    require_once dirname(__FILE__) . '/../vpl.class.php';
    if (!isloggedin()) {
        throw new Exception(get_string('loggedinnot'));
    }
    $id = required_param('id', PARAM_INT);
    // course id
    $action = required_param('action', PARAM_ALPHANUMEXT);
    $vpl = new mod_vpl($id);
    //TODO use or not sesskey
    //require_sesskey();
    require_login($vpl->get_course(), false);
    $vpl->require_capability(VPL_MANAGE_CAPABILITY);
    $PAGE->set_url(new moodle_url('/mod/vpl/forms/requiredfiles.json.php', array('id' => $id, 'action' => $action)));
    echo $OUTPUT->header();
    // Send headers.
    $data = json_decode(file_get_contents('php://input'));
    switch ($action) {
        case 'save':
            $postfiles = (array) $data;
            foreach ($postfiles as $name => $data) {
                $files[] = array('name' => $name, 'data' => $data);
            }
            $req_fgm = $vpl->get_required_fgm();
예제 #29
0
 */
global $CFG;
require_once dirname(__FILE__) . '/../../../config.php';
require_once dirname(__FILE__) . '/../locallib.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission.class.php';
require_once dirname(__FILE__) . '/../editor/editor_utility.php';
header("Pragma: no-cache");
//Browser must reload page
vpl_editor_util::generate_requires();
require_login();
$id = required_param('id', PARAM_INT);
$userid = optional_param('userid', FALSE, PARAM_INT);
$copy = optional_param('privatecopy', false, PARAM_INT);
$subid = optional_param('submissionid', false, PARAM_INT);
$vpl = new mod_vpl($id);
$page_parms = array('id' => $id);
if ($userid && !$copy) {
    $page_parms['userid'] = $userid;
}
if ($copy) {
    $page_parms['privatecopy'] = 1;
}
$vpl->prepare_page('forms/edit.php', $page_parms);
if (!$vpl->is_visible()) {
    notice(get_string('notavailable'));
}
if (!$vpl->is_submit_able()) {
    print_error('notavailable');
}
if (!$userid || $userid == $USER->id) {
예제 #30
0
/**
 * Atomatic evaluation from link
 * @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__) . '/../locallib.php';
require_once dirname(__FILE__) . '/../vpl.class.php';
require_once dirname(__FILE__) . '/../vpl_submission_CE.class.php';
require_once dirname(__FILE__) . '/../editor/editor_utility.php';
require_login();
vpl_editor_util::generate_requires_evaluation();
$id = required_param('id', PARAM_INT);
$vpl = new mod_vpl($id);
$vpl->prepare_page('forms/evaluation.php', array('id' => $id));
$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();
}