function display_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' => array('header' => get_string('curriculum_name', 'local_elisprogram')), 'description' => array('header' => get_string('description', 'local_elisprogram')), 'reqcredits' => array('header' => get_string('curriculum_reqcredits', 'local_elisprogram')), 'courses' => array('header' => get_string('courses', 'local_elisprogram')), 'priority' => array('header' => get_string('priority', 'local_elisprogram'))); if ($dir !== 'DESC') { $dir = 'ASC'; } if (isset($columns[$sort])) { $columns[$sort]['sortable'] = $dir; } // Get list of users $items = curriculum_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, curriculumpage::get_contexts('local/elisprogram:program_view')); $numitems = curriculum_count_records($namesearch, $alpha, curriculumpage::get_contexts('local/elisprogram:program_view')); curriculumpage::get_contexts('local/elisprogram:program_edit'); curriculumpage::get_contexts('local/elisprogram:program_delete'); $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true); }
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(cm_get_param('search', '')); $alpha = cm_get_param('alpha', ''); // Define columns $columns = array('name' => get_string('curriculum_name', 'block_curr_admin'), 'description' => get_string('curriculum_shortdescription', 'block_curr_admin'), 'reqcredits' => get_string('curriculum_reqcredits', 'block_curr_admin'), 'courses' => get_string('courses', 'block_curr_admin'), 'priority' => get_string('priority', 'block_curr_admin')); // Get list of users $items = curriculum_get_listing($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha, curriculumpage::get_contexts('block/curr_admin:curriculum:view')); $numitems = curriculum_count_records($namesearch, $alpha, curriculumpage::get_contexts('block/curr_admin:curriculum:view')); curriculumpage::get_contexts('block/curr_admin:curriculum:edit'); curriculumpage::get_contexts('block/curr_admin:curriculum:delete'); $this->print_list_view($items, $numitems, $columns, $filter = null, $alphaflag = true, $searchflag = true); }
/** * items in the form * * @uses $USER */ public function definition() { global $USER; $this->set_data($this->_customdata['obj']); $mform =& $this->_form; $mform->addElement('hidden', 'id'); $curs = array(); if (!empty($USER->id)) { // TBD: and/or capability 'block/curr_admin:curriculum:edit|view' ? // WAS: 'block/curr_admin:track:create' ??? $contexts = get_contexts_by_capability_for_user('curriculum', 'block/curr_admin:curriculum:view', $USER->id); $curs = curriculum_get_listing('name', 'ASC', 0, 0, '', '', $contexts); } if (empty($this->_customdata['obj']->id)) { $curid_options = array(); if (!empty($curs)) { foreach ($curs as $cur) { $curid_options[$cur->id] = '(' . $cur->idnumber . ') ' . $cur->name; } } $mform->addElement('select', 'curid', get_string('curriculum', 'block_curr_admin') . ':', $curid_options); $mform->addRule('curid', get_string('required'), 'required', NULL, 'client'); $mform->setHelpButton('curid', array('trackform/curriculum', get_string('curriculum', 'block_curr_admin'), 'block_curr_admin')); } else { // Track editing, do not allow the user to change curriculum $mform->addElement('static', 'curidstatic', get_string('curriculum', 'block_curr_admin') . ':', $curs[$this->_customdata['obj']->curid]->name); $mform->setHelpButton('curidstatic', array('trackform/curriculum', get_string('curriculum', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('hidden', 'curid'); } $mform->addElement('text', 'idnumber', get_string('track_idnumber', 'block_curr_admin') . ':'); $mform->setType('idnumber', PARAM_TEXT); $mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client'); $mform->addRule('idnumber', null, 'maxlength', 100); $mform->setHelpButton('idnumber', array('trackform/idnumber', get_string('track_idnumber', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('text', 'name', get_string('track_name', 'block_curr_admin') . ':'); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'maxlength', 255); $mform->addRule('name', get_string('required'), 'required', NULL, 'client'); $mform->setHelpButton('name', array('trackform/name', get_string('track_name', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('textarea', 'description', get_string('track_description', 'block_curr_admin') . ':'); $mform->setType('description', PARAM_CLEAN); $mform->setHelpButton('description', array('trackform/description', get_string('track_description', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('date_selector', 'startdate', get_string('track_startdate', 'block_curr_admin') . ':', array('optional' => true)); $mform->addElement('date_selector', 'enddate', get_string('track_enddate', 'block_curr_admin') . ':', array('optional' => true)); $mform->setHelpButton('startdate', array('trackform/startdate', get_string('startdate', 'block_curr_admin'), 'block_curr_admin')); if (!empty($this->_customdata['obj']->id)) { $trackassignobj = new trackassignmentclass(array('trackid' => $this->_customdata['obj']->id)); } // Only show auto-create checkbox if the track does not have any classes assigned if (!isset($trackassignobj) or 0 == $trackassignobj->count_assigned_classes_from_track()) { $mform->addElement('checkbox', 'autocreate', get_string('track_autocreate', 'block_curr_admin') . ':'); $mform->setHelpButton('autocreate', array('trackform/autocreate', get_string('track_autocreate', 'block_curr_admin'), 'block_curr_admin')); } // custom fields $fields = field::get_for_context_level('track'); $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('track', '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(); }
function action_copycurredit() { global $CFG, $USER, $CURMAN; require_js($CFG->wwwroot . '/curriculum/js/clustercurriculumpage.js'); $id = $this->required_param('id', PARAM_INT); // Create a list of curricula to be excluded $curriculumshown = array(); $table = new stdClass(); $table->head = array(get_string('clustcpyclustname', 'block_curr_admin'), get_string('clustcpycurname', 'block_curr_admin'), get_string('clustcpyadd', 'block_curr_admin'), get_string('clustcpytrkcpy', 'block_curr_admin'), get_string('clustcpycrscpy', 'block_curr_admin'), get_string('clustcpyclscpy', 'block_curr_admin'), get_string('clustcpymdlclscpy', 'block_curr_admin')); $table->class = 'cluster_copy_curriculum'; // Get all clusters $sort = 'name'; $dir = 'ASC'; $clusters = cluster_get_listing($sort, $dir, 0); $clusterlist = array(); $sql = 'SELECT * from ' . $CURMAN->db->prefix_table('crlm_cluster'); // Exclude clusters the user does not have the capability to manage/see $context = get_contexts_by_capability_for_user('cluster', 'block/curr_admin:cluster:view', $USER->id); foreach ($clusters as $clusid => $clusdata) { $haspermission = $context->context_allowed($clusid, 'cluster'); if (!$haspermission) { unset($clusters[$clusid]); } } echo '<form action="index.php" method="post">'; $mdlcrsoptions = array('copyalways' => get_string('currcopy_mdlcrs_copyalways', 'block_curr_admin'), 'copyautocreated' => get_string('currcopy_mdlcrs_copyautocreated', 'block_curr_admin'), 'autocreatenew' => get_string('currcopy_mdlcrs_autocreatenew', 'block_curr_admin'), 'link' => get_string('currcopy_mdlcrs_link', 'block_curr_admin')); $contexts = curriculumpage::get_contexts('block/curr_admin:associate'); foreach ($clusters as $clusid => $clusdata) { $assocurr = clustercurriculum::get_curricula($clusid); if (!empty($assocurr)) { $first = true; foreach ($assocurr as $assocurrrec) { // Add to list of curricula to exclude $curriculumshown[] = $assocurrrec->curriculumid; // Skip over this clusters associated curricula if ($clusid == $id) { continue; } // Skip over curricula that user cannot associate if (!$contexts->context_allowed($assocurrrec->curriculumid, 'curriculum')) { continue; } if ($first) { $curname = format_string($clusdata->name); $first = false; } else { $curname = ''; } $table->data[] = array($curname, format_string($assocurrrec->name), print_checkbox(self::CPY_CURR_PREFIX . $assocurrrec->curriculumid, 1, false, '', '', '', true), print_checkbox(self::CPY_CURR_TRK_PREFIX . $assocurrrec->curriculumid, 1, false, '', '', '', true), print_checkbox(self::CPY_CURR_CRS_PREFIX . $assocurrrec->curriculumid, 1, false, '', '', '', true), print_checkbox(self::CPY_CURR_CLS_PREFIX . $assocurrrec->curriculumid, 1, false, '', '', '', true), choose_from_menu($mdlcrsoptions, self::CPY_CURR_MDLCRS_PREFIX . $assocurrrec->curriculumid, '', '', '', 0, true)); $table->rowclass[] = 'clus_cpy_row'; } } } // Add unassociated row to table $table->data[] = array(get_string('unassociated', 'block_curr_admin'), '', '', '', '', '', ''); $table->rowclass[] = 'clus_cpy_row unassigned'; // Get all curriculums, removing curricula that have already // been listed $curriculums = curriculum_get_listing($sort, $dir, 0, 0, '', '', $contexts); foreach ($curriculums as $curriculumid => $curriculumdata) { if (false === array_search($curriculumid, $curriculumshown)) { $table->data[] = array('', format_string($curriculumdata->name), print_checkbox(self::CPY_CURR_PREFIX . $curriculumid, 1, false, '', '', '', true), print_checkbox(self::CPY_CURR_TRK_PREFIX . $curriculumid, 1, false, '', '', '', true), print_checkbox(self::CPY_CURR_CRS_PREFIX . $curriculumid, 1, false, '', '', '', true), print_checkbox(self::CPY_CURR_CLS_PREFIX . $curriculumid, 1, false, '', '', '', true), choose_from_menu($mdlcrsoptions, self::CPY_CURR_MDLCRS_PREFIX . $curriculumid, '', '', '', 0, true)); $table->rowclass[] = 'clus_cpy_row'; } } $currselectall = '<div class="currselectall">' . '<a id="clus_currcpy_select_all" onclick="cluster_copycurriculum_set_all_selected()">' . get_string('selectall') . '</a></div>'; $trkselectall = '<div class="trkselectall">' . '<a id="clus_trkcpy_select_all" onclick="cluster_copytrack_set_all_selected()">' . get_string('selectall') . '</a></div>'; $crsselectall = '<div class="crsselectall">' . '<a id="clus_crscpy_select_all" onclick="cluster_copycourse_set_all_selected()">' . get_string('selectall') . '</a></div>'; $clsselectall = '<div class="clsselectall">' . '<a id="clus_crscpy_select_all" onclick="cluster_copyclass_set_all_selected()">' . get_string('selectall') . '</a></div>'; $table->data[] = array('', '', $currselectall, $trkselectall, $crsselectall, $clsselectall); $table->rowclass[] = 'clus_cpy_row select_all_row'; echo print_table($table, true); echo '<div class="clus_curr_cpy_save_exit">'; echo '<input type="submit" name="save" value="' . get_string('saveexit', 'block_curr_admin') . '">'; echo '<div class="hidden">'; echo '<input type="hidden" name="id" value="' . $id . '">'; echo '<input type="hidden" name="s" value="clstcur">'; echo '<input type="hidden" name="action" value="copycurr">'; echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '">'; echo '</div>'; echo '</div>'; echo '</form>'; }
*/ if (!isset($_SERVER['REMOTE_ADDR'])) { define('CLI_SCRIPT', true); } require_once dirname(__FILE__) . '/../lib/setup.php'; require_once elispm::lib('data/curriculumcourse.class.php'); global $DB, $FULLME, $OUTPUT, $PAGE; if (isset($_SERVER['REMOTE_ADDR'])) { die('Cannot execute this script via web, command-line only.'); } if ($argc > 1) { die(print_usage()); } mtrace("Begin Program Completion Date updating ..."); $fixed_cnt = 0; $currs = curriculum_get_listing(); foreach ($currs as $cur) { $currcourses = $DB->get_records(curriculumcourse::TABLE, array('curriculumid' => $cur->id)); // mtrace("\ncur: {$cur->id} - courses = ". var_sdump($currcourses)); if (count($currcourses) == 1) { $currcourse = current($currcourses); $currclasses = $DB->get_records('local_elisprogram_cls', array('courseid' => $currcourse->courseid), '', 'id'); // mtrace("\ncur: {$cur->id} - classes = ". var_sdump($currclasses)); if (empty($currclasses)) { continue; } $currasses = $DB->get_recordset_select('local_elisprogram_pgm_assign', 'curriculumid = ? AND locked = 1 AND completed = ? AND timecompleted > 0', array($cur->id, STUSTATUS_PASSED)); foreach ($currasses as $currass) { $classenrolments = $DB->get_records_select('local_elisprogram_cls_enrol', 'userid = ? AND classid IN (' . implode(',', array_keys($currclasses)) . ')', array($currass->userid)); if (count($classenrolments) != 1) { continue;
/** * Specifies available report filters * (empty by default but can be implemented by child class) * * @param boolean $init_data If true, signal the report to load the * actual content of the filter objects * * @return array The list of available filters */ function get_filters($init_data = true) { global $CFG; $cms = array(); $contexts = get_contexts_by_capability_for_user('curriculum', $this->access_capability, $this->userid); $cms_objects = curriculum_get_listing('name', 'ASC', 0, 0, '', '', $contexts); if (!empty($cms_objects)) { foreach ($cms_objects as $curriculum) { $cms[$curriculum->id] = $curriculum->name; } } $cms['null'] = get_string('filter_non_program', 'rlreport_course_progress_summary'); $curricula_options = array('choices' => $cms, 'numeric' => false); $field_list = array(); // Add block id to field list array $field_list['block_instance'] = $this->id; $field_list['reportname'] = $this->get_report_shortname(); // Need help text $field_list['help'] = array('course_progress_summary', get_string('filter_custom_fields', 'rlreport_course_progress_summary'), 'rlreport_course_progress_summary'); $filter_entries = array(); $filter_entries[] = new generalized_filter_entry('curr', 'curcrs', 'curriculumid', get_string('filter_program', 'rlreport_course_progress_summary'), false, 'selectany', $curricula_options); $filter_entries[] = new generalized_filter_entry('cluster', 'enrol', 'userid', get_string('filter_cluster', 'rlreport_course_progress_summary'), false, 'clusterselect', array('default' => null)); $filter_entries[] = new generalized_filter_entry('field' . $this->id, 'field' . $this->id, 'id', get_string('filter_field', 'rlreport_course_progress_summary'), false, 'custom_field_multiselect_values', $field_list); $filter_entries[] = new generalized_filter_entry('enrol', 'enrol', 'enrolmenttime', get_string('filter_course_date', 'rlreport_course_progress_summary'), false, 'date'); $filter_entries[] = new generalized_filter_entry('enrol', 'enrol', 'enrolmenttime', get_string('filter_course_date', 'rlreport_course_progress_summary'), false, 'date'); return $filter_entries; }
/** * items in the form * * @uses $USER */ public function definition() { global $USER; $fields = field::get_for_context_level('track'); foreach ($fields as $rec) { $field = new field($rec); if (strcmp($field->datatype, "num") == 0) { $fieldname = "field_{$field->shortname}"; if (isset($this->_customdata['obj']->{$fieldname})) { $formatnum = $field->format_number($this->_customdata['obj']->{$fieldname}); $this->_customdata['obj']->{$fieldname} = $formatnum; } } } $this->set_data($this->_customdata['obj']); $mform =& $this->_form; $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $curs = array(); if (!empty($USER->id)) { // TBD: and/or capability 'local/elisprogram:track_edit|view' ? // This is necessary for creating a new track but will prevent a parent programs from appearing // when the user has track edit permissions but not track creation permission -- ELIS-5954 $contexts = get_contexts_by_capability_for_user('curriculum', 'local/elisprogram:track_create', $USER->id); $curs = curriculum_get_listing('name', 'ASC', 0, 0, '', '', $contexts); } if (empty($this->_customdata['obj']->id)) { $curid_options = array(); if (!empty($curs)) { foreach ($curs as $cur) { $curid_options[$cur->id] = '(' . $cur->idnumber . ') ' . $cur->name; } } $mform->addElement('select', 'curid', get_string('curriculum', 'local_elisprogram') . ':', $curid_options); $mform->addRule('curid', get_string('required'), 'required', NULL, 'client'); $mform->addHelpButton('curid', 'trackform:curriculum_curid', 'local_elisprogram'); } else { // Track editing, do not allow the user to change curriculum // Make sure that the parent program for this track is always included otherwise the display is messed up // and hitting the form Cancel button causes a DB error -- ELIS-5954 $track = new track($this->_customdata['obj']->id); $curs = curriculum_get_listing('name', 'ASC', 0, 0, $track->curriculum->name); $mform->addElement('static', 'curidstatic', get_string('curriculum', 'local_elisprogram') . ':', $curs[$this->_customdata['obj']->curid]->name); $mform->addHelpButton('curidstatic', 'trackform:curriculum_curidstatic', 'local_elisprogram'); $mform->addElement('hidden', 'curid'); $mform->setType('curid', PARAM_INT); } $mform->addElement('text', 'idnumber', get_string('track_idnumber', 'local_elisprogram') . ':'); $mform->setType('idnumber', PARAM_TEXT); $mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client'); $mform->addRule('idnumber', null, 'maxlength', 100); $mform->addHelpButton('idnumber', 'trackform:track_idnumber', 'local_elisprogram'); $mform->addElement('text', 'name', get_string('track_name', 'local_elisprogram') . ':'); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'maxlength', 255); $mform->addRule('name', get_string('required'), 'required', NULL, 'client'); $mform->addHelpButton('name', 'trackform:track_name', 'local_elisprogram'); $mform->addElement('textarea', 'description', get_string('track_description', 'local_elisprogram') . ':'); $mform->setType('description', PARAM_CLEAN); $mform->addHelpButton('description', 'trackform:track_description', 'local_elisprogram'); $mform->addElement('date_selector', 'startdate', get_string('track_startdate', 'local_elisprogram') . ':', array('optional' => true)); $mform->addElement('date_selector', 'enddate', get_string('track_enddate', 'local_elisprogram') . ':', array('optional' => true)); $mform->addHelpButton('startdate', 'trackform:track_startdate', 'local_elisprogram'); if (!empty($this->_customdata['obj']->id)) { $trackassignobj = new trackassignment(array('trackid' => $this->_customdata['obj']->id)); } // Only show auto-create checkbox if the track does not have any classes assigned if (!isset($trackassignobj) || 0 == $trackassignobj->count_assigned_classes_from_track()) { $mform->addElement('checkbox', 'autocreate', get_string('track_autocreate', 'local_elisprogram') . ':'); $mform->addHelpButton('autocreate', 'trackform:track_autocreate', 'local_elisprogram'); } // custom fields $this->add_custom_fields('track', 'local/elisprogram:track_edit', 'local/elisprogram:track_view', 'curriculum'); $this->add_action_buttons(); }
/** * Specifies available report filters * (empty by default but can be implemented by child class) * * @param boolean $init_data If true, signal the report to load the * actual content of the filter objects * * @return array The list of available filters */ function get_filters($init_data = true) { global $CFG, $CURMAN, $SESSION; $cms = array(); $contexts = get_contexts_by_capability_for_user('course', $this->access_capability, $this->userid); $cms_objects = curriculum_get_listing('name', 'ASC', 0, 0, '', '', $contexts); if (!empty($cms_objects)) { foreach ($cms_objects as $curriculum) { $cms[$curriculum->id] = $curriculum->name; } } $curricula_options = array('choices' => $cms, 'numeric' => false); // Needs to pull from saved prefs $user_preferences = php_report_filtering_get_user_preferences($this->get_report_shortname()); $report_index = 'php_report_' . $this->get_report_shortname() . '/field' . $this->id; if (!isset($user_preferences[$report_index]) || ($default_fieldid_list = @unserialize(base64_decode($user_preferences[$report_index]))) === false) { $default_fieldid_list = array(); } $field_list = array('fieldids' => $default_fieldid_list); // Add block id to field list array $field_list['block_instance'] = $this->id; $field_list['reportname'] = $this->get_report_shortname(); // Need help text $field_list['help'] = array('course_progress_summary_help', get_string('filter_custom_fields', 'rlreport_course_progress_summary'), 'block_php_report'); $filter_entries = array(); $this->curricula = new generalized_filter_entry('curr', 'curcrs', 'curriculumid', get_string('filter_curricula', 'rlreport_course_progress_summary'), false, 'selectany', $curricula_options); $filter_entries[] = $this->curricula; $filter_entries[] = new generalized_filter_entry('cluster', 'enrol', 'userid', get_string('filter_cluster', 'rlreport_course_progress_summary'), false, 'clusterselect', array('default' => null)); $this->multiselect_filter = new generalized_filter_entry('field' . $this->id, 'field' . $this->id, 'id', get_string('filter_field', 'rlreport_course_progress_summary'), false, 'custom_field_multiselect_values', $field_list); $filter_entries[] = $this->multiselect_filter; $filter_entries[] = new generalized_filter_entry('enrol', 'enrol', 'enrolmenttime', get_string('filter_course_date', 'rlreport_course_progress_summary'), false, 'date'); $filter_entries[] = new generalized_filter_entry('enrol', 'enrol', 'enrolmenttime', get_string('filter_course_date', 'rlreport_course_progress_summary'), false, 'date'); return $filter_entries; }
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(); }
public function definition() { global $CFG, $PAGE, $DB; $locationlabel = ''; if (isset($this->_customdata['obj']->id)) { $id = $this->_customdata['obj']->id; // TO-DO: this should probably be moved to a different location $template = coursetemplate::find(new field_filter('courseid', $id)); if ($template->valid()) { $template = $template->current(); $course = $DB->get_record('course', array('id' => $template->location)); if (!empty($course)) { $locationlabel = $course->fullname . ' ' . $course->shortname; } } else { // use a blank template $template = new coursetemplate(); } } $PAGE->requires->js('/local/elisprogram/js/courseform.js'); $this->set_data($this->_customdata['obj']); $mform =& $this->_form; $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('text', 'name', get_string('course_name', 'local_elisprogram') . ':'); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('required_field', 'local_elisprogram', get_string('course_name', 'local_elisprogram')), 'required', null, 'client'); $mform->addRule('name', null, 'maxlength', 255, 'client'); $mform->addHelpButton('name', 'courseform:course_name', 'local_elisprogram'); $mform->addElement('text', 'code', get_string('course_code', 'local_elisprogram') . ':'); $mform->setType('code', PARAM_TEXT); $mform->addRule('code', null, 'maxlength', 100, 'client'); $mform->addHelpButton('code', 'courseform:course_code', 'local_elisprogram'); $mform->addElement('text', 'idnumber', get_string('course_idnumber', 'local_elisprogram') . ':'); $mform->setType('idnumber', PARAM_TEXT); $mform->addRule('idnumber', get_string('required_field', 'local_elisprogram', get_string('course_idnumber', 'local_elisprogram')), 'required', null, 'client'); $mform->addRule('idnumber', null, 'maxlength', 100, 'client'); $mform->addHelpButton('idnumber', 'courseform:course_idnumber', 'local_elisprogram'); $attributes = array('cols' => 40, 'rows' => 2); $mform->addElement('textarea', 'syllabus', get_string('course_syllabus', 'local_elisprogram') . ':', $attributes); $mform->setType('syllabus', PARAM_CLEAN); $mform->addHelpButton('syllabus', 'courseform:course_syllabus', 'local_elisprogram'); $mform->addElement('text', 'lengthdescription', get_string('length_description', 'local_elisprogram')); $mform->setType('lengthdescription', PARAM_TEXT); $mform->addRule('lengthdescription', null, 'maxlength', 100, 'client'); $mform->addHelpButton('lengthdescription', 'courseform:length_description', 'local_elisprogram'); $mform->addElement('text', 'length', get_string('duration', 'local_elisprogram') . ':'); $mform->setType('length', PARAM_INT); $mform->addHelpButton('length', 'courseform:duration', 'local_elisprogram'); $mform->addElement('text', 'credits', get_string('credits', 'local_elisprogram') . ':'); $mform->setType('credits', PARAM_TEXT); $mform->addRule('credits', null, 'maxlength', 10, 'client'); $mform->addHelpButton('credits', 'courseform:credits', 'local_elisprogram'); $grades = range(0, 100, 1); $mform->addElement('select', 'completion_grade', get_string('completion_grade', 'local_elisprogram') . ':', $grades); $mform->addHelpButton('completion_grade', 'courseform:completion_grade', 'local_elisprogram'); $mform->addElement('text', 'cost', get_string('cost', 'local_elisprogram') . ':'); $mform->setType('cost', PARAM_TEXT); $mform->addRule('cost', null, 'maxlength', 10, 'client'); $mform->addHelpButton('cost', 'courseform:cost', 'local_elisprogram'); $mform->addElement('text', 'version', get_string('course_version', 'local_elisprogram') . ':'); $mform->setType('version', PARAM_TEXT); $mform->addRule('version', null, 'maxlength', 100, 'client'); $mform->addHelpButton('version', 'courseform:course_version', 'local_elisprogram'); // Print form items for course template browsing $mform->addElement('html', '<br />'); $mform->addElement('hidden', 'templateclass', 'moodlecourseurl', array('id' => 'id_templateclass')); $mform->setType('templateclass', PARAM_TEXT); if (empty($locationlabel) || optional_param('action', '', PARAM_CLEAN) != 'view') { $mform->addElement('text', 'locationlabel', get_string('coursetemplate', 'local_elisprogram'), array('readonly' => 'readonly', 'value' => $locationlabel)); $mform->setType('locationlabel', PARAM_TEXT); $mform->addHelpButton('locationlabel', 'courseform:coursetemplate', 'local_elisprogram'); } else { $mform->addElement('static', 'locationlabellink', get_string('coursetemplate', 'local_elisprogram') . ':', "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$locationlabel}</a>"); $mform->addHelpButton('locationlabellink', 'courseform:coursetemplate', 'local_elisprogram'); } if (empty($id)) { $mform->addElement('hidden', 'location', '', array('id' => 'id_location')); $mform->setType('location', PARAM_INT); $mform->addElement('hidden', 'temptype', '', array('id' => 'tempid')); $mform->setType('temptype', PARAM_INT); } else { $mform->addElement('hidden', 'location', $template->location, array('id' => 'id_location')); $mform->setType('location', PARAM_INT); $mform->addElement('hidden', 'tempid', $template->id, array('id' => 'tempid')); $mform->setType('tempid', PARAM_INT); } $templateButtons = array(); $templateButtons[] =& $mform->createElement('button', 'submit1', get_string('browse', 'local_elisprogram'), array('onClick' => 'openNewWindow();')); $templateButtons[] =& $mform->createElement('button', 'submit1', get_string('clear', 'local_elisprogram'), 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", "local_elisprogram"); // 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->addHelpButton('curriculum', 'courseform:curriculum', 'local_elisprogram'); $mform->addElement('submit', 'makecurcourse', get_string('makecurcourse', 'local_elisprogram')); } // custom fields $this->add_custom_fields('course', 'local/elisprogram:course_edit', 'local/elisprogram:course_view'); $this->add_action_buttons(); }
/** * Specifies available report filters * (empty by default but can be implemented by child class) * * @param boolean $initdata If true, signal the report to load the actual content of the filter objects. * @uses $DB * @return array The list of available filters */ public function get_filters($initdata = true) { $cms = array(); $contexts = get_contexts_by_capability_for_user('curriculum', $this->access_capability, $this->userid); $cms_objects = curriculum_get_listing('name', 'ASC', 0, 0, '', '', $contexts); if (!empty($cms_objects)) { foreach ($cms_objects as $curriculum) { $cms[$curriculum->id] = $curriculum->name; } } // Create all requested User Profile field filters. $upfilter = new generalized_filter_elisuserprofile('cu', get_string('filter_user_match', 'rlreport_curricula'), array('choices' => $this->_fields, 'notadvanced' => array('fullname'), 'extra' => true, 'tables' => array('up' => array(user::TABLE => 'crlmu')))); $filters = $upfilter->get_filters(); $filters = array_merge($filters, array(new generalized_filter_entry('curr', 'curass', 'curriculumid', get_string('filter_program', 'rlreport_curricula'), false, 'selectall', array('choices' => $cms, 'multiple' => true)), new generalized_filter_entry('cluster', 'crlmu', 'id', get_string('filter_cluster', 'rlreport_curricula'), false, 'clusterselect', array('default' => null)))); return $filters; }
/** * Display copy curriculum action. */ public function display_copycurredit() { global $CFG, $USER, $PAGE, $DB, $OUTPUT; $PAGE->requires->js('/local/elisprogram/js/clustercurriculumpage.js'); $id = $this->required_param('id', PARAM_INT); // Create a list of curricula to be excluded. $curriculumshown = array(); $table = new html_table(); $table->head = array(get_string('userset_cpyclustname', 'local_elisprogram'), get_string('userset_cpycurname', 'local_elisprogram'), get_string('userset_cpyadd', 'local_elisprogram'), get_string('userset_cpytrkcpy', 'local_elisprogram'), get_string('userset_cpycrscpy', 'local_elisprogram'), get_string('userset_cpyclscpy', 'local_elisprogram'), get_string('userset_cpymdlclscpy', 'local_elisprogram')); $table->class = 'cluster_copy_curriculum'; // Get all clusters. $sort = 'name'; $dir = 'ASC'; $clusters = cluster_get_listing($sort, $dir, 0); $clusterlist = array(); $sql = 'SELECT * from {' . userset::TABLE . '}'; // Exclude clusters the user does not have the capability to manage/see. $context = get_contexts_by_capability_for_user('cluster', 'local/elisprogram:userset_view', $USER->id); echo '<form action="index.php" method="post">'; $mdlcrsoptions = array('copyalways' => get_string('program_copy_mdlcrs_copyalways', 'local_elisprogram'), 'copyautocreated' => get_string('program_copy_mdlcrs_copyautocreated', 'local_elisprogram'), 'autocreatenew' => get_string('program_copy_mdlcrs_autocreatenew', 'local_elisprogram'), 'link' => get_string('program_copy_mdlcrs_link', 'local_elisprogram')); $contexts = curriculumpage::get_contexts('local/elisprogram:associate'); foreach ($clusters as $clusid => $clusdata) { if (!$context->context_allowed($clusid, 'cluster')) { continue; } $assocurr = clustercurriculum::get_curricula($clusid); if (!empty($assocurr)) { $first = true; foreach ($assocurr as $assocurrrec) { // Add to list of curricula to exclude. $curriculumshown[] = $assocurrrec->curriculumid; // Skip over this clusters associated curricula. if ($clusid == $id) { continue; } // Skip over curricula that user cannot associate. if (!$contexts->context_allowed($assocurrrec->curriculumid, 'curriculum')) { continue; } if ($first) { $curname = format_string($clusdata->name); $first = false; } else { $curname = ''; } // Disable the last 3 options unless the first is checked. $checkboxids = "'" . self::CPY_CURR_PREFIX . $assocurrrec->curriculumid . "',\n '" . self::CPY_CURR_TRK_PREFIX . $assocurrrec->curriculumid . "',\n '" . self::CPY_CURR_CRS_PREFIX . $assocurrrec->curriculumid . "',\n '" . self::CPY_CURR_CLS_PREFIX . $assocurrrec->curriculumid . "'"; $togglecheckboxes = "cluster_copy_checkbox_changed(" . $checkboxids . ");"; $table->data[] = array($curname, format_string($assocurrrec->name), html_writer::checkbox(self::CPY_CURR_PREFIX . $assocurrrec->curriculumid, 1, false, '', array('id' => self::CPY_CURR_PREFIX . $assocurrrec->curriculumid, 'onclick' => $togglecheckboxes)), html_writer::checkbox(self::CPY_CURR_TRK_PREFIX . $assocurrrec->curriculumid, 1, false, '', array('disabled' => true, 'id' => self::CPY_CURR_TRK_PREFIX . $assocurrrec->curriculumid)), html_writer::checkbox(self::CPY_CURR_CRS_PREFIX . $assocurrrec->curriculumid, 1, false, '', array('disabled' => true, 'id' => self::CPY_CURR_CRS_PREFIX . $assocurrrec->curriculumid)), html_writer::checkbox(self::CPY_CURR_CLS_PREFIX . $assocurrrec->curriculumid, 1, false, '', array('disabled' => true, 'id' => self::CPY_CURR_CLS_PREFIX . $assocurrrec->curriculumid)), html_writer::select($mdlcrsoptions, self::CPY_CURR_MDLCRS_PREFIX . $assocurrrec->curriculumid)); $table->rowclass[] = 'clus_cpy_row'; } } } // Add unassociated row to table. $table->data[] = array(get_string('usersetprogram_unassociated', 'local_elisprogram'), '', '', '', '', '', ''); $table->rowclass[] = 'clus_cpy_row unassigned'; // Get all curriculums, removing curricula that have already been listed. $curriculums = curriculum_get_listing($sort, $dir, 0, 0, '', '', $contexts); foreach ($curriculums as $curriculumid => $curriculumdata) { if (false === array_search($curriculumid, $curriculumshown)) { $checkboxids = "'" . self::CPY_CURR_PREFIX . $curriculumid . "',\n '" . self::CPY_CURR_TRK_PREFIX . $curriculumid . "',\n '" . self::CPY_CURR_CRS_PREFIX . $curriculumid . "',\n '" . self::CPY_CURR_CLS_PREFIX . $curriculumid . "'"; $togglecheckboxes = "cluster_copy_checkbox_changed(" . $checkboxids . ");"; $table->data[] = array('', format_string($curriculumdata->name), html_writer::checkbox(self::CPY_CURR_PREFIX . $curriculumid, 1, false, '', array('id' => self::CPY_CURR_PREFIX . $curriculumid, 'onclick' => $togglecheckboxes)), html_writer::checkbox(self::CPY_CURR_TRK_PREFIX . $curriculumid, 1, false, '', array('disabled' => true, 'id' => self::CPY_CURR_TRK_PREFIX . $curriculumid)), html_writer::checkbox(self::CPY_CURR_CRS_PREFIX . $curriculumid, 1, false, '', array('disabled' => true, 'id' => self::CPY_CURR_CRS_PREFIX . $curriculumid)), html_writer::checkbox(self::CPY_CURR_CLS_PREFIX . $curriculumid, 1, false, '', array('disabled' => true, 'id' => self::CPY_CURR_CLS_PREFIX . $curriculumid)), html_writer::select($mdlcrsoptions, self::CPY_CURR_MDLCRS_PREFIX . $curriculumid)); $table->rowclass[] = 'clus_cpy_row'; } } $currselectall = '<div class="currselectall">'; $currselectall .= '<a id="clus_currcpy_select_all" onclick="cluster_copycurriculum_set_all_selected()">'; $currselectall .= get_string('selectall') . '</a></div>'; $trkselectall = '<div class="trkselectall"><a id="clus_trkcpy_select_all" onclick="cluster_copytrack_set_all_selected()">'; $trkselectall .= get_string('selectall') . '</a></div>'; $crsselectall = '<div class="crsselectall"><a id="clus_crscpy_select_all" onclick="cluster_copycourse_set_all_selected()">'; $crsselectall .= get_string('selectall') . '</a></div>'; $clsselectall = '<div class="clsselectall"><a id="clus_crscpy_select_all" onclick="cluster_copyclass_set_all_selected()">'; $clsselectall .= get_string('selectall') . '</a></div>'; $table->data[] = array('', '', $currselectall, $trkselectall, $crsselectall, $clsselectall); $table->rowclass[] = 'clus_cpy_row select_all_row'; echo html_writer::table($table); echo '<div class="clus_curr_cpy_save_exit">'; echo '<input type="submit" name="save" value="' . get_string('userset_saveexit', 'local_elisprogram') . '">'; echo '<div class="hidden">'; echo '<input type="hidden" name="id" value="' . $id . '">'; echo '<input type="hidden" name="s" value="clstcur">'; echo '<input type="hidden" name="action" value="copycurr">'; echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '">'; echo '</div>'; echo '</div>'; echo '</form>'; }