/** * Returns human readable context identifier. * * @param boolean $withprefix whether to prefix the name of the context with User * @param boolean $short does not apply to user context * @return string the human readable context name. */ public function get_context_name($withprefix = true, $short = false) { global $DB; $name = ''; if ($user = new \user($this->_instanceid)) { $user->load(); if ($withprefix) { $name = get_string('user', 'local_elisprogram') . ': '; } $name .= $user->moodle_fullname(); } return $name; }
/** * Function to handle class not completed events. * * @param student $student The class enrolment / student object who is "not completed" * @uses $CFG * @uses $DB * @return boolean TRUE is successful, otherwise FALSE */ public static function class_notcompleted_handler($student) { global $CFG, $DB; require_once elispm::lib('notifications.php'); /// Does the user receive a notification? $sendtouser = elis::$config->local_elisprogram->notify_classnotcompleted_user; $sendtorole = elis::$config->local_elisprogram->notify_classnotcompleted_role; $sendtosupervisor = elis::$config->local_elisprogram->notify_classnotcompleted_supervisor; /// If nobody receives a notification, we're done. if (!$sendtouser && !$sendtorole && !$sendtosupervisor) { return true; } if (!empty($student->moodlecourseid)) { if (!($context = context_course::instance($student->moodlecourseid))) { if (in_cron()) { mtrace(get_string('invalidcontext')); } else { debugging(get_string('invalidcontext')); } return true; } } else { $context = context_system::instance(); } $message = new notification(); /// Set up the text of the message $text = empty(elis::$config->local_elisprogram->notify_classnotcompleted_message) ? get_string('notifyclassnotcompletedmessagedef', self::LANG_FILE) : elis::$config->local_elisprogram->notify_classnotcompleted_message; $search = array('%%userenrolname%%', '%%classname%%', '%%coursename%%'); $user = new user($student->userid); if (!$user) { if (in_cron()) { mtrace(get_string('nouser', 'local_elisprogram')); } else { debugging(get_string('nouser', 'local_elisprogram')); } return true; } $user->load(); // Get course info $pmcourse = $DB->get_record(course::TABLE, array('id' => $student->courseid)); $pmclass = $DB->get_record(pmclass::TABLE, array('id' => $student->classid)); $replace = array($user->moodle_fullname(), $pmclass->idnumber, $pmcourse->name); $text = str_replace($search, $replace, $text); $eventlog = new Object(); $eventlog->event = 'class_notcompleted'; $eventlog->instance = $student->classid; $eventlog->fromuserid = $user->id; if ($sendtouser) { $message->send_notification($text, $user, null, $eventlog); } $users = array(); if ($sendtorole) { /// Get all users with the notify_classnotcomplete capability. if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_classnotcomplete')) { $users = $users + $roleusers; } } if ($sendtosupervisor) { /// Get parent-context users. if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_classnotcomplete')) { $users = $users + $supervisors; } } // Send notifications to any users who need to receive them. foreach ($users as $touser) { $message->send_notification($text, $touser, $user, $eventlog); } return true; }
/** * Return the HTML to edit a specific instructor. * This could be extended to allow for application specific editing, for example * a Moodle interface to its formslib. * * @param int $classid The class ID. * @param string $sort Field to sort on. * @param string $dir Direction of sort. * @param int $page The page to start at. * @param int $perpage Number of records per page. * @param string $namesearch Search string for item name. * @param string $alpha Start initial of item name filter. * @return string The form HTML, without the form. */ public function edit_form_html($classid, $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 30, $namesearch = '', $alpha = '') { global $CFG, $OUTPUT, $SESSION, $PAGE; $action = optional_param('action', '', PARAM_ALPHA); $this->classid = $classid; $output = ''; ob_start(); if (empty($this->id)) { $columns = array('assign' => array('header' => get_string('assign', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'idnumber' => array('header' => get_string('class_idnumber', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'name' => array('header' => get_string('tag_name', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'assigntime' => array('header' => get_string('assigntime', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'completetime' => array('header' => get_string('completion_time', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false)); } else { $columns = array('idnumber' => array('header' => get_string('class_idnumber', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'name' => array('header' => get_string('tag_name', self::LANG_FILE), 'display_function' => 'htmltab_display_function'), 'assigntime' => array('header' => get_string('assigntime', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false), 'completetime' => array('header' => get_string('completion_time', self::LANG_FILE), 'display_function' => 'htmltab_display_function', 'sortable' => false)); } if ($dir !== 'DESC') { $dir = 'ASC'; } if (isset($columns[$sort])) { $columns[$sort]['sortable'] = $dir; } else { $sort = 'name'; $columns[$sort]['sortable'] = $dir; } $newarr = array(); $users = array(); if (empty($this->id)) { $users = $this->get_users_avail($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $usercount = $this->count_users_avail($namesearch, $alpha); pmalphabox(new moodle_url('/local/elisprogram/index.php', array('s' => 'ins', 'section' => 'curr', 'action' => 'add', 'id' => $classid, 'sort' => $sort, 'dir' => $dir, 'perpage' => $perpage)), 'alpha', get_string('tag_name', self::LANG_FILE) . ':'); $pagingbar = new paging_bar($usercount, $page, $perpage, "index.php?s=ins&section=curr&id={$classid}&action=add&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&" . "search=" . urlencode($namesearch)); // TBD: .'&' echo $OUTPUT->render($pagingbar); flush(); } else { //error_log("instructor.class.php::edit_form_html(); userid = {$this->userid}"); $user = new stdClass(); $user->name = '?'; if ($tmpuser = new user($this->userid)) { $tmpuser->load(); $user = $tmpuser->to_object(); $user->name = $tmpuser->moodle_fullname(); } $users[] = $user; $usercount = 0; // TBD: 1 ??? } $has_users = is_array($users) && !empty($users) || $users instanceof Iterator && $users->valid() === true ? true : false; if (empty($this->id) && $has_users === false) { $table = NULL; } else { $insobj = new instructor(); //$table->width = "100%"; foreach ($users as $user) { $tabobj = new stdClass(); $assigntime = $this->assigntime; $completetime = $this->completetime; $selection = json_decode(retrieve_session_selection($user->id, 'add')); if ($selection) { $assigntime = pm_timestamp(0, 0, 0, $selection->enrolment_date->month, $selection->enrolment_date->day, $selection->enrolment_date->year); $completetime = pm_timestamp(0, 0, 0, $selection->completion_date->month, $selection->completion_date->day, $selection->completion_date->year); } /* **** debug code ob_start(); var_dump($user); $tmp = ob_get_contents(); ob_end_clean(); error_log("instructor.class.php::edit_form_html() user = $tmp"); **** */ foreach ($columns as $column => $cdesc) { switch ($column) { case 'assign': $tabobj->{$column} = '<input type="checkbox" id="checkbox' . $user->id . '" onClick="select_item(' . $user->id . ')" name="users[' . $user->id . '][assign]" value="1" ' . ($selection ? 'checked="checked"' : '') . '/>' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />'; break; case 'name': case 'idnumber': case 'description': $tabobj->{$column} = $user->{$column}; break; case 'assigntime': $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $assigntime, true); break; case 'completetime': $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $completetime, true); break; default: $tabobj->{$column} = ''; break; } } $newarr[] = $tabobj; //$table->data[] = $newarr; } $table = new display_table($newarr, $columns, get_pm_url(), 'sort', 'dir', array('id' => 'selectiontbl')); } unset($users); print_checkbox_selection($classid, 'ins', 'add'); if (empty($this->id)) { pmsearchbox(null, 'search', 'get', get_string('show_all_users', self::LANG_FILE)); echo '<form method="post" action="index.php?s=ins&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="savenew" />' . "\n"; } else { echo '<form method="post" action="index.php?s=ins&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="update" />' . "\n"; echo '<input type="hidden" name="association_id" value="' . $this->id . '" />' . "\n"; echo '<input type="hidden" name="id" value="' . $this->classid . '" />' . "\n"; echo '<input type="hidden" name="userid" value="' . $this->userid . '" />' . "\n"; } if (!empty($table) && !empty($newarr)) { if ($action == 'add') { $PAGE->requires->js('/local/elisprogram/js/classform.js'); echo '<input type="button" onclick="checkbox_select(true,\'[assign]\')" value="' . get_string('selectall') . '" /> '; echo '<input type="button" onclick="checkbox_select(false,\'[assign]\')" value="' . get_string('deselectall') . '" /> '; } echo $table->get_html(); $pagingbar = new paging_bar($usercount, $page, $perpage, "index.php?s=ins&section=curr&id={$classid}&action=add&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&" . "search=" . urlencode($namesearch)); // TBD: .'&' echo $OUTPUT->render($pagingbar); } if (empty($this->id)) { if ($has_users === false) { pmshowmatches($alpha, $namesearch); } echo '<br /><input type="submit" value="' . get_string('assign_selected', self::LANG_FILE) . '">' . "\n"; } else { echo '<br /><input type="submit" value="' . get_string('update_assignment', self::LANG_FILE) . '">' . "\n"; } echo '</form>' . "\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Function to handle curriculum not completed events. * */ public static function curriculum_notcompleted_handler($curstudent) { global $CFG, $DB; require_once elispm::lib('notifications.php'); /// Does the user receive a notification? $sendtouser = elis::$config->local_elisprogram->notify_curriculumnotcompleted_user; $sendtorole = elis::$config->local_elisprogram->notify_curriculumnotcompleted_role; $sendtosupervisor = elis::$config->local_elisprogram->notify_curriculumnotcompleted_supervisor; /// If nobody receives a notification, we're done. if (!$sendtouser && !$sendtorole && !$sendtosupervisor) { return true; } $context = context_system::instance(); // Send notifications $message = new notification(); /// Set up the text of the message $text = empty(elis::$config->local_elisprogram->notify_curriculumnotcompleted_message) ? get_string('notifycurriculumnotcompletedmessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_curriculumnotcompleted_message; $user = new user($curstudent->userid); if (!$user) { return true; } $user->load(); // Get course info $program = $DB->get_record(curriculum::TABLE, array('id' => $curstudent->curriculumid)); $search = array('%%userenrolname%%', '%%programname%%'); $replace = array($user->moodle_fullname(), $program->name); $text = str_replace($search, $replace, $text); $eventlog = new Object(); $eventlog->event = 'curriculum_notcompleted'; $eventlog->instance = $curstudent->id; /// Store the assignment id. $eventlog->fromuserid = $user->id; if ($sendtouser) { $message->send_notification($text, $user, null, $eventlog); } $users = array(); if ($sendtorole) { /// Get all users with the notify_curriculumnotcomplete capability. if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_programnotcomplete')) { $users = $users + $roleusers; } } if ($sendtosupervisor) { /// Get parent-context users. if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_programnotcomplete')) { $users = $users + $supervisors; } } foreach ($users as $u) { $message->send_notification($text, $u, $user, $eventlog); } return true; }
/** * Triggered when a track assignment takes place. * This function should use the CM configured values to send messages to appropriate users when a track assignment * takes place. Users will be ones configured for the context, which can include the user that is assigned and users * assigned to configured roles for that context. The message template used should be the one configured as well. * * @param object $eventdata the track assignment record * @return boolean success * */ function pm_notify_track_assign_handler($eventdata) { global $CFG, $DB, $USER; /// Does the user receive a notification? $sendtouser = isset(elis::$config->local_elisprogram->notify_trackenrol_user) ? elis::$config->local_elisprogram->notify_trackenrol_user : ''; $sendtorole = isset(elis::$config->local_elisprogram->notify_trackenrol_role) ? elis::$config->local_elisprogram->notify_trackenrol_role : ''; $sendtosupervisor = isset(elis::$config->local_elisprogram->notify_trackenrol_supervisor) ? elis::$config->local_elisprogram->notify_trackenrol_supervisor : ''; /// If nobody receives a notification, we're done. if (!$sendtouser && !$sendtorole && !$sendtosupervisor) { return true; } /// We get all context assigns, so check that this is a class. If not, we're done. $context = context_system::instance(); /// Make sure this is a valid user. $enroluser = new user($eventdata->userid); if (!$enroluser) { if (in_cron()) { mtrace(getstring('nouser', 'local_elisprogram')); } else { print_error('nouser', 'local_elisprogram'); } return true; } // Due to lazy loading, we need to pre-load this object $enroluser->load(); if (empty($enroluser->id)) { if (in_cron()) { mtrace(getstring('nouser', 'local_elisprogram')); } else { print_error('nouser', 'local_elisprogram'); } return true; } /// Get the track record from the track id. if (!($track = $DB->get_record('local_elisprogram_trk', array('id' => $eventdata->trackid)))) { if (in_cron()) { mtrace(get_string('notrack', 'local_elisprogram')); } else { print_error('notrack', 'local_elisprogram'); } return true; } $message = new notification(); /// Set up the text of the message $text = empty(elis::$config->local_elisprogram->notify_trackenrol_message) ? get_string('notifytrackenrolmessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_trackenrol_message; $search = array('%%userenrolname%%', '%%trackname%%'); $replace = array($enroluser->moodle_fullname(), $track->name); $text = str_replace($search, $replace, $text); if ($sendtouser) { $message->send_notification($text, $enroluser); } $users = array(); if ($sendtorole) { /// Get all users with the notify_trackenrol capability. if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_trackenrol')) { $users = $users + $roleusers; } } if ($sendtosupervisor) { /// Get parent-context users. if ($supervisors = pm_get_users_by_capability('user', $eventdata->userid, 'local/elisprogram:notify_trackenrol')) { $users = $users + $supervisors; } } foreach ($users as $user) { $message->send_notification($text, $user, $enroluser); } /// If you don't return true, the message queue will clog and no more will be sent. return true; }
/** * 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, $USER; require_once $CFG->dirroot . '/local/elisprogram/accesslib.php'; $filters = array(); $autocomplete_opts = array('report' => $this->get_report_shortname(), 'ui' => 'inline', 'contextlevel' => CONTEXT_ELIS_USER, 'instance_fields' => array('idnumber' => get_string('filter_autocomplete_idnumber', $this->lang_file), 'firstname' => get_string('filter_autocomplete_firstname', $this->lang_file), 'lastname' => get_string('filter_autocomplete_lastname', $this->lang_file), 'username' => get_string('filter_autocomplete_username', $this->lang_file)), 'custom_fields' => '*', 'label_template' => '[[firstname]] [[lastname]]', 'configurable' => true, 'required' => true); $permissions_filter = $this->get_user_permissions_filter('id', false); $autocomplete_opts['selection_enabled'] = !isset($permissions_filter->select) || $permissions_filter->select != 'FALSE' ? true : false; $autocomplete_opts['restriction_sql'] = $permissions_filter; $last_user = $this->get_chosen_userid(); $cm_user_id = empty($last_user) ? cm_get_crlmuserid($USER->id) : $last_user; if ($cm_user_id && ($cmuser = new user($cm_user_id))) { $cmuser->load(); $autocomplete_opts['defaults'] = array('label' => $cmuser->moodle_fullname(), 'id' => $cm_user_id); } $filters[] = new generalized_filter_entry('filterautoc', 'crlmuser', 'id', get_string('fld_fullname', 'local_eliscore'), false, 'autocomplete_eliswithcustomfields', $autocomplete_opts); $field_list = array('block_instance' => $this->id, 'reportname' => $this->get_report_shortname(), 'field_exceptions' => array('_elis_course_pretest', '_elis_course_posttest'), 'help' => array('individual_course_progress_field', get_string('displayname', $this->lang_file), $this->lang_file)); $filters[] = new generalized_filter_entry('field' . $this->id, 'field' . $this->id, 'id', get_string('selectcustomfields', $this->lang_file), false, 'custom_field_multiselect_values', $field_list); // column selection checkboxes $filters[] = new generalized_filter_entry('optional_columns', '', '', get_string('columns_options_heading', $this->lang_file), false, 'checkboxes', array('choices' => array('los' => get_string('los_label', $this->lang_file), 'totalscore' => get_string('totalscore_label', $this->lang_file), 'preposttest' => get_string('preposttest_label', $this->lang_file)), 'checked' => array('preposttest'), 'allowempty' => true, 'heading' => get_string('columns_options_heading', $this->lang_file), 'nofilter' => true, 'help' => array('optional_columns', get_string('displayname', $this->lang_file), $this->lang_file))); return $filters; }
/** * 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 * @uses $CFG * @uses $USER * @return array The list of available filters */ function get_filters($init_data = true) { global $CFG, $USER; require_once $CFG->dirroot . '/local/elisprogram/accesslib.php'; $filters = array(); $autocomplete_opts = array('report' => $this->get_report_shortname(), 'ui' => 'inline', 'contextlevel' => CONTEXT_ELIS_USER, 'instance_fields' => array('idnumber' => get_string('filter_autocomplete_idnumber', $this->lang_file), 'firstname' => get_string('filter_autocomplete_firstname', $this->lang_file), 'lastname' => get_string('filter_autocomplete_lastname', $this->lang_file), 'username' => get_string('filter_autocomplete_username', $this->lang_file)), 'custom_fields' => '*', 'label_template' => '[[firstname]] [[lastname]]', 'configurable' => true, 'required' => true, 'help' => array('individual_user_report', get_string('displayname', $this->lang_file), 'rlreport_individual_user')); $permissions_filter = $this->get_user_permissions_filter('id', false); $autocomplete_opts['selection_enabled'] = !isset($permissions_filter->select) || $permissions_filter->select != 'FALSE' ? true : false; $autocomplete_opts['restriction_sql'] = $permissions_filter; $last_user = $this->get_chosen_userid(); $cm_user_id = empty($last_user) ? cm_get_crlmuserid($USER->id) : $last_user; if ($cm_user_id && ($cmuser = new user($cm_user_id))) { $cmuser->load(); $autocomplete_opts['defaults'] = array('label' => $cmuser->moodle_fullname(), 'id' => $cm_user_id); } $filters[] = new generalized_filter_entry('userid', 'usr', 'id', get_string('fld_fullname', 'local_eliscore'), false, 'autocomplete_eliswithcustomfields', $autocomplete_opts); return $filters; }
/** * Function to handle course recurrence events. * * @param user $user CM user object representing the user in the course * * @return boolean TRUE is successful, otherwise FALSE */ public static function course_recurrence_handler($user) { global $DB; require_once elispm::lib('notifications.php'); /// Does the user receive a notification? $sendtouser = elis::$config->local_elisprogram->notify_courserecurrence_user; $sendtorole = elis::$config->local_elisprogram->notify_courserecurrence_role; $sendtosupervisor = elis::$config->local_elisprogram->notify_courserecurrence_supervisor; /// If nobody receives a notification, we're done. if (!$sendtouser && !$sendtorole && !$sendtosupervisor) { return true; } $context = context_system::instance(); /// Make sure this is a valid user. $enroluser = new user($user->userid); if (!$enroluser) { if (in_cron()) { mtrace(get_string('nouser', 'local_elisprogram')); } else { print_error('nouser', 'local_elisprogram'); } return true; } // Due to lazy loading, we need to pre-load this object $enroluser->load(); if (empty($enroluser->id)) { if (in_cron()) { mtrace(get_string('nouser', 'local_elisprogram')); } else { print_error('nouser', 'local_elisprogram'); } return true; } /// Set up the text of the message $message = new notification(); $text = empty(elis::$config->local_elisprogram->notify_courserecurrence_message) ? get_string('notifycourserecurrencemessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_courserecurrence_message; $search = array('%%userenrolname%%', '%%coursename%%'); $replace = array($enroluser->moodle_fullname(), $user->coursename); $text = str_replace($search, $replace, $text); $eventlog = new Object(); $eventlog->event = 'course_recurrence'; $eventlog->instance = $user->enrolmentid; $eventlog->fromuserid = $enroluser->id; if ($sendtouser) { $message->send_notification($text, $enroluser, null, $eventlog); } $users = array(); if ($sendtorole) { /// Get all users with the notify_courserecurrence capability. if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_courserecurrence')) { $users = $users + $roleusers; } } if ($sendtosupervisor) { /// Get parent-context users. if ($supervisors = pm_get_users_by_capability('user', $enroluser->id, 'local/elisprogram:notify_courserecurrence')) { $users = $users + $supervisors; } } foreach ($users as $u) { $message->send_notification($text, $u, $enroluser, $eventlog); } return true; }
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(' '), 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'); }