function action_default() { // Get parameters $sort = optional_param('sort', 'name', PARAM_ALPHA); $dir = optional_param('dir', 'ASC', PARAM_ALPHA); $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 30, PARAM_INT); // how many per page $namesearch = trim(optional_param('search', '', PARAM_TEXT)); $alpha = optional_param('alpha', '', PARAM_ALPHA); // Define columns $columns = array('name' => get_string('environment_name', 'block_curr_admin'), 'description' => get_string('environment_description', 'block_curr_admin')); $items = environment_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $numitems = environment_count_records($namesearch, $alpha); $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true); }
function definition() { global $USER, $CFG, $COURSE, $CURMAN; $mform =& $this->_form; $mform->addElement('header', 'crsdftdefault', get_string('defaultcrs', 'block_curr_admin')); $mform->addElement('text', 'crsdftname', get_string('course_name', 'block_curr_admin') . ':'); $mform->setType('crsdftname', PARAM_TEXT); $mform->addElement('text', 'crsdftcode', get_string('course_code', 'block_curr_admin') . ':'); $mform->setType('crsdftcode', PARAM_TEXT); $mform->addElement('text', 'crsdftidnumber', get_string('course_idnumber', 'block_curr_admin') . ':'); $mform->setType('crsdftidnumber', PARAM_TEXT); $attributes = array('cols' => 40, 'rows' => 2); $mform->addElement('textarea', 'crsdftsyllabus', get_string('course_syllabus', 'block_curr_admin') . ':', $attributes); $mform->setType('crsdftsyllabus', PARAM_CLEAN); $mform->addElement('text', 'crsdftlengthdescription', get_string('length_description', 'block_curr_admin')); $mform->setType('crsdftlengthdescription', PARAM_TEXT); $mform->addRule('crsdftlengthdescription', null, 'maxlength', 100); $mform->addElement('text', 'crsdftlength', get_string('duration', 'block_curr_admin') . ':'); $mform->setType('crsdftlength', PARAM_INT); $mform->addElement('text', 'crsdftcredits', get_string('credits', 'block_curr_admin') . ':'); $mform->setType('crsdftcredits', PARAM_NUMBER); $mform->addRule('crsdftcredits', null, 'maxlength', 10); $grades = range(0, 100, 1); $mform->addElement('select', 'crsdftcompletion_grade', get_string('completion_grade', 'block_curr_admin') . ':', $grades); $environments = array('- ' . get_string('none', 'block_curr_admin') . ' -'); $envs = environment_get_listing(); if (empty($envs)) { $envs = array(); } foreach ($envs as $e) { $environments[$e->id] = $e->name; } $mform->addElement('select', 'crsdftenvironmentid', get_string('environment', 'block_curr_admin'), $environments); $mform->addElement('text', 'crsdftcost', get_string('cost', 'block_curr_admin') . ':'); $mform->setType('crsdftcost', PARAM_TEXT); $mform->addRule('crsdftcost', null, 'maxlength', 10); $mform->addElement('text', 'crsdftversion', get_string('course_version', 'block_curr_admin') . ':'); $mform->setType('crsdftversion', PARAM_TEXT); $mform->addRule('crsdftversion', null, 'maxlength', 100); $this->add_action_buttons(); }
function definition() { global $USER, $CFG, $COURSE, $CURMAN; $mform =& $this->_form; $mform->addElement('header', 'clsdefault', get_string('defaultcls', 'block_curr_admin')); $mform->addElement('text', 'clsdftidnumber', get_string('class_idnumber', 'block_curr_admin') . ':'); $mform->setType('idnumber', PARAM_TEXT); $mform->addElement('date_selector', 'clsdftstartdate', get_string('class_startdate', 'block_curr_admin') . ':', array('optional' => true)); $mform->addElement('date_selector', 'clsdftenddate', get_string('class_enddate', 'block_curr_admin') . ':', array('optional' => true)); $mform->addElement('time_selector', 'clsdftstarttime', get_string('class_starttime', 'block_curr_admin') . ':', array('display_12h' => $CURMAN->config->time_format_12h)); $mform->addElement('time_selector', 'clsdftendtime', get_string('class_endtime', 'block_curr_admin') . ':', array('display_12h' => $CURMAN->config->time_format_12h)); $mform->addElement('text', 'clsdftmaxstudents', get_string('class_maxstudents', 'block_curr_admin') . ':'); $mform->setType('maxstudents', PARAM_INT); // Environment selector $envs = environment_get_listing(); $envs = $envs ? $envs : array(); $o_envs = array(get_string('none', 'block_curr_admin')); foreach ($envs as $env) { $o_envs[$env->id] = $env->name; } $mform->addElement('select', 'clsdftenvironmentid', get_string('environment', 'block_curr_admin') . ':', $o_envs); $this->add_action_buttons(); }
function definition() { global $USER, $CFG, $COURSE, $CURMAN; parent::definition(); if (!empty($this->_customdata['obj'])) { $obj = $this->_customdata['obj']; if (empty($obj->startdate) || $obj->startdate == 0) { $this->set_data(array('disablestart' => '1')); } if (empty($obj->enddate) || $obj->enddate == 0) { $this->set_data(array('disableend' => '1')); } if (isset($obj->starttimeminute) && isset($obj->starttimehour)) { $this->set_data(array('starttime' => array('minute' => $obj->starttimeminute, 'hour' => $obj->starttimehour))); } if (isset($obj->endtimeminute) && isset($obj->endtimehour)) { $this->set_data(array('endtime' => array('minute' => $obj->endtimeminute, 'hour' => $obj->endtimehour))); } } $mform =& $this->_form; $mform->addElement('hidden', 'id'); // If there is no custom data for the course, create some if (empty($this->_customdata['obj']->course->name) || empty($this->_customdata['obj']->id)) { $courses = array(); if (!empty($USER->id)) { $contexts = get_contexts_by_capability_for_user('course', 'block/curr_admin:class:create', $USER->id); // get listing of available ELIS courses $courses = course_get_listing('name', 'ASC', 0, 0, '', '', $contexts); } // Add course select $attributes = array('onchange' => 'update_trk_multiselect(); '); $selections = array(); if (!empty($courses)) { foreach ($courses as $course) { $selections[$course->id] = '(' . $course->idnumber . ')' . $course->name; } } $mform->addElement('select', 'courseid', get_string('course', 'block_curr_admin') . ':', $selections, $attributes); $mform->setHelpButton('courseid', array('cmclassform/course', get_string('course', 'block_curr_admin'), 'block_curr_admin')); $firstcourse = reset($courses); $this->firstcourse = $firstcourse; if (false !== $firstcourse && empty($this->_customdata['obj']->id)) { $this->add_track_multi_select($firstcourse->id); } elseif (!empty($courses)) { $this->add_track_multi_select($this->_customdata['obj']->courseid); } } else { $extra_params = array(); $mform->addElement('static', 'courseid', get_string('course', 'block_curr_admin') . ':'); // Get current action and set param accordingly $current_action = optional_param('action', 'view', PARAM_ALPHA); $extra_params['action'] = $current_action; $extra_params['s'] = 'crs'; // Want to set the url for the course $extra_params['id'] = $this->_customdata['obj']->courseid; // Course id $course_url = $this->get_moodle_url($extra_params); $course_name = '(' . $this->_customdata['obj']->course->idnumber . ')' . '<a href="' . $course_url . '" >' . $this->_customdata['obj']->course->name . '</a>'; $this->set_data(array('courseid' => $course_name)); $mform->setHelpButton('courseid', array('cmclassform/course', get_string('course', 'block_curr_admin'), 'block_curr_admin')); $this->add_track_multi_select($this->_customdata['obj']->courseid); } if (!empty($this->_customdata['obj']->courseid)) { $mform->freeze('courseid'); } else { $mform->addRule('courseid', get_string('required'), 'required', NULL, 'client'); } // Done adding course select //get_string('general'); $mform->addElement('text', 'idnumber', get_string('class_idnumber', 'block_curr_admin') . ':'); $mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client'); $mform->setType('idnumber', PARAM_TEXT); $mform->setHelpButton('idnumber', array('cmclassform/idnumber', get_string('class_idnumber', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('date_selector', 'startdate', get_string('class_startdate', 'block_curr_admin') . ':', array('optional' => true, 'disabled' => 'disabled')); $mform->setHelpButton('startdate', array('cmclassform/startdate', get_string('class_startdate', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('date_selector', 'enddate', get_string('class_enddate', 'block_curr_admin') . ':', array('optional' => true)); // They may very likely be a much better way of checking for this... if (empty($obj->starttimehour) and empty($obj->starttimeminute)) { $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => $CURMAN->config->time_format_12h)); } else { $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => $CURMAN->config->time_format_12h)); } $mform->setHelpButton('starttime', array('cmclassform/starttime', get_string('class_starttime', 'block_curr_admin'), 'block_curr_admin')); // Do the same thing for the endtime if (empty($obj->endtimehour) and empty($obj->endtimeminute)) { $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => $CURMAN->config->time_format_12h)); } else { $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => $CURMAN->config->time_format_12h)); } $mform->addElement('text', 'maxstudents', get_string('class_maxstudents', 'block_curr_admin') . ':'); $mform->setType('maxstudents', PARAM_INT); $mform->setHelpButton('maxstudents', array('cmclassform/maxstudents', get_string('class_maxstudents', 'block_curr_admin'), 'block_curr_admin')); // Environment selector $envs = environment_get_listing(); $envs = $envs ? $envs : array(); $o_envs = array(get_string('none', 'block_curr_admin')); foreach ($envs as $env) { $o_envs[$env->id] = $env->name; } $mform->addElement('select', 'environmentid', get_string('environment', 'block_curr_admin') . ':', $o_envs); $mform->setHelpButton('environmentid', array('cmclassform/environment', get_string('environment', 'block_curr_admin'), 'block_curr_admin')); // Course selector if (empty($this->_customdata['obj']->moodlecourseid)) { $this->add_moodle_course_select(); } else { global $CURMAN; $coursename = $CURMAN->db->get_field('course', 'fullname', 'id', $this->_customdata['obj']->moodlecourseid); $mform->addElement('static', 'class_attached_course', get_string('class_attached_course', 'block_curr_admin') . ':', "<a href=\"{$CFG->wwwroot}/course/view.php?id={$this->_customdata['obj']->moodlecourseid}\">{$coursename}</a>"); $mform->setHelpButton('class_attached_course', array('cmclassform/moodlecourseid', get_string('moodlecourse', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('hidden', 'moodlecourseid'); } $mform->addElement('checkbox', 'enrol_from_waitlist', get_string('waitlistenrol', 'block_curr_admin') . ':'); $mform->setHelpButton('enrol_from_waitlist', array('cmclassform/waitlistenrol', get_string('waitlistenrol', 'block_curr_admin'), 'block_curr_admin')); // custom fields $fields = field::get_for_context_level('class'); $fields = $fields ? $fields : array(); $lastcat = null; $context = isset($this->_customdata['obj']) && isset($this->_customdata['obj']->id) ? get_context_instance(context_level_base::get_custom_context_level('class', 'block_curr_admin'), $this->_customdata['obj']->id) : get_context_instance(CONTEXT_SYSTEM); require_once CURMAN_DIRLOCATION . '/plugins/manual/custom_fields.php'; foreach ($fields as $rec) { $field = new field($rec); if (!isset($field->owners['manual'])) { continue; } if ($lastcat != $rec->categoryid) { $lastcat = $rec->categoryid; $mform->addElement('header', "category_{$lastcat}", htmlspecialchars($rec->categoryname)); } manual_field_add_form_element($this, $context, $field); } $this->add_action_buttons(); }
public function definition() { if (isset($this->_customdata['obj']->id)) { $id = $this->_customdata['obj']->id; } global $CFG, $CURMAN; require_js($CFG->wwwroot . '/curriculum/js/courseform.js'); $this->set_data($this->_customdata['obj']); $mform =& $this->_form; $mform->addElement('hidden', 'id'); $mform->addElement('text', 'name', get_string('course_name', 'block_curr_admin') . ':'); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('required_field', 'block_curr_admin', get_string('course_name', 'block_curr_admin')), 'required', null, 'client'); $mform->addRule('name', null, 'maxlength', 255); $mform->setHelpButton('name', array('courseform/name', get_string('course_name', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'code', get_string('course_code', 'block_curr_admin') . ':'); $mform->setType('code', PARAM_TEXT); $mform->addRule('code', null, 'maxlength', 100); $mform->setHelpButton('code', array('courseform/code', get_string('course_code', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'idnumber', get_string('course_idnumber', 'block_curr_admin') . ':'); $mform->setType('idnumber', PARAM_TEXT); $mform->addRule('idnumber', get_string('required_field', 'block_curr_admin', get_string('course_idnumber', 'block_curr_admin')), 'required', null, 'client'); $mform->addRule('idnumber', null, 'maxlength', 100); $mform->setHelpButton('idnumber', array('courseform/idnumber', get_string('course_idnumber', 'block_curr_admin'), 'block_curr_admin')); $attributes = array('cols' => 40, 'rows' => 2); $mform->addElement('textarea', 'syllabus', get_string('course_syllabus', 'block_curr_admin') . ':', $attributes); $mform->setType('syllabus', PARAM_CLEAN); $mform->setHelpButton('syllabus', array('courseform/description', get_string('course_syllabus', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'lengthdescription', get_string('length_description', 'block_curr_admin')); $mform->setType('lengthdescription', PARAM_TEXT); $mform->addRule('lengthdescription', null, 'maxlength', 100); $mform->setHelpButton('lengthdescription', array('courseform/lengthdescription', get_string('length_description', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'length', get_string('duration', 'block_curr_admin') . ':'); $mform->setType('length', PARAM_INT); $mform->setHelpButton('length', array('courseform/duration', get_string('duration', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'credits', get_string('credits', 'block_curr_admin') . ':'); $mform->setType('credits', PARAM_TEXT); $mform->addRule('credits', null, 'maxlength', 10); $mform->setHelpButton('credits', array('courseform/credits', get_string('credits', 'block_curr_admin'), 'block_curr_admin')); $grades = range(0, 100, 1); $mform->addElement('select', 'completion_grade', get_string('completion_grade', 'block_curr_admin') . ':', $grades); $mform->setHelpButton('completion_grade', array('courseform/completion_grade', get_string('completion_grade', 'block_curr_admin'), 'block_curr_admin')); $environments = array('- ' . get_string('none', 'block_curr_admin') . ' -'); $envs = environment_get_listing(); if (empty($envs)) { $envs = array(); } foreach ($envs as $e) { $environments[$e->id] = $e->name; } $mform->addElement('select', 'environmentid', get_string('environment', 'block_curr_admin'), $environments); $mform->setHelpButton('environmentid', array('courseform/environmentid', get_string('environment', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'cost', get_string('cost', 'block_curr_admin') . ':'); $mform->setType('cost', PARAM_TEXT); $mform->addRule('cost', null, 'maxlength', 10); $mform->setHelpButton('cost', array('courseform/cost', get_string('cost', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'version', get_string('course_version', 'block_curr_admin') . ':'); $mform->setType('version', PARAM_TEXT); $mform->addRule('version', null, 'maxlength', 100); $mform->setHelpButton('version', array('courseform/version', get_string('course_version', 'block_curr_admin'), 'block_curr_admin')); // Print form items for course template browsing $mform->addElement('html', '<br />'); $mform->addElement('hidden', 'templateclass', 'moodlecourseurl', array('id' => 'id_templateclass')); if (optional_param('action', '', PARAM_CLEAN) == 'view' && !empty($this->_customdata['obj']->locationlabel)) { $mform->addElement('static', 'locationlabellink', get_string('coursetemplate', 'block_curr_admin') . ':', "<a href=\"{$CFG->wwwroot}/course/view.php?id={$this->_customdata['obj']->locationid}\">{$this->_customdata['obj']->locationlabel}</a>"); $mform->setHelpButton('locationlabellink', array('courseform/coursetemplate', get_string('coursetemplate', 'block_curr_admin'), 'block_curr_admin')); } else { $mform->addElement('text', 'locationlabel', get_string('coursetemplate', 'block_curr_admin') . ':', array('readonly' => 'readonly')); $mform->setType('locationlabel', PARAM_TEXT); $mform->setHelpButton('locationlabel', array('courseform/coursetemplate', get_string('coursetemplate', 'block_curr_admin'), 'block_curr_admin')); } if (empty($id)) { $mform->addElement('hidden', 'location', '', array('id' => 'id_location')); $mform->addElement('hidden', 'temptype', '', array('id' => 'tempid')); } else { global $CURMAN; $template = new coursetemplate($id); $mform->addElement('hidden', 'location', $template->location, array('id' => 'id_location')); $mform->addElement('hidden', 'tempid', $template->id, array('id' => 'tempid')); } $templateButtons = array(); $templateButtons[] =& $mform->createElement('button', 'submit1', get_string('browse', 'block_curr_admin'), array('onClick' => 'openNewWindow();')); $templateButtons[] =& $mform->createElement('button', 'submit1', get_string('clear', 'block_curr_admin'), array('onClick' => 'cleartext();')); $mform->addGroup($templateButtons, 'templateButtons', '', '', false); // Multi select box for choosing curricula (only when creating a course) if (!isset($this->_customdata['obj'])) { $mform->addElement('html', '<br />'); $cur_listings = curriculum_get_listing(); $cur_listings = $cur_listings ? $cur_listings : array(); $values = array(); foreach ($cur_listings as $key => $val) { $values[$key] = $val->name; } $strcur = get_string("curricula", "block_curr_admin"); // Set an explicit width if the select box will have no elements. $attributes = empty($values) ? array('style' => 'width: 200px;') : array(); $multiSelect =& $mform->addElement('select', 'curriculum', $strcur . ':', $values, $attributes); $multiSelect->setMultiple(true); $mform->setHelpButton('curriculum', array('courseform/curriculum', get_string('curriculum', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('submit', 'makecurcourse', get_string('makecurcourse', 'block_curr_admin')); } // custom fields $fields = field::get_for_context_level('course'); $fields = $fields ? $fields : array(); $lastcat = null; $context = isset($this->_customdata['obj']) && isset($this->_customdata['obj']->id) ? get_context_instance(context_level_base::get_custom_context_level('course', 'block_curr_admin'), $this->_customdata['obj']->id) : get_context_instance(CONTEXT_SYSTEM); require_once CURMAN_DIRLOCATION . '/plugins/manual/custom_fields.php'; foreach ($fields as $rec) { $field = new field($rec); if (!isset($field->owners['manual'])) { continue; } if ($lastcat != $rec->categoryid) { $lastcat = $rec->categoryid; $mform->addElement('header', "category_{$lastcat}", htmlspecialchars($rec->categoryname)); } manual_field_add_form_element($this, $context, $field); } $this->add_action_buttons(); }