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; }
/** * Run periodically to check for vpl visibility update * * @uses $CFG * @return boolean **/ function vpl_cron() { global $DB; $rebuilds = array(); $now = time(); $sql = 'SELECT id, startdate, duedate, course, name FROM {vpl} WHERE startdate > ? and startdate <= ? and (duedate > ? or duedate = 0)'; $parms = array($now - 2 * 3600, $now, $now); $vpls = $DB->get_records_sql($sql, $parms); foreach ($vpls as $instance) { if (!instance_is_visible(VPL, $instance)) { $vpl = new mod_vpl(null, $instance->id); echo 'Setting visible "' . s($vpl->get_printable_name()) . '"'; $cm = $vpl->get_course_module(); $rebuilds[$cm->id] = $cm; } } foreach ($rebuilds as $cmid => $cm) { set_coursemodule_visible($cm->id, true); rebuild_course_cache($cm->course); } return true; }
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; }
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'); } }
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); // Print the page header $PAGE->requires->css(new moodle_url('/mod/vpl/css/sh.css')); $vpl->print_header(get_string('description', VPL));
if ($grader && !$no_grade) { $table->head[] = get_string('submissions', VPL); $table->head[] = get_string('graded', VPL); $table->align[] = 'right'; $table->align[] = 'right'; } if ($student && !$no_grade) { $table->head[] = get_string('grade'); $table->align[] = 'left'; } $table->data = array(); $totalsubs = 0; $totalgraded = 0; foreach ($vpls as $vpl) { $instance = $vpl->get_instance(); $url = vpl_rel_url('view.php', 'id', $vpl->get_course_module()->id); $row = array(count($table->data) + 1, "<a href='{$url}'>{$vpl->get_printable_name()}</a>", s($instance->shortdescription)); if ($startdate) { $row[] = $instance->startdate > 0 ? userdate($instance->startdate) : ''; } if ($duedate) { $row[] = $instance->duedate > 0 ? userdate($instance->duedate) : ''; } if ($grader) { if ($vpl->has_capability(VPL_GRADE_CAPABILITY) && $vpl->get_grade() != 0 && !$instance->example) { $info = vpl_list_util::count_graded($vpl); $totalsubs += $info['submissions']; $totalgraded += $info['graded']; $url = vpl_rel_url('views/submissionslist.php', 'id', $vpl->get_course_module()->id, 'selection', 'allsubmissions'); $row[] = '<a href="' . $url . '">' . $info['submissions'] . '</a>'; //Need mark?