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;
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * @param string $schoolid
  * @param string $headmid
  * @param unknown $editlinkparams
  * @param number $bOnlyActual
  * @param number $year
  * @param array $aSort Associative array with column as key and ASC/DESC/null as value
  * @return Ambigous <string, lang_string>|string
  */
 public static function show_locations($schoolid = null, $headmid = null, $editlinkparams = array(), $bOnlyActual = 0, $year = 0, $aSort = array())
 {
     global $USER, $cm, $OUTPUT, $DB;
     $schoolid = $schoolid ? $schoolid : null;
     $sortAvailable = array('sschool' => 'name', 'sstudyfield' => 'studyfieldname', 'sisced' => 'isced', 'syear' => 'year', 'ssubject' => 'subject', 'sactive' => 'active');
     $aSortcorrect = array_intersect(array_keys($sortAvailable), array_keys($aSort));
     $sort = array();
     foreach ($aSortcorrect as $k) {
         if (!is_null($aSort[$k])) {
             $sort[] = $sortAvailable[$k] . ' ' . $aSort[$k];
         }
     }
     $locs = praxe_get_locations_by_schooldata($schoolid, $headmid, $bOnlyActual, $year, implode(', ', array_reverse($sort)));
     if (!$locs) {
         return get_string('nolocationsavailable', 'praxe');
     }
     $defEnableAssignStudent = praxe_has_capability('assignstudenttolocation');
     $table = new html_table();
     $baseLink = praxe_get_base_url(array('mode' => 'locations', 'schoolid' => (int) $schoolid, 'fyearloc' => $year, 'factual' => $bOnlyActual));
     $h = array();
     $aHeadSorting = array('sschool' => get_string('school', 'praxe'), 'ssubject' => get_string('subject', 'praxe'), 'sactive' => get_string('active', 'praxe'), 'sstudyfield' => get_string('studyfield', 'praxe'), 'sisced' => get_string('iscedlevel', 'praxe'), 'syear' => get_string('year', 'praxe'));
     foreach ($aHeadSorting as $k => $text) {
         if (isset($aSort[$k])) {
             $toLink = $aSort[$k] == 'ASC' ? 'DESC' : 'ASC';
             $sOut = $OUTPUT->action_link($baseLink . '&amp;' . $k . '=' . $toLink, $text);
             $sOut .= $OUTPUT->pix_icon('t/sort_' . strtolower($aSort[$k]), $aSort[$k]);
         } else {
             $sOut = $OUTPUT->action_link($baseLink . '&amp;' . $k . '=ASC', $text);
         }
         $aHeadSorting[$k] = $sOut;
     }
     $h[] = $aHeadSorting['sschool'];
     $h[] = $aHeadSorting['ssubject'];
     $h[] = get_string('extteacher', 'praxe');
     $h[] = $aHeadSorting['sstudyfield'];
     $h[] = $aHeadSorting['sisced'];
     $h[] = $aHeadSorting['syear'];
     $h[] = get_string('term', 'praxe');
     $h[] = get_string('actual_status', 'praxe');
     $h[] = $aHeadSorting['sactive'];
     $h[] = get_string('student', 'praxe');
     $table->head = $h;
     $table->align = array('left', 'left', 'left', 'left', 'left', 'center', 'center', 'left', 'center');
     $table->data = array();
     $stredit = get_string('edit');
     foreach ($locs as $loc) {
         $editable = false;
         if (praxe_has_capability('manageallincourse') || praxe_has_capability('editanylocation') || praxe_has_capability('editownlocation') && ($USER->id == $loc->headmaster || $USER->id == $loc->teacherid)) {
             $editable = true;
         }
         $teacher = '';
         if (!is_null($loc->teacherid)) {
             $teacher = praxe_get_user_fullname((object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => $loc->teacher_lastname));
         }
         $stf = s($loc->studyfieldname) . ' (' . s($loc->shortcut) . ')';
         $status = praxe_get_use_status_of_location($loc->id);
         $active = $loc->active == 1 ? get_string('yes') : get_string('no');
         $row = array(s($loc->name), s($loc->subject), $teacher, $stf, praxe_get_isced_text($loc->isced), s($loc->year), praxe_get_term_text($loc->term), $status, $active);
         /// icon for assign student / student ///
         $sql = "SELECT p.*, s.firstname, s.lastname FROM {praxe_records} p LEFT JOIN {user} s ON (s.id = p.student)\n\t\t\t\t\tWHERE location = ?\n\t\t\t\t\tORDER BY timemodified DESC\n\t\t\t\t\tLIMIT 1";
         $params = array($loc->id);
         if ($ret = $DB->get_record_sql($sql, $params)) {
             $row[] = praxe_get_user_fullname((object) array('id' => $ret->student, 'firstname' => $ret->firstname, 'lastname' => $ret->lastname));
             $enableAssignStudent = $defEnableAssignStudent && $ret->status == PRAXE_STATUS_REFUSED;
         } else {
             $row[] = "&nbsp;";
             $enableAssignStudent = $defEnableAssignStudent;
         }
         if ($editable || $enableAssignStudent) {
             $editRow = array();
             $params = array('locationid' => $loc->id);
             foreach ($editlinkparams as $name => $val) {
                 $params[s($name)] = s($val);
             }
             if ($editable) {
                 $editRow[] = $OUTPUT->action_icon(praxe_get_base_url($params), new pix_icon('t/edit', $stredit));
             }
             if ($enableAssignStudent) {
                 $params['assignuser'] = 1;
                 $editRow[] = $OUTPUT->action_icon(praxe_get_base_url($params, 'assigntolocation'), new pix_icon('i/users', get_string('assignusertolocation', 'praxe')));
             }
             $row[] = implode(' ', $editRow);
             if (count($table->head) < count($row)) {
                 $table->head[] = get_string('edit');
                 $table->align[] = 'center';
             }
         }
         $row = new html_table_row($row);
         if ($loc->active != 1) {
             $row->attributes['class'] = 'praxe_noactive_location';
         }
         $table->data[] = $row;
     }
     return html_writer::table($table);
 }
Ejemplo n.º 3
0
 private function show_all_my_locations($bOnlyActual = 0, $year = 0)
 {
     global $USER, $CFG, $tab_modes, $DB, $OUTPUT;
     if (!($all = praxe_get_locations(null, null, null, $bOnlyActual, $year))) {
         return get_string('nolocationsavailable', 'praxe');
     }
     $table = new html_table();
     $strname = get_string('schoolname', 'praxe');
     $strsubject = get_string('subject', 'praxe');
     $strstudy = get_string('studyfield', 'praxe');
     $strisced = get_string('iscedlevel', 'praxe');
     $stryear = get_string('year', 'praxe');
     $strterm = get_string('term', 'praxe');
     $table->head = array($strname, $strsubject, $strisced, $strstudy, $stryear, $strterm, get_string('active', 'praxe'), get_string('edit'));
     $table->align = array('left', 'left', 'left', 'left', 'center', 'center', 'center');
     $stredit = get_string('edit');
     foreach ($all as $loc) {
         if ($loc->teacherid != $USER->id) {
             continue;
         }
         $row = array(s($loc->name), s($loc->subject), praxe_get_isced_text($loc->isced), s($loc->studyfieldname) . " (" . s($loc->shortcut) . ")");
         $row[] = s($loc->year);
         $row[] = praxe_get_term_text($loc->term);
         $row[] = $loc->active == 1 ? get_string('yes') : get_string('no');
         if (praxe_has_capability('editanylocation') || praxe_has_capability('editownlocation') && $USER->id == $loc->teacherid) {
             $row[] = $OUTPUT->action_icon(praxe_get_base_url(array("mode" => $tab_modes['extteacher'][PRAXE_TAB_EXTTEACHER_EDITLOCATION], "locationid" => $loc->id)), new pix_icon('t/edit', $stredit));
         } else {
             $row[] = get_string('already_used', 'praxe');
         }
         $table->data[] = $row;
     }
     if (count($table->data)) {
         return html_writer::table($table);
     }
     return get_string('nolocationsavailable', 'praxe');
 }
Ejemplo n.º 4
0
$table->head = array(get_string('name'), get_string('description'), get_string('iscedlevel', 'praxe'), get_string('year', 'praxe'), get_string('term', 'praxe'), get_string('dateofpraxe', 'praxe'), get_string('numberofrecords', 'praxe'), get_string('participants') . " (" . get_string('groups') . ")");
$table->align = array('center', 'left', 'center', 'center', 'center', 'center', 'center', 'center');
foreach ($praxes as $praxe) {
    $records = $DB->get_records('praxe_records', array('praxe' => $praxe->id));
    $numofrecords = count($records);
    if (!$praxe->visible) {
        $link = html_writer::link(new moodle_url('/mod/praxe/view.php', array('id' => $praxe->coursemodule)), format_string($praxe->name, true), array('class' => 'dimmed'));
    } else {
        $link = html_writer::link(new moodle_url('/mod/praxe/view.php', array('id' => $praxe->coursemodule)), format_string($praxe->name, true));
    }
    $part = '0';
    if (!empty($praxe->groupingid)) {
        $groups = $DB->get_records_sql("SELECT g.*\n    \t\t\t\t\t\t\t\t\tFROM {groupings_groups} gg\n    \t\t\t\t\t\t\t\t\tLEFT JOIN {groups} g on(groupid = g.id)\n    \t\t\t\t\t\t\t\t\tWHERE groupingid = ?", array($praxe->groupingid));
        $aPart = array();
        foreach ($groups as $group) {
            $aPart[] = '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $course->id . '&amp;group=' . $group->id . '">' . $group->name . '</a>';
        }
        $part = implode(', ', $aPart);
    }
    $date = userdate($praxe->datestart, get_string('strftimedateshort')) . " - " . userdate($praxe->dateend, get_string('strftimedateshort'));
    $table->data[] = array($link, s($praxe->description), praxe_get_isced_text($praxe->isced), s($praxe->year), praxe_get_term_text($praxe->term), $date, $numofrecords, $part);
    /*
        if ($course->format == 'weeks' or $course->format == 'topics') {
            $table->data[] = array($praxe->section, $link);
        } else {
            $table->data[] = array($link);
        }*/
}
echo $OUTPUT->heading(get_string('modulenameplural', 'praxe'), 2);
echo html_writer::table($table);
echo $OUTPUT->footer();