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; }
function vpl_extend_navigation(navigation_node $vplnode, $course, $module, $cm) { global $CFG, $USER, $DB; //FIXME //Student //Descripción //Entrega //Edición //Ver entrega //En grupos visibles lista de entregas //Profesor //Descripción //Lista de entregas //Similaridad //Si se esta accediendo a la información de un alumno //Entrega //Editar //Ver entrega //Calificar //Lista de entregas previas $vpl = new mod_vpl($cm->id); $viewer = $vpl->has_capability(VPL_VIEW_CAPABILITY); $submiter = $vpl->has_capability(VPL_SUBMIT_CAPABILITY); $similarity = $vpl->has_capability(VPL_SIMILARITY_CAPABILITY); $grader = $vpl->has_capability(VPL_GRADE_CAPABILITY); $manager = $vpl->has_capability(VPL_MANAGE_CAPABILITY); $userid = optional_param('userid', false, PARAM_INT); if (!$userid && $USER->id != $userid) { $parm = array('id' => $cm->id, 'userid' => $userid); } else { $userid = $USER->id; $parm = array('id' => $cm->id); } $strdescription = get_string('description', VPL); $strsubmission = get_string('submission', VPL); $stredit = get_string('edit', VPL); $strsubmissionview = get_string('submissionview', VPL); $urlforms = '/mod/' . VPL . '/forms/'; $urlviews = '/mod/' . VPL . '/views/'; if ($viewer) { $vplnode->add($strdescription, new moodle_url('/mod/vpl/view.php', $parm), navigation_node::TYPE_SETTING); } $example = $vpl->get_instance()->example; $submit_able = $manager || $grader && $USER->id != $userid || !$grader && $submiter && $vpl->is_submit_able(); if ($submit_able && !$example && !$vpl->get_instance()->restrictededitor) { $vplnode->add($strsubmission, new moodle_url('/mod/vpl/forms/submission.php', $parm), navigation_node::TYPE_SETTING); } if ($submit_able) { $vplnode->add($stredit, new moodle_url('/mod/vpl/forms/edit.php', $parm), navigation_node::TYPE_SETTING); } if (!$example) { if ($grader && $USER->id != $userid) { $text = get_string('grade'); $vplnode->add($text, new moodle_url('/mod/vpl/forms/gradesubmission.php', $parm), navigation_node::TYPE_SETTING); } $vplnode->add($strsubmissionview, new moodle_url('/mod/vpl/forms/submissionview.php', $parm), navigation_node::TYPE_SETTING); if ($grader || $similarity) { $strlistprevoiussubmissions = get_string('previoussubmissionslist', VPL); $vplnode->add($strlistprevoiussubmissions, new moodle_url('/mod/vpl/views/previoussubmissionslist.php', $parm), navigation_node::TYPE_SETTING); } if ($grader || $manager) { $strsubmissionslist = get_string('submissionslist', VPL); $vplnode->add($strsubmissionslist, new moodle_url('/mod/vpl/views/submissionslist.php', $parm), navigation_node::TYPE_SETTING); } if ($similarity) { $strssimilarity = get_string('similarity', VPL); $vplnode->add($strssimilarity, new moodle_url('/mod/vpl/similarity/similarity_form.php', $parm), navigation_node::TYPE_SETTING); } } }
* @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); } } else { //Download own submission
//Read records 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); } } else { //view own submission $vpl->require_capability(VPL_VIEW_CAPABILITY); $userid = $USER->id; $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); } } if ($subinstance != null && $subinstance->vpl != $vpl->get_instance()->id) { print_error('invalidcourseid'); } if ($USER->id == $userid) { $vpl->network_check(); $vpl->password_check(); } //Print header $PAGE->requires->css(new moodle_url('/mod/vpl/css/sh.css')); $PAGE->requires->css(new moodle_url('/mod/vpl/editor/VPLIDE.css'));
} if (!$vpl->is_submit_able()) { print_error('notavailable'); } if (!$userid || $userid == $USER->id) { //Edit own submission $userid = $USER->id; $vpl->require_capability(VPL_SUBMIT_CAPABILITY); } else { //Edit other user submission $vpl->require_capability(VPL_MANAGE_CAPABILITY); } $vpl->network_check(); $vpl->password_check(); $instance = $vpl->get_instance(); $manager = $vpl->has_capability(VPL_MANAGE_CAPABILITY); $grader = $vpl->has_capability(VPL_GRADE_CAPABILITY); //This code allow to edit previous versions (only managers) if ($subid && $vpl->has_capability(VPL_MANAGE_CAPABILITY)) { $parms = array('id' => $subid, 'vpl' => $instance->id, 'userid' => $userid); $res = $DB->get_records('vpl_submissions', $parms); if (count($res) == 1) { $lastsub = $res[$subid]; } else { $lastsub = false; } } else { $lastsub = $vpl->last_user_submission($userid); } $options = array(); $options['id'] = $id;
// 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)); }
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); // Print the page header $PAGE->requires->css(new moodle_url('/mod/vpl/css/sh.css')); $vpl->print_header(get_string('description', VPL)); /// Print the main part of the page $vpl->print_view_tabs(basename(__FILE__)); $vpl->print_name(); echo $OUTPUT->box_start(); $vpl->print_submission_period();
case 'examples': if ($instance->example) { $vpls[] = $vpl; } break; } } } //Is the user a grader? $grader = false; $student = false; $startdate = false; $duedate = false; $no_grade = true; foreach ($vpls as $vpl) { if ($vpl->has_capability(VPL_GRADE_CAPABILITY)) { $grader = true; } elseif ($vpl->has_capability(VPL_SUBMIT_CAPABILITY)) { $student = true; } $instance = $vpl->get_instance(); if ($vpl->get_grade() != 0 && !$instance->example) { $no_grade = false; } if ($instance->startdate > 0) { $startdate = true; } if ($instance->duedate > 0) { $duedate = true; } }