public function definition() { global $USER, $cm; if (is_array($locations = praxe_get_available_locations($USER->id, praxe_record::getData('isced'), praxe_record::getData('studyfield'))) && count($locations)) { //$mform =& $this->_form; $this->content_before_form .= get_string('assigntolocation_text_forstudents', 'praxe'); $form = '<form class="mform" action="' . praxe_get_base_url() . '" method="post">'; $form .= '<input type="hidden" name="post_form" value="assignlocation" />'; $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; $table = new stdClass(); $table->head = array('', get_string('school', 'praxe'), get_string('subject', 'praxe'), get_string('teacher', 'praxe')); $table->align = array('center', 'left', 'center', 'center'); foreach ($locations as $loc) { $row = array('<input id="praxe_loc_' . $loc->id . '" type="radio" name="location" value="' . $loc->id . '" />'); $sch = "<a href=\"" . praxe_get_base_url(array('viewaction' => 'viewschool', 'schoolid' => $loc->school)) . "\" title=\"" . get_string('school_detail', 'praxe') . "\">" . s($loc->name) . "</a>"; $sch .= "<div class=\"praxe_detail\">" . s($loc->street) . ', ' . s($loc->city) . "</div>"; $row[] = $sch; $row[] = s($loc->subject); if (!is_null($loc->teacherid)) { $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname)); $row[] = praxe_get_user_fullname($teacher); } else { $row[] = ''; } $table->data[] = $row; //$row .= '<label for="praxe_loc_'.$loc->id.'">'.$text.'</label>'; //$form .= "<div class=\"tr\">$row</div>"; } $form .= html_writer::table($table, true); $form .= '<div class="fitem center" style="margin: 10px 0;">' . '<input type="submit" id="id_submitbutton" value="Submit" name="submitbutton" /> ' . '<input type="submit" id="id_cancel" onclick="skipClientValidation = true; return true;" value="Cancel" name="cancel" />' . '</div>'; $form .= '</form>'; $this->content .= "<div>{$form}</div>"; //$mform->addElement('header', null, get_string('locations', 'praxe')); /* $options = array(); $radioarray = array(); foreach($locations as $loc) { //print_object($loc); $link = "<a target='_blank' href='view.php?id=$cm->id&praxeaction=viewschool&schoolid=$loc->school' title='".get_string('school_detail','praxe')."'>".get_string('school_detail','praxe')."</a>"; $text = s($loc->name) . "($link) - " . s($loc->subject); $text .= "<br>".s($loc->street).', '.s($loc->zip).' '.s($loc->city); if(!is_null($loc->teacherid)) { $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname)); $text .= " (".praxe_get_user_fullname($teacher).")"; } $radioarray[] = $mform->createElement('radio', 'location', null, $text, $loc->id, array('class'=>'radio location')); } $mform->addGroup($radioarray, 'location', get_string('locations','praxe').':', '<hr>', false); $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'client'); $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'server'); //$mform->addElement('select', 'location', get_string('chooselocation', 'praxe'), $options, array('size' => count($options) > 15 ? '15' : count($options)+1)); $mform->addElement('hidden', 'post_form', 'assigntolocation'); */ //$this->add_action_buttons(true, get_string('submit')); } else { $this->content_before_form .= get_string('nolocationsavailable', 'praxe'); } }
public function active_actual_user_records($userid, $praxeid = null, $order = null) { $ret = array(); if (is_null($praxeid)) { $praxeid = praxe_record::getData('id'); } $all = praxe_get_praxe_records($praxeid, $order, null, null, true); if (is_array($all)) { foreach ($all as $k => $rec) { if ($rec->teacherid == $userid) { $ret[] = $rec; } } } return $ret; }
public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'post_form', 'makeschedule'); $mform->setType('post_form', PARAM_ALPHA); $attr = array("onchange" => "praxe.setscheduletimeend(this.name,this.value)"); $this->add_to_content(get_string('error_timeschedule', 'praxe'), true); $options = array('0' => '0.', '1' => '1.', '2' => '2.', '3' => '3.', '4' => '4.', '5' => '5.', '6' => '6.', '7' => '7.', '8' => '8.', '9' => '9.', '10' => '10.', '11' => '11.', '12' => '12.', '13' => '13.', '13' => '13.', '14' => '14.', '15' => '15.', '-1' => '---'); $mform->addElement('select', 'lesnumber', get_string('lesson_number', 'praxe'), $options); $options = array('startyear' => praxe_record::getData('year'), 'stopyear' => praxe_record::getData('year'), 'applydst' => true, 'optional' => false, 'step' => 5); $fields = array($mform->createElement('date_time_selector', 'timestart', get_string('lesson_start', 'praxe'), $options, $attr), $mform->createElement('date_time_selector', 'timeend', get_string('lesson_end', 'praxe'), $options)); $group = $mform->createElement('group', 'time', get_string('lesson_start', 'praxe') . '<br>' . get_string('lesson_end', 'praxe'), $fields, '<br>', false); $mform->addElement($group); $mform->addHelpButton('time', 'schedule-lessontime', 'praxe'); $starttime = time() + 24 * 60 * 60; $mform->setDefault('timestart', array('day' => date('j', $starttime), 'month' => date('n', $starttime), 'year' => praxe_record::getData('year'), 'hour' => 8, 'minute' => 0)); $mform->setDefault('timeend', array('day' => date('j', $starttime), 'month' => date('n', $starttime), 'year' => praxe_record::getData('year'), 'hour' => 8, 'minute' => 45)); switch (praxe_record::getData('isced')) { case PRAXE_ISCED_1: $options = array('1' => PRAXE_ISCED_1_TEXT . ' - 1.', '2' => PRAXE_ISCED_1_TEXT . ' - 2.', '3' => PRAXE_ISCED_1_TEXT . ' - 3.', '4' => PRAXE_ISCED_1_TEXT . ' - 4.', '5' => PRAXE_ISCED_1_TEXT . ' - 5.'); break; case PRAXE_ISCED_2: $options = array('6' => PRAXE_ISCED_2_TEXT . ' - 6.', '7' => PRAXE_ISCED_2_TEXT . ' - 7.', '8' => PRAXE_ISCED_2_TEXT . ' - 8.', '9' => PRAXE_ISCED_2_TEXT . ' - 9.'); break; case PRAXE_ISCED_1: $options = array('10' => PRAXE_ISCED_3_TEXT . ' - 1.', '11' => PRAXE_ISCED_3_TEXT . ' - 2.', '12' => PRAXE_ISCED_3_TEXT . ' - 3.', '13' => PRAXE_ISCED_3_TEXT . ' - 4.', '14' => PRAXE_ISCED_3_TEXT . ' - 5.'); break; default: $options = array('1' => PRAXE_ISCED_1_TEXT . ' - 1.', '2' => PRAXE_ISCED_1_TEXT . ' - 2.', '3' => PRAXE_ISCED_1_TEXT . ' - 3.', '4' => PRAXE_ISCED_1_TEXT . ' - 4.', '5' => PRAXE_ISCED_1_TEXT . ' - 5.', '6' => PRAXE_ISCED_2_TEXT . ' - 6.', '7' => PRAXE_ISCED_2_TEXT . ' - 7.', '8' => PRAXE_ISCED_2_TEXT . ' - 8.', '9' => PRAXE_ISCED_2_TEXT . ' - 9.', '10' => PRAXE_ISCED_3_TEXT . ' - 1.', '11' => PRAXE_ISCED_3_TEXT . ' - 2.', '12' => PRAXE_ISCED_3_TEXT . ' - 3.', '13' => PRAXE_ISCED_3_TEXT . ' - 4.', '14' => PRAXE_ISCED_3_TEXT . ' - 5.'); break; } $mform->addElement('select', 'yearclass', get_string('yearclass', 'praxe'), $options); $mform->addElement('text', 'schoolroom', get_string('schoolroom', 'praxe'), array('size' => '12')); $mform->addRule('schoolroom', get_string('error_schoolroom', 'praxe'), 'required', null, 'client'); $mform->setType('schoolroom', PARAM_ALPHANUMEXT); $mform->addElement('text', 'lessubject', get_string('subject', 'praxe'), array('size' => '64')); $mform->setDefault('lessubject', praxe_record::$data->location->subject); $mform->addRule('lessubject', null, 'required', null, 'client'); $mform->setType('lessubject', PARAM_TEXT); $mform->addElement('editor', 'lestheme', get_string('lesson_theme', 'praxe')); $mform->setType('lestheme', PARAM_RAW); $this->add_action_buttons(); }
public function show_all_students_records() { global $CFG; if ($records = praxe_get_praxe_records(praxe_record::getData('id'), null, null, null, true, false)) { require_once $CFG->dirroot . '/mod/praxe/view_extteacher.php'; $this->content .= praxe_view_extteacher::show_records($records); } else { $this->content .= get_string('no_praxe_records', 'praxe'); } }
$mail->mailToUser($emuser, $emfrom); } redirect(praxe_get_base_url(), $msg); } break; case 'makeschedule': $aErrors = array(); require_capability('mod/praxe:addstudentschedule', $context); require_once 'c_makeschedule.php'; $form = new praxe_makeschedule(); if ($fdata = $form->get_data()) { if ($fdata->lesnumber == -1) { $fdata->lesnumber = null; } $post = (object) array('timestart' => $fdata->timestart, 'timeend' => $fdata->timeend, 'lesnumber' => $fdata->lesnumber, 'yearclass' => $fdata->yearclass, 'schoolroom' => $fdata->schoolroom, 'lessubject' => $fdata->lessubject, 'lestheme' => $fdata->lestheme['text']); $post->record = praxe_record::getData('rec_id'); $redurl = praxe_get_base_url(array('mode' => $tab_modes['student'][PRAXE_TAB_STUDENT_SCHEDULE])); /// insert record /// if (empty($edit)) { $post->timecreated = time(); if ($DB->insert_record('praxe_schedules', $post)) { redirect($redurl, get_string('schedule_item_added', 'praxe')); } } else { $post->id = required_param('scheduleid', PARAM_INT); $post->timemodified = time(); if ($DB->update_record('praxe_schedules', $post)) { redirect($redurl, get_string('schedule_updated', 'praxe')); } } } else {
} break; case PRAXE_TAB_VIEW_EDITTEACHER: $viewschool = optional_param('schoolid', null, PARAM_INT); /// filter for schools and subtabs $filteractualloc = optional_param('factualloc', 0, PARAM_INT); ///filter for locations actual $filteryearloc = optional_param('fyearloc', 0, PARAM_INT); $viewtabrows[] = new tabobject(PRAXE_TAB_EDITTEACHER_HOME, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_HOME], get_string('records_list', 'praxe')); $viewtabrows[] = new tabobject(PRAXE_TAB_EDITTEACHER_SCHOOLS, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_SCHOOLS], get_string('schools', 'praxe')); if (praxe_has_capability('manageallincourse')) { $viewtabrows[] = new tabobject(PRAXE_TAB_EDITTEACHER_ADDSCHOOL, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_ADDSCHOOL], get_string('addschool', 'praxe')); } if ($tab == PRAXE_TAB_EDITTEACHER_HOME) { $recordid = optional_param('recordid', 0, PARAM_INT); $records = praxe_get_praxe_records(praxe_record::getData('id')); if ($records) { $options = array(); $options[0] = get_string('all'); foreach ($records as $rec) { $options[$rec->id] = $rec->schoolname . " - " . praxe_get_user_fullname($rec->teacherid) . " - " . $rec->subject . " - " . praxe_get_user_fullname($rec->student); } $sel = new single_select(praxe_get_base_url(array('mode' => $mode)), 'recordid', $options, $recordid, null, 'praxepop_recorddetail'); $sel->label = get_string('praxe', 'praxe'); $tab_content .= $OUTPUT->render($sel); } } if ($tab == PRAXE_TAB_EDITTEACHER_SCHOOLS || !is_null($viewschool)) { $activated[] = PRAXE_TAB_EDITTEACHER_SCHOOLS; /// school list exists /// if (is_array($schools = praxe_get_schools())) {
function praxe_record($userid) { global $cm, $course, $praxe, $DB; praxe_record::$data = $praxe; if ($result = $DB->get_records('praxe_records', array('praxe' => $praxe->id, 'student' => $userid), 'timecreated DESC')) { $result = array_shift($result); foreach ($result as $col => $val) { $name = "rec_{$col}"; praxe_record::$data->{$name} = $val; } praxe_record::$data->location = praxe_get_location($result->location); } if (is_numeric($praxe->studyfield)) { if ($stf = $DB->get_record('praxe_studyfields', array('id' => $praxe->studyfield))) { praxe_record::$data->studyfield_name = $stf->name; praxe_record::$data->studyfield_shortcut = $stf->shortcut; } } }
/** * Builds and returns the body of the email notification in html format. * * @param string $post * @param object $userto * @param array $linkstofoot array of objects containing: link, text * @return string The email text in HTML format */ private function makeMailHtml($post, $userto) { global $CFG, $cm, $OUTPUT; if ($userto->mailformat != 1) { // Needs to be HTML return ''; } $praxe = praxe_record::getData(); $site = get_site(); $posthtml = '<head>'; /*foreach ($CFG->stylesheets as $stylesheet) { $posthtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n"; }TODO*/ $posthtml .= '</head>'; $posthtml .= "\n<body id=\"email\">\n\n"; $posthtml .= '<div class="navbar">' . $OUTPUT->action_link($CFG->wwwroot . '/course/view.php?id=' . $this->course->id, $this->course->shortname) . " » " . $OUTPUT->action_link(praxe_get_base_url(), format_string($praxe->name, true)) . '</div>'; if (strlen($this->subject)) { $posthtml .= '<div class="subject">' . format_text($this->subject) . '</div>'; } if (strlen($post)) { $posthtml .= '<div class="message">' . format_text($post) . '</div>'; } $posthtml .= "<hr /><div class=\"mdl-align unsubscribelink\">"; foreach ($this->linkstofoot as $link) { $posthtml .= $OUTPUT->action_link($link->link, $link->text) . " "; } $posthtml .= "</div><div class=\"mdl-align unsubscribelink\">" . $OUTPUT->action_link($CFG->wwwroot, $site->shortname) . "</div>"; $posthtml .= '</body>'; return $posthtml; }
$f .= '<input type="submit" name="confirmsubmitbutton" value="' . get_string('confirm') . '" />'; $f .= ' <input type="submit" name="cancelbutton" value="' . get_string('cancel') . '" />'; $f .= '</div>'; $f .= '</form>'; $echo .= $f; } else { require_sesskey(); $post = (object) array('id' => $scheduleid, 'deleted' => 1); $DB->update_record('praxe_schedules', $post); redirect(praxe_get_base_url(array('mode' => 'schedule'))); } break; case 'confirmschedule': require_sesskey(); $teachermail = optional_param('mailtoextteacher', 0, PARAM_INT); $praxe = praxe_record::getData(); $schedules = $DB->get_records('praxe_schedules', array('record' => $praxe->rec_id)); if (empty($schedules)) { print_error('notallowedaction', 'praxe'); } $post = (object) array('id' => $praxe->rec_id, 'status' => PRAXE_STATUS_SCHEDULE_DONE); if ($DB->update_record('praxe_records', $post) && $teachermail == 1) { $emfrom = get_complete_user_data('id', $praxe->rec_student); require_once $CFG->dirroot . '/mod/praxe/mailing.php'; $mail = new praxe_mailing(); $fak = new stdClass(); $fak->name = fullname($emfrom); $fak->school = s($praxe->location->name); $mail->setSubject(get_string('confirmschedule_mailsubject', 'praxe')); $emtext = get_string('confirmschedule_mail', 'praxe', $fak); $mail->setPlain($emtext);
public function make_assigntolocation_form($edit = false) { global $CFG, $USER, $OUTPUT; $locations = praxe_get_available_locations($USER->id, praxe_record::getData('isced'), praxe_record::getData('studyfield')); if (!is_array($locations) || !count($locations)) { return get_string('nolocationsavailable', 'praxe'); } $form = '<form class="mform" action="' . praxe_get_base_url() . '" method="post">'; $form .= '<input type="hidden" name="post_form" value="assigntolocation" />'; $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; if ($edit) { $form .= '<input type="hidden" name="edit" value="changelocation" />'; } $table = new html_table(); $table->head = array('', get_string('school', 'praxe'), get_string('subject', 'praxe'), get_string('teacher', 'praxe')); $table->colclasses = array('praxe_cell center', 'praxe_cell left', 'praxe_cell center', 'praxe_cell center'); foreach ($locations as $loc) { $sch = $OUTPUT->action_link(praxe_get_base_url(array("viewaction" => 'viewschool', "schoolid" => $loc->school)), s($loc->name), null, array('title' => get_string('school_detail', 'praxe'))); $sch .= "<div class=\"praxe_detail\">" . s($loc->street) . ', ' . s($loc->city) . "</div>"; $row = array('<input id="praxe_loc_' . $loc->id . '" type="radio" name="location" value="' . $loc->id . '" />', $sch); $row[] = s($loc->subject); if (!is_null($loc->teacherid)) { $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname)); $row[] = praxe_get_user_fullname($teacher); } else { $row[] = ''; } $table->data[] = $row; } $form .= html_writer::table($table); $form .= '<div class="fitem center" style="margin: 10px 0;">' . '<input type="submit" id="id_submitbutton" value="' . get_string('submit') . '" name="submitbutton" />'; if ($edit) { $form .= ' <input type="submit" id="id_cancel" onclick="skipClientValidation = true; return true;" value="' . get_string('cancel') . '" name="cancel" />'; } $form .= '</div>'; $form .= '</form>'; return "<div>{$form}</div>"; }