Пример #1
0
 /**
  *
  * @param object $rec - object of praxe record to be shown
  * @return string
  */
 public static function show_record_detail($rec)
 {
     global $mode, $USER, $CFG, $OUTPUT;
     /// left top table ///
     $tab1 = new html_table();
     $tab1->align = array('right', 'left');
     //$tab1->width = '300px';
     $tab1->attributes['class'] = "floatinfotable left twocolstable";
     $school = array($rec->name);
     if (strlen(trim($rec->city))) {
         $school[] = $rec->city;
     }
     if (strlen(trim($rec->street))) {
         $school[] = $rec->street;
     }
     if (strlen(trim($rec->phone))) {
         $school[] = $rec->phone;
     }
     if (strlen(trim($rec->email))) {
         $school[] = $rec->email;
     }
     $tab1->data[] = array(get_string('school', 'praxe') . ":", format_string(implode(', ', $school)));
     $tab1->data[] = array(get_string('subject', 'praxe') . ":", $rec->subject);
     if ($rec->teacherid && $USER->id != $rec->teacherid) {
         $tab1->data[] = array(get_string('teacher', 'praxe') . ":", praxe_get_user_fullname((object) array('id' => $rec->teacherid, 'firstname' => $rec->teacher_firstname, 'lastname' => $rec->teacher_lastname)));
     }
     /// right top table ///
     $tab2 = new html_table();
     $tab2->align = array('right', 'left');
     //$tab2->width = '350px';
     $tab2->attributes['class'] = "floatinfotable left twocolstable last";
     $tab2->data[] = array(get_string('student', 'praxe') . ":", praxe_get_user_fullname($rec->student));
     $tab2->data[] = array(get_string('status', 'praxe') . ":", praxe_get_status_info($rec->status));
     if ($rec->status == PRAXE_STATUS_ASSIGNED) {
         $tab2->data[] = array(get_string('action') . ':', self::confirm_location_form($rec->id));
         return html_writer::table($tab1) . html_writer::table($tab2) . '<div class="clearer"></div>';
     }
     $return = html_writer::table($tab1) . html_writer::table($tab2) . '<div class="clearer"></div>';
     $return .= "<h3>" . get_string('schedule', 'praxe') . "</h3>";
     $schedules = praxe_get_schedules($rec->id);
     if (!$schedules) {
         return $return . get_string('no_schedule_items', 'praxe');
     }
     $sched = array();
     $cols = array();
     foreach ($schedules as $sch) {
         if (!isset($sched[date("j_m", $sch->timestart)])) {
             $sched[date("j_m", $sch->timestart)] = array('date' => $sch->timestart);
         }
         $sched[date("j_m", $sch->timestart)][$sch->lesnumber] = $sch;
         if (!in_array($sch->lesnumber, $cols)) {
             $cols[] = $sch->lesnumber;
         }
     }
     /// schedule table ///
     $tab3 = new html_table();
     if (count($cols)) {
         sort($cols);
     }
     $tab3->head = $cols;
     array_unshift($tab3->head, get_string('date'));
     for ($i = 1; $i < count($tab3->head); $i++) {
         if (is_null($tab3->head[$i])) {
             $tab3->head[$i] = "---";
         } else {
             $tab3->head[$i] = s($tab3->head[$i]) . "." . get_string('lesson', 'praxe');
         }
     }
     $cellf = new html_table_cell();
     $cellf->attributes['class'] = "header first";
     $cellf->header = true;
     $paramsToAssing = array('post_form' => 'assigntoinspection', 'sesskey' => sesskey(), 'submitbutton' => 'true', 'userid' => $USER->id);
     $paramsToRemAssing = array('post_form' => 'removefrominspection', 'sesskey' => sesskey(), 'submitbutton' => 'true');
     foreach ($sched as $row) {
         $datetd = userdate($row['date'], get_string('strftimeday', 'praxe')) . "<br />" . userdate($row['date'], get_string('strftimedateshort'));
         $cell = clone $cellf;
         $cell->text = $datetd;
         $cells = array($cell);
         foreach ($cols as $k => $c) {
             if (isset($row[$c])) {
                 $item = userdate($row[$c]->timestart, get_string('strftimetime')) . " - " . userdate($row[$c]->timeend, get_string('strftimetime')) . "<br>" . s($row[$c]->lessubject) . "<br>" . get_string('schoolroom', 'praxe') . ": " . s($row[$c]->schoolroom);
                 $item = "<div>" . $OUTPUT->action_link(praxe_get_base_url(array("mode" => $mode, "recordid" => $rec->id, "scheduleid" => $row[$c]->id)), $item, null, array('title' => get_string('detail', 'praxe'))) . "</div>";
                 if (count($row[$c]->inspectors)) {
                     foreach ($row[$c]->inspectors as $insp) {
                         $item .= "<div class=\"inspector right\">" . $OUTPUT->render(new pix_icon('icon_inspect', get_string('inspection', 'praxe'), 'praxe')) . "&nbsp;" . praxe_get_user_fullname($insp);
                         /// remove assinging from item action ///
                         if ($USER->id == $insp->id || praxe_has_capability('manageallincourse')) {
                             $params = $paramsToRemAssing;
                             $params['scheduleid'] = $row[$c]->id;
                             $params['inspid'] = $insp->id;
                             $item .= $OUTPUT->action_icon(praxe_get_base_url($params), new pix_icon('t/delete', get_string('removeinspection', 'praxe')));
                         }
                         $item .= "</div>";
                     }
                 } else {
                     if (praxe_has_capability('assignselftoinspection')) {
                         $params = $paramsToAssing;
                         $params['scheduleid'] = $row[$c]->id;
                         /// assign inspector button ///
                         $item .= "<div class=\"inspector right\">" . $OUTPUT->single_button(praxe_get_base_url($params), get_string('gotoinspection', 'praxe'), 'post') . '</div>';
                     }
                 }
                 $cells[] = new html_table_cell($item);
             } else {
                 $cells[] = new html_table_cell('&nbsp;');
             }
         }
         $tab3->data[] = new html_table_row($cells);
     }
     return $return . html_writer::table($tab3);
 }
Пример #2
0
 function praxe_view_student()
 {
     global $CFG, $tab, $tab_modes, $context, $DB, $sentForm;
     $viewaction = optional_param('viewaction', null, PARAM_ALPHA);
     $schoolid = optional_param('schoolid', 0, PARAM_INT);
     if ($viewaction == 'viewschool' && $schoolid) {
         require_once $CFG->dirroot . '/mod/praxe/view_headm.php';
         $this->content .= praxe_view_headm::show_school($schoolid);
         $this->content .= praxe_praxehome_buttons(false);
     } else {
         $status = praxe_record::getData('rec_status');
         switch ($tab) {
             case PRAXE_TAB_STUDENT_HOME:
                 $after_tab = '';
                 $strd = get_string('done', 'praxe');
                 $strinpr = get_string('inprocess', 'praxe');
                 $cell = new html_table_cell(get_string('todo', 'praxe'));
                 $cell->attributes['class'] = 'cell center';
                 $cell1 = clone $cell;
                 $cell2 = clone $cell;
                 if (is_null($status)) {
                     $this->content .= '<div class="before_form">' . get_string('assigntolocation_text_forstudents', 'praxe') . '</div>';
                     $this->content .= self::make_assigntolocation_form();
                     $this->content .= "<hr>";
                 } else {
                     $this->content .= "<div class=\"status_infobox\"><strong>" . get_string('status', 'praxe') . ": </strong>" . praxe_get_status_info($status, 'student') . "</div>";
                     if ($status == PRAXE_STATUS_REFUSED) {
                         $this->content .= '<div class="before_form">' . get_string('assigntolocation_text_forstudents', 'praxe') . '</div>';
                         $this->content .= self::make_assigntolocation_form();
                     } else {
                         if ($status == PRAXE_STATUS_ASSIGNED) {
                             $cell->text = $strinpr;
                             $cell->attributes['class'] .= ' orange';
                         } else {
                             if ($status == PRAXE_STATUS_SCHEDULE_DONE) {
                                 $cell->text = $strd;
                                 $cell->attributes['class'] .= ' green';
                                 $cell1->text = $strd;
                                 $cell1->attributes['class'] .= ' green';
                             } else {
                                 if ($status == PRAXE_STATUS_CONFIRMED) {
                                     $cell->text = $strd;
                                     $cell->attributes['class'] .= ' green';
                                     $schlink = praxe_get_base_url(array("mode" => $tab_modes['student'][PRAXE_TAB_STUDENT_SCHEDULE]));
                                     $after_tab .= "<div class=\"infobox center\"><div>" . get_string('you_should_create_schedule', 'praxe') . ": <a href=\"{$schlink}\">" . get_string('my_schedule', 'praxe') . "</a></div></div>";
                                 } else {
                                     if ($status == PRAXE_STATUS_EVALUATED) {
                                         $cell->text = $strd;
                                         $cell->attributes['class'] .= ' green';
                                         $cell1->text = $strd;
                                         $cell1->attributes['class'] .= ' green';
                                         $cell2->text = $strd;
                                         $cell2->attributes['class'] .= ' green';
                                     }
                                 }
                             }
                         }
                     }
                 }
                 /// table of parts of student's practice ///
                 $table = new html_table();
                 $table->attributes['class'] = 'praxe generaltable boxaligncenter status';
                 $table->head = array(get_string('choosing_location', 'praxe'), get_string('schedule', 'praxe'), get_string('evaluated', 'praxe'));
                 //get_string('praxe_completed','praxe'));
                 $table->data[] = new html_table_row(array($cell, $cell1, $cell2));
                 $this->content .= html_writer::table($table);
                 $this->content .= $after_tab;
                 break;
             case PRAXE_TAB_STUDENT_MYSCHOOL:
                 $this->content .= self::show_location(praxe_record::getData('rec_location'));
                 break;
             case PRAXE_TAB_STUDENT_EDITLOC:
                 $this->content .= self::change_location_form();
                 break;
             case PRAXE_TAB_STUDENT_SCHEDULE:
                 $editlinks = array("mode" => $tab_modes['student'][PRAXE_TAB_STUDENT_ADDSCHEDULE], 'edit' => 'editschedule');
                 $schedules = praxe_get_schedules(praxe_record::getData('rec_id'), array('timestart', 'lesnumber'));
                 self::show_schedule($schedules, false, $editlinks);
                 /// schedule confirm form for validation ///
                 if ($schedules) {
                     $f = '<form method="post" class="form confirmschedule center">';
                     $f .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="praxeaction" value="confirmschedule" />';
                     $f .= '<div>';
                     $f .= '<strong>' . get_string('confirmschedule_sendnotice', 'praxe') . '</strong><br />';
                     $f .= get_string('sendinfotoextteacher', 'praxe') . ": ";
                     $f .= '<input type="checkbox" name="mailtoextteacher" value="1" checked="checked" />';
                     $f .= '</div><div class="center">';
                     $f .= '<input type="submit" name="confirmsubmitbutton" value="' . get_string('confirm') . '" />';
                     $f .= '</div>';
                     $f .= '</form>';
                     $this->content .= $f;
                 }
                 break;
             case PRAXE_TAB_STUDENT_ADDSCHEDULE:
                 if (is_object($sentForm)) {
                     if (!is_null(optional_param('edit', null, PARAM_TEXT))) {
                         $scheduleid = optional_param('scheduleid', 0, PARAM_INT);
                         $sentForm->set_form_to_edit((object) array('id' => $scheduleid));
                     }
                     $sentForm->display_content_before();
                     $sentForm->display();
                 } else {
                     require_capability('mod/praxe:addstudentschedule', $context);
                     require_once $CFG->dirroot . '/mod/praxe/c_makeschedule.php';
                     $this->form = new praxe_makeschedule();
                     if (!is_null(optional_param('edit', null, PARAM_TEXT))) {
                         $scheduleid = optional_param('scheduleid', 0, PARAM_INT);
                         if ($schedule = $DB->get_record('praxe_schedules', array('id' => $scheduleid, 'record' => praxe_record::getData('rec_id')))) {
                             if (!$this->form->set_form_to_edit($schedule)) {
                                 $this->form->add_to_content(get_string('date_of_schedule_has_expired', 'praxe') . "<br>" . get_string('noeditableitem', 'praxe'), true);
                             }
                         } else {
                             print_error('notallowedaction', 'praxe');
                         }
                     }
                 }
                 break;
             default:
                 redirect(praxe_get_base_url());
                 break;
         }
     }
 }