public function definition() { global $USER, $cm, $context; $error = false; $mform =& $this->_form; $mform->addElement('hidden', 'post_form', 'assignteachers'); if (!($school = praxe_get_school($this->schoolid))) { print_error('notallowedaction', 'praxe'); } $mform->addElement('hidden', 'teacher_school', $this->schoolid); $mform->addElement('static', 'static1', get_string('school', 'praxe'), s($school->name)); $ext = praxe_get_cohort_members(PRAXE_COHORT_EXTTEACHERS); //get_users_by_capability($context, 'mod/praxe:beexternalteacher', 'u.id, u.firstname, u.lastname','lastname, firstname', null, null, null, null, null, false); if (is_array($ext) && count($ext)) { if (is_array($used_ext = praxe_get_ext_teachers_at_school(null, $this->schoolid))) { foreach ($used_ext as $t) { if (isset($ext[$t->teacherid])) { unset($ext[$t->teacherid]); } } } if (!count($ext)) { $this->error = get_string('no_teachers_available', 'praxe'); } else { $options = array(); foreach ($ext as $h) { $options[$h->id] = s($h->firstname) . " " . s($h->lastname); } $mform->addElement('select', 'ext_teacher', get_string('extteacher', 'praxe'), $options); } } else { $this->error = get_string('no_teachers_available', 'praxe'); } $this->add_action_buttons(true, get_string('submit')); }
function definition() { global $USER, $context, $DB; /// Adding fields $mform =& $this->_form; $mform->addElement('hidden', 'post_form', 'addlocation'); $school = praxe_get_school($this->schoolid); $mform->addElement('hidden', 'school', $school->id); $mform->addElement('static', 'static_school', get_string('school', 'praxe'), s($school->name)); $teachers = praxe_get_ext_teachers_at_school(null, $this->schoolid); //print_object($teachers); if (count($teachers)) { $options = array(0 => '---'); foreach ($teachers as $t) { $options[$t->ext_teacher_id] = s($t->firstname) . ' ' . s($t->lastname); } $mform->addElement('select', 'teacher', get_string('teacher', 'praxe'), $options); } else { $mform->addElement('static', 'static_teacher', get_string('extteacher', 'praxe'), get_string('no_teachers_available', 'praxe')); } if (!$this->error) { $result = $DB->get_records('praxe_studyfields', null, 'name, shortcut'); $options = array(); foreach ($result as $sf) { $options[$sf->id] = $sf->name . " (" . $sf->shortcut . ")"; } $mform->addElement('select', 'studyfield', get_string('studyfield', 'praxe'), $options); $options = array(PRAXE_ISCED_1 => PRAXE_ISCED_1_TEXT, PRAXE_ISCED_2 => PRAXE_ISCED_2_TEXT, PRAXE_ISCED_3 => PRAXE_ISCED_3_TEXT); $mform->addElement('select', 'isced', get_string('iscedlevel', 'praxe'), $options); $mform->addElement('text', 'subject', get_string('subject', 'praxe'), array('size' => '64')); $mform->setType('subject', PARAM_TEXT); $mform->addRule('subject', null, 'required', null, 'client'); $mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $actualyear = (int) date('Y', time()); $options = array($actualyear => $actualyear, $actualyear + 1 => $actualyear + 1, $actualyear + 2 => $actualyear + 2); $mform->addElement('select', 'year', get_string('year', 'praxe'), $options); /// Adding the "term" select field to choose the summer term/winter term for current course $options = array(PRAXE_TERM_WS => PRAXE_TERM_WS_TEXT, PRAXE_TERM_SS => PRAXE_TERM_SS_TEXT); $mform->addElement('select', 'term', get_string('term', 'praxe'), $options); $act = $mform->addElement('selectyesno', 'active', get_string('active', 'praxe')); $mform->setDefault('active', 1); $this->add_action_buttons(true, get_string('submit')); } }
/** * * @param int $headm [optional][default null] * @param int $schoolid [optional][default null] * @return string - if no records, returns empty string */ public static function school_teachers_by_schools($headm = null, $schoolid = null) { $ret = ''; $ext = praxe_get_ext_teachers_at_school($headm, $schoolid); if (!$ext) { return get_string('no_teachers_for_this_school', 'praxe'); } $arr = array(); foreach ($ext as $id => $teach) { if (!isset($arr[$teach->schoolid])) { $arr[$teach->schoolid] = new stdClass(); $arr[$teach->schoolid]->name = $teach->name; $arr[$teach->schoolid]->street = $teach->street; $arr[$teach->schoolid]->teachers = array(); } $arr[$teach->schoolid]->teachers[$id] = new stdClass(); $arr[$teach->schoolid]->teachers[$id]->firstname = $teach->firstname; $arr[$teach->schoolid]->teachers[$id]->lastname = $teach->lastname; $arr[$teach->schoolid]->teachers[$id]->id = $teach->teacherid; } $strstud = get_string('firstname') . ' / ' . get_string('lastname'); $strloc = get_string('locations', 'praxe'); $table = new html_table(); $table->head = array($strstud); $table->align = array('left'); foreach ($arr as $sch) { $data = array(); foreach ($sch->teachers as $teach) { if (is_null($teach->id)) { continue; } $data[] = array(praxe_get_user_fullname($teach->id)); } if (count($data)) { $table->data = $data; if (is_null($schoolid)) { $ret .= '<h3>' . s($sch->name) . '</h3>'; } $ret .= html_writer::table($table); } } return $ret; }