コード例 #1
0
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'trackid');
     $mform->addElement('hidden', 'classid');
     $mform->addElement('advcheckbox', 'autoenrol', null, get_string('auto_enrol_cluster_curriculum', 'block_curr_admin'), null, array('0', '1'));
     $mform->setDefault('autoenrol', '1');
     $mform->setHelpButton('autoenrol', array('clustercurriculumform/autoenrol', get_string('auto_enrol', 'block_curr_admin'), 'block_curr_admin'));
     $this->add_action_buttons();
 }
コード例 #2
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'userid');
     $mform->setType('userid', PARAM_INT);
     $mform->addElement('hidden', 'clusterid');
     $mform->setType('clusterid', PARAM_INT);
     $this->add_action_buttons();
     parent::definition();
 }
コード例 #3
0
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $data = $this->_customdata[0];
     $mform->addElement('hidden', 'id');
     $limit_group[] = $mform->addElement('static', 'lbl_classlimit', get_string('class_limit', 'block_curr_admin') . ':', $data->limit);
     $mform->addElement('static', 'lbl_enroled', get_string('enroled', 'block_curr_admin') . ': ', $data->enroled);
     $mform->addElement('static', 'lbl_num_waitlist', get_string('num_waitlist', 'block_curr_admin') . ': ', $data->waitlisted);
     $mform->addElement('static', 'lbl_enrol_confirmation', '', get_string('enrol_confirmation', 'block_curr_admin', $data->a));
     $this->add_action_buttons(true, get_string('enrol', 'block_curr_admin'));
 }
コード例 #4
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'userid');
     $mform->addElement('hidden', 'clusterid');
     $mform->addElement('advcheckbox', 'autoenrol', get_string('cluster_manual_autoenrol_label', 'block_curr_admin'));
     $mform->addElement('static', '', '', get_string('cluster_manual_autoenrol_help', 'block_curr_admin'));
     $mform->addElement('advcheckbox', 'leader', get_string('cluster_manual_leader_label', 'block_curr_admin'));
     $mform->addElement('static', '', '', get_string('cluster_manual_leader_help', 'block_curr_admin'));
     $this->add_action_buttons();
     parent::definition();
 }
コード例 #5
0
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'trackid');
     $mform->setType('trackid', PARAM_INT);
     $mform->addElement('hidden', 'clusterid');
     $mform->setType('clusterid', PARAM_INT);
     $mform->addElement('advcheckbox', 'autoenrol', null, get_string('usersettrack_auto_enrol', 'local_elisprogram'), null, array('0', '1'));
     $mform->setDefault('autoenrol', '1');
     $mform->addHelpButton('autoenrol', 'usersettrackform:autoenrol', 'local_elisprogram');
     $this->add_action_buttons();
 }
コード例 #6
0
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $data = $this->_customdata[0];
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $limit_group[] = $mform->addElement('static', 'lbl_classlimit', get_string('class_limit', 'local_elisprogram') . ':', $data->limit);
     $mform->addElement('static', 'lbl_enroled', get_string('enroled', 'local_elisprogram') . ': ', $data->enroled);
     $mform->addElement('static', 'lbl_num_waitlist', get_string('num_waitlist', 'local_elisprogram') . ': ', $data->waitlisted);
     $mform->addElement('static', 'lbl_enrol_confirmation', '', get_string('enrol_confirmation', 'local_elisprogram', $data->a));
     $this->add_action_buttons(true, get_string('btn_waitlist_add', 'local_elisprogram'));
 }
コード例 #7
0
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     if (!empty($this->_customdata['students'])) {
         $student_list = $this->_customdata['students'];
         $mform->addElement('header', 'waitlistaddform', get_string('waitinglistform_title', 'block_curr_admin'));
         foreach ($student_list as $student) {
             $mform->addElement('hidden', 'userid[' . $student->userid . ']', $student->userid);
             $mform->addElement('hidden', 'classid[' . $student->userid . ']', $student->classid);
             $mform->addElement('hidden', 'enrolmenttime[' . $student->userid . ']', $student->enrolmenttime);
             $enrol_options = array();
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('yes'), 1);
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('no'), 0);
             $context = get_context_instance(CONTEXT_SYSTEM);
             if (has_capability('block/curr_admin:overrideclasslimit', $context)) {
                 $mform->addElement('hidden', 'grade[' . $student->userid . ']', $student->grade);
                 $mform->addElement('hidden', 'credits[' . $student->credits . ']', $student->credits);
                 $mform->addElement('hidden', 'locked[' . $student->locked . ']', $student->locked);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('over_enrol', 'block_curr_admin'), 2);
             }
             $user = new user($student->userid);
             $name = new object();
             $name->name = $user->to_string();
             $name->username = $user->username;
             $mform->addGroup($enrol_options, 'options[' . $student->userid . ']', get_string('add_to_waitinglist', 'block_curr_admin', $name), '', false);
         }
     } else {
         if (!empty($this->_customdata['student_ids'])) {
             $student_id = $this->_customdata['student_ids'];
             foreach ($student_id as $id => $student) {
                 $mform->addElement('hidden', 'userid[' . $id . ']');
                 $mform->addElement('hidden', 'classid[' . $id . ']');
                 $mform->addElement('hidden', 'enrolmenttime[' . $id . ']');
                 $enrol_options = array();
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('yes'), 1);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('no'), 0);
                 $context = get_context_instance(CONTEXT_SYSTEM);
                 if (has_capability('block/curr_admin:overrideclasslimit', $context)) {
                     $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('over_enrol', 'block_curr_admin'), 2);
                 }
                 $name = 'no name';
                 $mform->addGroup($enrol_options, 'options[' . $id . ']', $name, '', false);
             }
         }
     }
     $mform->addElement('hidden', 'id');
     $mform->addElement('submit', 'submitbutton', 'Save');
 }
コード例 #8
0
 /**
  * items in the form
  */
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'trackid');
     $mform->addElement('hidden', 'classid');
     $mform->addElement('advcheckbox', 'autoenrol', null, get_string('auto_enrol_long', 'block_curr_admin'), null, array('0', '1'));
     $mform->setHelpButton('autoenrol', array('trackassignmentform/autoenrol', get_string('auto_enrol', 'block_curr_admin'), 'block_curr_admin'));
     if (isset($this->_customdata['obj'])) {
         $trackid = $this->_customdata['obj']->trackid;
         $aid = $this->_customdata['obj']->id;
         $mform->addElement('static', 'enrolall', null, "<button onclick=\"location.href=&quot;index.php?s=trkcls&amp;action=enrolall&amp;id={$trackid}&amp;association_id={$aid}&quot;; return false\"/>" . get_string('enrol_all_users_now', 'block_curr_admin') . '</button>');
     }
     $this->add_action_buttons();
 }
コード例 #9
0
 function definition()
 {
     global $CFG, $DB;
     parent::definition();
     $strrequired = get_string('required');
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $shortname = $mform->addElement('text', 'shortname', get_string('shortname', 'elisprogram_usetclassify'));
     $mform->setType('shortname', PARAM_TEXT);
     if (empty($this->_customdata['obj'])) {
         $mform->addRule('shortname', $strrequired, 'required', null, 'client');
     } else {
         $shortname->freeze();
     }
     $mform->addElement('text', 'name', get_string('name', 'elisprogram_usetclassify'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     $mform->addElement('advcheckbox', 'param_autoenrol_curricula', get_string('autoenrol_curricula', 'elisprogram_usetclassify'));
     $mform->addElement('advcheckbox', 'param_autoenrol_tracks', get_string('autoenrol_tracks', 'elisprogram_usetclassify'));
     $mform->addElement('advcheckbox', 'param_autoenrol_groups', get_string('autoenrol_groups', 'elisprogram_usetclassify'));
     $mform->addHelpButton('param_autoenrol_groups', 'usersetclassificationform:autoenrol_groups', 'elisprogram_usetclassify');
     $mform->addElement('advcheckbox', 'param_autoenrol_groupings', get_string('autoenrol_groupings', 'elisprogram_usetclassify'));
     $mform->addHelpButton('param_autoenrol_groupings', 'usersetclassificationform:autoenrol_groupings', 'elisprogram_usetclassify');
     // Add option for Alfresco shared organization space creation (if Alfresco code is present)
     if (file_exists($CFG->dirroot . '/repository/elisfiles/lib.php') && $DB->record_exists('config_plugins', array('plugin' => 'elisfiles'))) {
         $mform->addElement('advcheckbox', 'param_elis_files_shared_folder', get_string('elis_files_shared_folder', 'elisprogram_usetclassify'));
         $mform->addHelpButton('param_elis_files_shared_folder', 'usersetclassificationform:elis_files_shared_folder', 'elisprogram_usetclassify');
     }
     $recs = $DB->get_recordset(usersetclassification::TABLE, null, 'name ASC', 'shortname, name');
     //                                                  ($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0)
     $options = array('' => get_string('same_classification', 'elisprogram_usetclassify'));
     foreach ($recs as $rec) {
         $options[$rec->shortname] = $rec->name;
     }
     unset($recs);
     $mform->addElement('select', 'param_child_classification', get_string('child_classification', 'elisprogram_usetclassify'), $options);
     $this->add_action_buttons();
 }
コード例 #10
0
 function definition()
 {
     global $CFG, $CURMAN;
     parent::definition();
     $strrequired = get_string('required');
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('hidden', PARAM_INT);
     $shortname = $mform->addElement('text', 'shortname', get_string('shortname', 'crlm_cluster_classification'));
     if (empty($this->_customdata['obj'])) {
         $mform->addRule('shortname', $strrequired, 'required', null, 'client');
     } else {
         $shortname->freeze();
     }
     $mform->addElement('text', 'name', get_string('name', 'crlm_cluster_classification'));
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     $mform->addElement('advcheckbox', 'param_autoenrol_curricula', get_string('autoenrol_curricula', 'crlm_cluster_classification'));
     $mform->addElement('advcheckbox', 'param_autoenrol_tracks', get_string('autoenrol_tracks', 'crlm_cluster_classification'));
     $mform->addElement('advcheckbox', 'param_autoenrol_groups', get_string('autoenrol_groups', 'crlm_cluster_classification'));
     $mform->setHelpButton('param_autoenrol_groups', array('autoenrol_groups', get_string('autoenrol_groups', 'crlm_cluster_classification'), 'crlm_cluster_classification'));
     $mform->addElement('advcheckbox', 'param_autoenrol_groupings', get_string('autoenrol_groupings', 'crlm_cluster_classification'));
     $mform->setHelpButton('param_autoenrol_groupings', array('autoenrol_groupings', get_string('autoenrol_groupings', 'crlm_cluster_classification'), 'crlm_cluster_classification'));
     // Add option for Alfresco shared organization space creation (if Alfresco code is present)
     if (file_exists($CFG->dirroot . '/file/repository/alfresco/repository.php') && record_exists('block', 'name', 'repository')) {
         $mform->addElement('advcheckbox', 'param_alfresco_shared_folder', get_string('alfresco_shared_folder', 'crlm_cluster_classification'));
         $button = array('alfresco_shared_folder', get_string('alfresco_shared_folder', 'crlm_cluster_classification'), 'crlm_cluster_classification');
         $mform->setHelpButton('param_alfresco_shared_folder', $button);
     }
     $recs = $CURMAN->db->get_records(CLUSTERCLASSTABLE, '', '', 'name ASC', 'shortname, name');
     $options = array('' => get_string('same_classification', 'crlm_cluster_classification'));
     if ($recs) {
         foreach ($recs as $rec) {
             $options[$rec->shortname] = $rec->name;
         }
     }
     $mform->addElement('select', 'param_child_classification', get_string('child_classification', 'crlm_cluster_classification'), $options);
     $this->add_action_buttons();
 }
コード例 #11
0
 public function definition()
 {
     global $CURMAN, $CFG;
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'confirm');
     $mform->setDefault('confirm', md5($this->_customdata['obj']->id));
     $radioarray = array();
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('deletesubs', 'block_curr_admin'), 1);
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('promotesubs', 'block_curr_admin'), 2);
     $mform->addGroup($radioarray, 'deletesubs', '', '<br />', false);
     $mform->setDefault('deletesubs', 2);
     $this->add_action_buttons();
 }
コード例 #12
0
 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();
 }
コード例 #13
0
ファイル: pmclassform.class.php プロジェクト: jamesmcq/elis
 function definition()
 {
     global $USER, $CFG, $DB, $PAGE;
     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) && $obj->starttimeminute < 61 && $obj->starttimehour < 25) {
             $this->set_data(array('starttime' => array('minute' => $obj->starttimeminute, 'hour' => $obj->starttimehour)));
         }
         if (isset($obj->endtimeminute) && isset($obj->endtimehour) && $obj->endtimeminute < 61 && $obj->endtimehour < 25) {
             $this->set_data(array('endtime' => array('minute' => $obj->endtimeminute, 'hour' => $obj->endtimehour)));
         }
     }
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     // 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)) {
             // This is necessary for creating a new class instance but will prevent a parent course from appearing
             // when the user has class edit permissions but not class creation permission -- ELIS-5954
             $contexts = get_contexts_by_capability_for_user('course', 'local/elisprogram:class_create', $USER->id);
             // get listing of available ELIS courses
             $courses = course_get_listing('name', 'ASC', 0, 0, '', '', $contexts);
             // Detect if we are editing an existing class instance by checking for an value in the 'id' element
             $elm = $mform->_elements[$mform->_elementIndex['id']];
             $id = $elm->getValue();
             if (!empty($id)) {
                 // Make sure that the parent course for this class is always included otherwise the display is messed up
                 // and hitting the form Cancel button causes a DB error -- ELIS-5954
                 $pmclass = new pmclass($id);
                 $courses = array_merge($courses, course_get_listing('name', 'ASC', 0, 0, $pmclass->course->idnumber));
             }
         }
         // Add course select
         $attributes = array('onchange' => 'update_trk_multiselect(); update_crs_template();');
         $selections = array();
         if (!empty($courses)) {
             foreach ($courses as $course) {
                 $selections[$course->id] = '(' . $course->idnumber . ')' . $course->name;
             }
         }
         $mform->addElement('select', 'courseid', get_string('course', 'local_elisprogram') . ':', $selections, $attributes);
         $mform->addHelpButton('courseid', 'pmclassform:course', 'local_elisprogram');
         $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', 'local_elisprogram') . ':');
         // 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->addHelpButton('courseid', 'pmclassform:course', 'local_elisprogram');
         $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
     // Set any associated Moodle course for this class instance
     if (empty($this->_customdata['obj']->moodlecourseid) && !empty($this->_customdata['obj']->id)) {
         $this->_customdata['obj']->moodlecourseid = moodle_get_course($this->_customdata['obj']->id);
     }
     $mform->addElement('text', 'idnumber', get_string('class_idnumber', 'local_elisprogram') . ':');
     $mform->setType('idnumber', PARAM_TEXT);
     $mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client');
     $mform->addRule('idnumber', null, 'maxlength', 100, 'client');
     $mform->addHelpButton('idnumber', 'pmclassform:class_idnumber', 'local_elisprogram');
     $mform->addElement('date_selector', 'startdate', get_string('class_startdate', 'local_elisprogram') . ':', array('optional' => true, 'disabled' => 'disabled'));
     $mform->addHelpButton('startdate', 'pmclassform:class_startdate', 'local_elisprogram');
     $mform->addElement('date_selector', 'enddate', get_string('class_enddate', 'local_elisprogram') . ':', array('optional' => true));
     if (!isset($obj->starttimehour) || $obj->starttimehour >= 25 || !isset($obj->starttimeminute) || $obj->starttimeminute >= 61) {
         $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     } else {
         $mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     }
     $mform->addHelpButton('starttime', 'pmclassform:class_starttime', 'local_elisprogram');
     // Do the same thing for the endtime
     if (!isset($obj->endtimehour) || $obj->endtimehour >= 25 || !isset($obj->endtimeminute) || $obj->endtimeminute >= 61) {
         $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     } else {
         $mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'local_elisprogram') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => elis::$config->local_elisprogram->time_format_12h));
     }
     $mform->addElement('text', 'maxstudents', get_string('class_maxstudents', 'local_elisprogram') . ':');
     $mform->setType('maxstudents', PARAM_INT);
     $mform->addHelpButton('maxstudents', 'pmclassform:class_maxstudents', 'local_elisprogram');
     // Course selector
     if (empty($this->_customdata['obj']->moodlecourseid)) {
         $this->add_moodle_course_select();
     } else {
         $PAGE->requires->js('/local/elisprogram/js/classform.js');
         $courseSelected = array();
         $coursename = $DB->get_field('course', 'fullname', array('id' => $this->_customdata['obj']->moodlecourseid));
         $courseSelected[] = $mform->createElement('static', 'class_attached_course', get_string('class_attached_course', 'local_elisprogram') . ':', "<a href=\"{$CFG->wwwroot}/course/view.php?id={$this->_customdata['obj']->moodlecourseid}\">{$coursename}</a>");
         //only show checkbox if current action is edit
         $current_action = optional_param('action', 'view', PARAM_ALPHA);
         if ($current_action == 'edit') {
             $options = array();
             //set group to null
             $options['group'] = null;
             $options['onclick'] = "return class_confirm_unlink(this,'" . get_string('class_unlink_confirm', 'local_elisprogram') . "')";
             $courseSelected[] = $mform->createElement('advcheckbox', 'unlink_attached_course', get_string('class_unlink_attached_course', 'local_elisprogram') . ':', get_string('class_unlink_attached_course', 'local_elisprogram'), $options);
         }
         $mform->addGroup($courseSelected, 'courseSelected', get_string('class_attached_course', 'local_elisprogram') . ':');
         $mform->addHelpButton('courseSelected', 'pmclassform:moodlecourse', 'local_elisprogram');
         $mform->addElement('hidden', 'moodlecourseid');
         $mform->setType('moodlecourseid', PARAM_INT);
     }
     $mform->addElement('advcheckbox', 'enrol_from_waitlist', get_string('waitlistenrol', 'local_elisprogram') . ':');
     $mform->addHelpButton('enrol_from_waitlist', 'pmclassform:waitlistenrol', 'local_elisprogram');
     // custom fields
     $this->add_custom_fields('class', 'local/elisprogram:class_edit', 'local/elisprogram:class_view', 'course');
     $this->add_action_buttons();
 }
コード例 #14
0
ファイル: userform.class.php プロジェクト: jamesmcq/elis
 public function definition()
 {
     global $USER, $CFG, $COURSE;
     //determine if this is a create or a view / edit
     if ($this->_customdata['obj'] && isset($this->_customdata['obj']->id)) {
         //view / edit
         $disabled = true;
         if (!empty($this->_customdata['obj']->birthdate)) {
             list($this->_customdata['obj']->birthyear, $this->_customdata['obj']->birthmonth, $this->_customdata['obj']->birthday) = sscanf($this->_customdata['obj']->birthdate, '%d/%d/%d');
         }
     } else {
         //create
         $disabled = false;
     }
     parent::definition();
     $mform =& $this->_form;
     $strgeneral = get_string('general');
     $strrequired = get_string('required');
     $bundle = NULL;
     /// Add some extra hidden fields
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'search');
     $mform->setType('search', PARAM_TEXT);
     $mform->addElement('text', 'idnumber', get_string('idnumber'));
     $mform->setType('idnumber', PARAM_TEXT);
     $mform->addRule('idnumber', null, 'required', null, 'client');
     $mform->addRule('idnumber', null, 'maxlength', 255);
     $mform->addHelpButton('idnumber', 'useridnumber', 'local_elisprogram');
     $username_group = array();
     if (empty($disabled)) {
         //create
         $username_group[] =& $mform->createElement('text', 'username', get_string('username'));
         $username_group[] =& $mform->createElement('checkbox', 'id_same_user', null, get_string('id_same_as_user', 'local_elisprogram'));
         $mform->disabledIf('username_group', 'id_same_user', 'checked');
         $mform->addGroup($username_group, 'username_group', get_string('username'), ' ', false);
         $mform->addRule('username_group', $strrequired, 'required', null, 'client');
         $mform->setType('username', PARAM_TEXT);
     } else {
         //view / edit
         $username_group[] =& $mform->createElement('static', 'username');
         $mform->addGroup($username_group, 'username_group', get_string('username'), ' ', false);
         $mform->freeze('username_group');
     }
     $mform->addGroupRule('username_group', array('username' => array(array(null, 'maxlength', 100))));
     $mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'));
     $mform->setType('newpassword', PARAM_TEXT);
     $mform->addRule('newpassword', null, 'maxlength', 25);
     $mform->addElement('text', 'firstname', get_string('firstname'));
     $mform->setType('firstname', PARAM_TEXT);
     $mform->addRule('firstname', $strrequired, 'required', null, 'client');
     $mform->addRule('firstname', null, 'maxlength', 100);
     $mform->addElement('text', 'lastname', get_string('lastname'));
     $mform->setType('lastname', PARAM_TEXT);
     $mform->addRule('lastname', $strrequired, 'required', null, 'client');
     $mform->addRule('lastname', null, 'maxlength', 100);
     $mform->addElement('text', 'mi', get_string('usermi', 'local_elisprogram'));
     $mform->setType('mi', PARAM_TEXT);
     $mform->addRule('mi', null, 'maxlength', 100);
     $mform->addElement('text', 'email', get_string('email'));
     $mform->setType('email', PARAM_TEXT);
     $mform->addRule('email', null, 'email', null, 'client');
     $mform->addRule('email', null, 'required', null, 'client');
     $mform->addRule('email', null, 'maxlength', 100);
     $mform->addElement('text', 'email2', get_string('email2', 'local_elisprogram'));
     $mform->setType('email2', PARAM_TEXT);
     $mform->addRule('email2', null, 'email', null, 'client');
     $mform->addRule('email2', null, 'maxlength', 100);
     $mform->addElement('text', 'address', get_string('address', 'local_elisprogram'));
     $mform->setType('address', PARAM_TEXT);
     $mform->addRule('address', null, 'maxlength', 100);
     $mform->addElement('text', 'address2', get_string('address2', 'local_elisprogram'));
     $mform->setType('address2', PARAM_TEXT);
     $mform->addRule('address2', null, 'maxlength', 100);
     $mform->addElement('text', 'city', get_string('city'));
     $mform->setType('city', PARAM_TEXT);
     $mform->addRule('city', null, 'maxlength', 100);
     $mform->addElement('text', 'state', get_string('state'));
     $mform->setType('state', PARAM_TEXT);
     $mform->addRule('state', null, 'maxlength', 100);
     $mform->addElement('text', 'postalcode', get_string('postalcode', 'local_elisprogram'));
     $mform->setType('postalcode', PARAM_TEXT);
     $mform->addRule('postalcode', null, 'maxlength', 32);
     $country = get_string_manager()->get_list_of_countries();
     $default_country[''] = get_string('selectacountry');
     $country = array_merge($default_country, $country);
     $mform->addElement('select', 'country', get_string('country'), $country);
     $mform->addElement('text', 'phone', get_string('phone'));
     $mform->setType('phone', PARAM_TEXT);
     $mform->addRule('phone', null, 'maxlength', 100);
     $mform->addElement('text', 'phone2', get_string('phone2', 'local_elisprogram'));
     $mform->setType('phone2', PARAM_TEXT);
     $mform->addRule('phone2', null, 'maxlength', 100);
     $mform->addElement('text', 'fax', get_string('fax', 'local_elisprogram'));
     $mform->setType('fax', PARAM_TEXT);
     $mform->addRule('fax', null, 'maxlength', 100);
     $bdaygroup = array();
     $days[''] = get_string('day', 'form');
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = $i;
     }
     $months[''] = get_string('month', 'form');
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
     }
     $years[''] = get_string('year', 'form');
     for ($i = 1900; $i <= 2020; $i++) {
         $years[$i] = $i;
     }
     $bdaygroup[] =& $mform->createElement('select', 'birthday', get_string('day', 'form'), $days, '', true);
     $bdaygroup[] =& $mform->createElement('select', 'birthmonth', get_string('month', 'form'), $months, '', true);
     $bdaygroup[] =& $mform->createElement('select', 'birthyear', get_string('year', 'form'), $years, '', true);
     $mform->addGroup($bdaygroup, 'birthdate', get_string('userbirthdate', 'local_elisprogram'), ' ', false);
     //$mform->addElement('date_selector', 'birthdate', get_string('userbirthdate', 'local_elisprogram')); // Note: date_selector limited to timestamp > 1970
     $radioarray = array();
     $radioarray[] =& $mform->createElement('radio', 'gender', '', get_string('male', 'local_elisprogram'), 'M');
     $radioarray[] =& $mform->createElement('radio', 'gender', '', get_string('female', 'local_elisprogram'), 'F');
     $mform->addGroup($radioarray, 'gender', get_string('usergender', 'local_elisprogram'), ' ', false);
     $language = get_string_manager()->get_list_of_translations(true);
     $mform->addElement('select', 'language', get_string('language'), $language);
     //$mform->setDefault('language', 'en');
     // ELIS-4041: ^^^ had to remove setDefault('language', 'en')
     //            'cause it never showed real language value always default?
     //            added method to userpage::get_default_object_for_add()
     $mform->addHelpButton('language', 'user_language', 'local_elisprogram');
     $mform->addElement('text', 'transfercredits', get_string('user_transfercredits', 'local_elisprogram'));
     $mform->setType('transfercredits', PARAM_INT);
     $mform->addHelpButton('transfercredits', 'user_transfercredits', 'local_elisprogram');
     $mform->addElement('textarea', 'comments', get_string('comments'));
     $mform->setType('comments', PARAM_CLEAN);
     $mform->addHelpButton('comments', 'user_comments', 'local_elisprogram');
     $mform->addElement('textarea', 'notes', get_string('user_notes', 'local_elisprogram'));
     $mform->setType('notes', PARAM_CLEAN);
     $mform->addHelpButton('notes', 'user_notes', 'local_elisprogram');
     $mform->addElement('advcheckbox', 'inactive', get_string('user_inactive', 'local_elisprogram'));
     $mform->setType('inactive', PARAM_TEXT);
     $mform->addHelpButton('inactive', 'user_inactive', 'local_elisprogram');
     $this->add_custom_fields('user', 'local/elisprogram:user_edit', 'local/elisprogram:user_view');
     $this->add_action_buttons();
 }
コード例 #15
0
 public function definition()
 {
     parent::definition();
     $mform =& $this->_form;
     //config data setup
     $dataSet = array('curriculumid', 'courseid', 'id', 'availableCorequisites', 'existingCorequisites', 'association_id');
     foreach ($dataSet as $d) {
         if (isset($this->_customdata[$d])) {
             $data->{$d} = $this->_customdata[$d];
         } else {
             $data->{$d} = null;
         }
     }
     //add elements
     $mform->addElement('hidden', 'curriculum');
     $mform->setType('curriculum', PARAM_INT);
     $mform->addElement('hidden', 'course');
     $mform->setType('course', PARAM_INT);
     $mform->addElement('hidden', 'association_id', $data->association_id);
     $mform->setType('association_id', PARAM_INT);
     $mform->addElement('header', 'curriculumcourseeditform', get_string('edit_course_corequisites', 'block_curr_admin'));
     $select =& $mform->addElement('select', 'coreqs', get_string('available_course_corequisites', 'block_curr_admin'), $data->availableCorequisites);
     $select->setMultiple(true);
     $select =& $mform->addElement('select', 'scoreqs', get_string('existing_course_corequisites', 'block_curr_admin'), $data->existingCorequisites);
     $select->setMultiple(true);
     $mform->addElement('checkbox', 'add_to_curriculum', get_string('add_coreq_to_curriculum', 'block_curr_admin'));
     $group = array();
     $group[] =& $mform->createElement('submit', 'add', get_string('add_coreq', 'block_curr_admin'));
     $group[] =& $mform->createElement('submit', 'remove', get_string('remove_coreq', 'block_curr_admin'));
     $mform->addGroup($group, 'submitbuttons', '', '', false);
     $mform->addElement('cancel', 'exit', get_string('exit', 'block_curr_admin'));
 }
コード例 #16
0
ファイル: usersetform.class.php プロジェクト: jamesmcq/elis
 public function definition()
 {
     global $CURMAN, $CFG;
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'confirm');
     $mform->setDefault('confirm', 1);
     $mform->setType('confirm', PARAM_INT);
     $radioarray = array();
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('deletesubs', 'local_elisprogram'), 1);
     $radioarray[] =& $mform->createElement('radio', 'deletesubs', '', get_string('promotesubs', 'local_elisprogram'), 0);
     $mform->addGroup($radioarray, 'deletesubs', '', '<br />', false);
     $mform->setDefault('deletesubs', 0);
     $this->add_action_buttons();
 }
コード例 #17
0
ファイル: waitlistform.class.php プロジェクト: jamesmcq/elis
 public function definition()
 {
     global $DB;
     parent::definition();
     $mform =& $this->_form;
     if (!empty($this->_customdata['students'])) {
         $student_list = $this->_customdata['students'];
         $mform->addElement('header', 'waitlistaddform', get_string('waitinglistform_title', 'local_elisprogram'));
         foreach ($student_list as $student) {
             $mform->addElement('hidden', 'userid[' . $student->userid . ']', $student->userid);
             $mform->setType('userid[' . $student->userid . ']', PARAM_INT);
             $mform->addElement('hidden', 'classid[' . $student->userid . ']', $student->classid);
             $mform->setType('classid[' . $student->userid . ']', PARAM_INT);
             $mform->addElement('hidden', 'enrolmenttime[' . $student->userid . ']', $student->enrolmenttime);
             $mform->setType('enrolmenttime[' . $student->userid . ']', PARAM_INT);
             $enrol_options = array();
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('yes'), 1);
             $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('no'), 0);
             $context = context_system::instance();
             if (has_capability('local/elisprogram:overrideclasslimit', $context)) {
                 $mform->addElement('hidden', 'grade[' . $student->userid . ']', $student->grade);
                 $mform->setType('grade[' . $student->userid . ']', PARAM_INT);
                 $mform->addElement('hidden', 'credits[' . $student->credits . ']', $student->credits);
                 $mform->setType('credits[' . $student->credits . ']', PARAM_INT);
                 $mform->addElement('hidden', 'locked[' . $student->locked . ']', $student->locked);
                 $mform->setType('locked[' . $student->locked . ']', PARAM_INT);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $student->userid . ']', '', get_string('over_enrol', 'local_elisprogram'), 2);
             }
             $user = new stdClass();
             $user->name = '?';
             if ($tmpuser = new user($student->userid)) {
                 $tmpuser->load();
                 $user = $tmpuser->to_object();
                 $user->name = $tmpuser->moodle_fullname();
             }
             $mform->addGroup($enrol_options, 'options[' . $student->userid . ']', get_string('add_to_waitinglist', 'local_elisprogram', $user), array('&nbsp;&nbsp;&nbsp;'), false);
         }
     } else {
         if (!empty($this->_customdata['student_ids'])) {
             $student_id = $this->_customdata['student_ids'];
             foreach ($student_id as $id => $student) {
                 $mform->addElement('hidden', 'userid[' . $id . ']');
                 $mform->setType('userid[' . $id . ']', PARAM_INT);
                 $mform->addElement('hidden', 'classid[' . $id . ']');
                 $mform->setType('classid[' . $id . ']', PARAM_INT);
                 $mform->addElement('hidden', 'enrolmenttime[' . $id . ']');
                 $mform->setType('enrolmenttime[' . $id . ']', PARAM_INT);
                 $enrol_options = array();
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('yes'), 1);
                 $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('no'), 0);
                 $context = context_system::instance();
                 if (has_capability('local/elisprogram:overrideclasslimit', $context)) {
                     $enrol_options[] = $mform->createElement('radio', 'enrol[' . $id . ']', '', get_string('over_enrol', 'local_elisprogram'), 2);
                 }
                 $name = 'no name';
                 $mform->addGroup($enrol_options, 'options[' . $id . ']', $name, '', false);
             }
         }
     }
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('submit', 'submitbutton', 'Save');
 }