function praxe_view_extteacher()
 {
     global $CFG, $tab, $USER, $tab_modes, $context;
     switch ($tab) {
         case PRAXE_TAB_EXTTEACHER_HOME:
             require_capability('mod/praxe:viewrecordstoownlocation', $context);
             $detail = optional_param('recordid', 0, PARAM_INT);
             if ($detail > 0 && ($record = praxe_get_record($detail))) {
                 if ($record->teacherid != $USER->id) {
                     print_error('notallowedaction', 'praxe');
                 }
                 $schid = optional_param('scheduleid', 0, PARAM_INT);
                 if ($schid > 0 && ($schedule = praxe_get_schedule($schid))) {
                     $this->content .= self::show_schedule_detail($schedule) . "<hr>";
                 }
                 $this->content .= self::show_record_detail($record);
             } else {
                 $this->content .= self::show_records();
             }
             break;
         case PRAXE_TAB_EXTTEACHER_MYLOCATIONS:
             $factual = optional_param('factualloc', 0, PARAM_INT);
             $fyear = optional_param('fyearloc', 0, PARAM_INT);
             $this->content .= self::show_all_my_locations($factual, $fyear);
             break;
         case PRAXE_TAB_EXTTEACHER_MYSCHOOLS:
             $schoolid = optional_param('schoolid', 0, PARAM_INT);
             $schools = praxe_get_schools(null, $USER->id);
             if ($schoolid == 0) {
                 $this->content .= self::show_schools($schools);
             } else {
                 if (isset($schools[$schoolid])) {
                     require_once $CFG->dirroot . '/mod/praxe/view_headm.php';
                     $this->content .= praxe_view_headm::show_school($schoolid);
                 } else {
                     redirect(praxe_get_base_url(), get_string('notallowedaction', 'praxe'));
                 }
             }
             break;
         case PRAXE_TAB_EXTTEACHER_EDITLOCATION:
             $locid = required_param('locationid', PARAM_INT);
             if (!($loc = praxe_get_location($locid, $USER->id))) {
                 print_error('notallowedaction', 'praxe');
             }
             require_once $CFG->dirroot . '/mod/praxe/c_addlocation.php';
             $this->form = new praxe_addlocation($loc->school);
             $this->form->set_redirect_url(null, array('mode' => $tab_modes['extteacher'][PRAXE_TAB_EXTTEACHER_MYLOCATIONS]));
             $this->form->set_form_to_edit($loc);
             break;
         case PRAXE_TAB_EXTTEACHER_COPYLOCATION:
             // TODO
             break;
         default:
             break;
     }
 }
 public function definition()
 {
     $err = false;
     global $USER, $cm, $course, $DB, $CFG;
     $location = praxe_get_location($this->locationid);
     $users = praxe_get_student_participants($cm->id);
     /// link back to list of locations - we will use it later
     $back = html_writer::link(new moodle_url(praxe_get_base_url(array('mode' => 'locations', 'schoolid' => 0))), get_string('back'));
     //if(praxe_get_use_status_of_location($location->id))
     //var_dump(praxe_get_use_status_of_location($location->id));
     //var_dump($location);
     if (!empty($location)) {
         $this->content_before_form .= html_writer::tag('p', get_string('assignstudtolocation_text', 'praxe'));
         $info = $location->name;
         if (strlen(trim($location->city))) {
             $info .= ", " . s($location->city);
         }
         if (strlen(trim($location->street))) {
             $info .= ", " . s($location->street);
         }
         $info = html_writer::tag('strong', $info);
         if (strlen(trim($location->subject))) {
             $info .= '<br>' . html_writer::tag('strong', s($location->subject));
         }
         if (!is_null($location->teacherid)) {
             $info .= '<br>' . s($location->teacher_name) . ' ' . s($location->teacher_lastname);
         }
         $info .= '<br>' . praxe_get_term_text($location->term) . ' ' . $location->year;
         $this->content_before_form .= html_writer::tag('p', $info);
         // location is occupied
         $sql = "SELECT rec.* FROM {praxe_records} rec WHERE rec.location = ? AND rec.status != ?";
         $params = array($this->locationid, PRAXE_STATUS_REFUSED);
         if ($ret = $DB->get_record_sql($sql, $params)) {
             $this->content .= html_writer::tag('div', get_string('location_is_not_available', 'praxe'));
             $this->content .= html_writer::tag('div', $back);
             /// location and users are available
         } else {
             if (is_array($users) && count($users)) {
                 $form = '<form class="mform" action="' . praxe_get_base_url(array('locationid' => $this->locationid), 'assigntolocation') . '" method="post">';
                 $form .= '<input type="hidden" name="post_form" value="assigntolocation" />';
                 $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
                 $form .= '<input type="hidden" name="location" value="' . $this->locationid . '" />';
                 $select = '<select name="student">';
                 $select .= '<option value="null">' . get_string('select_student', 'praxe') . '</option>';
                 foreach ($users as $us) {
                     $select .= '<option value="' . $us->id . '">' . s($us->firstname . ' ' . $us->lastname) . '</option>';
                 }
                 $select .= '</select>';
                 $form .= html_writer::tag('div', html_writer::tag('label', get_string('student')) . html_writer::tag('div', $select), array('class' => 'frow'));
                 /// option to send emails
                 require_once $CFG->dirroot . "/lib/pear/HTML/QuickForm/checkbox.php";
                 $checks = '';
                 if (!is_null($location->teacherid)) {
                     $check = new HTML_QuickForm_checkbox('sendemailtoextteacher', '', get_string('sendinfotoextteacher', 'praxe'));
                     $checks .= html_writer::tag('div', $check->toHtml());
                 }
                 $check = new HTML_QuickForm_checkbox('sendemailtostudent', '', get_string('sendinfotostudent', 'praxe'), 'checked');
                 $checks .= $check->toHtml();
                 $form .= html_writer::tag('div', html_writer::tag('label', get_string('informparticipants')) . html_writer::tag('div', $checks), array('class' => 'frow'));
                 /// action buttons
                 //$sub = '<div class="fitem center" style="margin: 10px 0;">'
                 $sub = '<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" />';
                 //felement fsubmit
                 $form .= html_writer::tag('div', $sub, array('class' => 'frow submit'));
                 $form .= '</form>';
                 $this->content .= html_writer::tag('div', $form, array('class' => 'thin-form'));
                 /// no students to be assigned to location
             } else {
                 $table->data[] = array(get_string('nostudentsavailable', 'praxe'));
                 $table->data[] = array($back);
                 $table->align = array('center');
                 $this->content .= html_writer::table($table, true);
             }
         }
     } else {
         $this->content_before_form .= html_writer::tag('strong', get_string('notallowedaction', 'praxe'));
         $this->content .= $back;
     }
 }
 function praxe_view_editteacher()
 {
     global $DB, $tab, $CFG, $tab_modes, $context;
     switch ($tab) {
         case PRAXE_TAB_EDITTEACHER_HOME:
             $detail = optional_param('recordid', 0, PARAM_INT);
             require_once $CFG->dirroot . '/mod/praxe/view_extteacher.php';
             if ($detail > 0 && ($record = praxe_get_record($detail))) {
                 $schid = optional_param('scheduleid', 0, PARAM_INT);
                 if ($schid > 0 && ($schedule = praxe_get_schedule($schid))) {
                     $this->content .= praxe_view_extteacher::show_schedule_detail($schedule) . "<hr>";
                 }
                 $this->content .= praxe_view_extteacher::show_record_detail($record);
             } else {
                 $this->content .= self::show_all_students_records();
             }
             break;
         case PRAXE_TAB_EDITTEACHER_ADDSCHOOL:
             require_capability('mod/praxe:manageallincourse', $context);
             require_once $CFG->dirroot . '/mod/praxe/c_addschool.php';
             $this->form = new praxe_addschool();
             break;
         case PRAXE_TAB_EDITTEACHER_SCHOOLS:
             require_once $CFG->dirroot . '/mod/praxe/view_headm.php';
             $schoolid = optional_param('schoolid', 0, PARAM_INT);
             if ($schoolid == 0) {
                 /// sorting list
                 $sname = strtoupper(optional_param('sname', null, PARAM_ALPHA));
                 $stype = strtoupper(optional_param('stype', null, PARAM_ALPHA));
                 $sort = array();
                 $aSort = array();
                 if ($sname == 'ASC' || $sname == 'DESC') {
                     $sort[] = 'name ' . $sname;
                     $aSort['name'] = $sname;
                 }
                 if ($stype == 'ASC' || $stype == 'DESC') {
                     $sort[] = 'type ' . $stype;
                     $aSort['type'] = $stype;
                 }
                 $sort = count($sort) ? implode(', ', $sort) : '';
                 $schools = $DB->get_records('praxe_schools', array(), $sort);
                 $this->content .= praxe_view_headm::show_schools($schools, array('mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_EDITSCHOOL]), $aSort);
             } else {
                 $this->content .= praxe_view_headm::show_school($schoolid, array('mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_EDITSCHOOL]));
             }
             break;
         case PRAXE_TAB_EDITTEACHER_EDITSCHOOL:
             require_capability('mod/praxe:manageallincourse', $context);
             $schoolid = required_param('schoolid', PARAM_INT);
             if ($school = praxe_get_school($schoolid)) {
                 require_once $CFG->dirroot . '/mod/praxe/c_addschool.php';
                 $this->form = new praxe_addschool();
                 $this->form->set_form_to_edit($school);
             }
             break;
         case PRAXE_TAB_EDITTEACHER_TEACHERS:
             $schoolid = optional_param('schoolid', 0, PARAM_INT);
             require_once $CFG->dirroot . '/mod/praxe/view_headm.php';
             if ($schoolid > 0) {
                 $this->content .= praxe_view_headm::school_teachers_by_schools(null, $schoolid);
             } else {
                 $this->content .= praxe_view_headm::school_teachers_by_schools();
             }
             break;
         case PRAXE_TAB_EDITTEACHER_ASSIGNTEACHERS:
             require_capability('mod/praxe:manageallincourse', $context);
             $schoolid = required_param('schoolid', PARAM_INT);
             require_once $CFG->dirroot . '/mod/praxe/c_assignteachers.php';
             $this->form = new praxe_assignteachers($schoolid);
             break;
         case PRAXE_TAB_EDITTEACHER_LOCATIONS:
             $schoolid = optional_param('schoolid', 0, PARAM_INT);
             $locationid = optional_param('locationid', 0, PARAM_INT);
             $edit = optional_param('edit', null, PARAM_TEXT);
             $factual = optional_param('factualloc', 0, PARAM_INT);
             $fyear = optional_param('fyearloc', 0, PARAM_INT);
             /// edit location form ///
             if (!is_null($edit) && $locationid > 0) {
                 if (!($loc = praxe_get_location($locationid))) {
                     print_error('notallowedaction', 'praxe');
                 }
                 require_once $CFG->dirroot . '/mod/praxe/c_addlocation.php';
                 $this->form = new praxe_addlocation($loc->school);
                 $this->form->set_redirect_url(null, array('mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_LOCATIONS], 'schoolid' => $schoolid));
                 $this->form->set_form_to_edit($loc);
             } else {
                 /// sorting list
                 $sortFields = array('sschool', 'sstudyfield', 'sisced', 'syear', 'ssubject', 'sactive');
                 $aSort = array();
                 foreach ($sortFields as $f) {
                     $s_[$f] = strtoupper(optional_param($f, null, PARAM_ALPHA));
                     if ($s_[$f] == 'ASC' || $s_[$f] == 'DESC') {
                         $aSort[$f] = $s_[$f];
                     } else {
                         $aSort[$f] = null;
                     }
                 }
                 require_once $CFG->dirroot . '/mod/praxe/view_headm.php';
                 $params = array('edit' => 'true', 'mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_LOCATIONS], 'schoolid' => $schoolid);
                 $this->content .= praxe_view_headm::show_locations($schoolid, null, $params, $factual, $fyear, $aSort);
             }
             break;
         case PRAXE_TAB_EDITTEACHER_ADDLOCATION:
             require_capability('mod/praxe:manageallincourse', $context);
             $schoolid = required_param('schoolid', PARAM_INT);
             require_once $CFG->dirroot . '/mod/praxe/c_addlocation.php';
             $this->form = new praxe_addlocation($schoolid);
             break;
         default:
             break;
     }
 }
Example #4
0
     }
     $post->active = required_param('active', PARAM_INT);
 }
 $post->subject = required_param('subject', PARAM_TEXT);
 if (!$bManage) {
     if (is_null($edit)) {
         if (!praxe_has_capability('createownlocation')) {
             print_error('notallowedaction', 'praxe');
         }
         $school = $DB->get_record('praxe_schools', array('headmaster' => $USER->id, 'id' => $post->school));
         $ext = $DB->get_record('praxe_school_teachers', array('id' => $post->teacher));
         if (!$school && !$ext) {
             print_error('notallowedaction', 'praxe');
         }
     } else {
         if (!(praxe_has_capability('editanylocation') || praxe_has_capability('editownlocation') && praxe_get_location($post->id, $USER->id))) {
             print_error('notallowedaction', 'praxe');
         }
     }
 }
 $redurl = optional_param('redurl', praxe_get_base_url(array('mode' => 'locations', 'schoolid' => 0)), PARAM_URL);
 /// insert record ///
 if (is_null($edit)) {
     $post->timecreated = time();
     if ($DB->insert_record('praxe_locations', $post)) {
         redirect($redurl, get_string('location_added', 'praxe'));
     }
 } else {
     $post->timemodified = time();
     if ($DB->update_record('praxe_locations', $post)) {
         redirect($redurl, get_string('location_updated', 'praxe'));
Example #5
0
 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;
         }
     }
 }
Example #6
0
 public function show_location($id)
 {
     global $OUTPUT;
     if ($data = praxe_get_location($id)) {
         //print_object($data);
         $table = new html_table();
         $table->head = array(get_string('school', 'praxe'), get_string('subject', 'praxe'), get_string('teacher', 'praxe'));
         $table->align = array('left', 'center', 'center');
         $sch = new html_table();
         $sch->data[] = array(get_string('address', 'praxe') . ":", s($data->street) . ', ' . s($data->zip) . "&nbsp;&nbsp;" . s($data->city));
         if ($data->headmaster > 0) {
             $headmaster = (object) array('id' => $data->headmaster, 'firstname' => $data->head_name, 'lastname' => $data->head_lastname);
             $sch->data[] = array(get_string('headmaster', 'praxe') . ":", praxe_get_user_fullname($headmaster));
         }
         $contact = array();
         if (is_string($data->phone) && strlen($data->phone)) {
             $contact[] = s($data->phone);
         }
         if (is_string($data->email) && strlen($data->email)) {
             $contact[] = s($data->email);
         }
         if (is_string($data->website) && strlen($data->website)) {
             $contact[] = format_string($data->website);
         }
         $sch->data[] = array(get_string('contact', 'praxe') . ":", implode("<br />", $contact));
         $schlink = $OUTPUT->action_link(praxe_get_base_url(array("viewaction" => 'viewschool', "schoolid" => $data->school)), s($data->name), null, array('title' => get_string('school_detail', 'praxe')));
         $row = array($schlink . html_writer::table($sch), s($data->subject));
         if ($data->teacherid > 0) {
             $teacher = (object) array('id' => $data->teacherid, 'firstname' => s($data->teacher_name), 'lastname' => s($data->teacher_lastname));
             $row[] = praxe_get_user_fullname($teacher);
         } else {
             $row[] = get_string('unlisted', 'praxe');
         }
         $table->data[] = $row;
         return html_writer::table($table);
     }
     return '';
 }