Example #1
0
<?php

include '../view/header.php';
require_once '../model/database.php';
require_once '../model/teachers_db.php';
$results = get_teachers();
?>

			<div class="">
				<ul class="breadcrumb">
  					<li><a href="index.php">Home</a> <span class="divider">/</span></li>
					<li class="active">Teachers</li>
				</ul>
			
			
				<table class="table table-condensed table-bordered table-striped">
					<tr>
						<th>Teacher ID</th>
						<th>First Name</th>
						<th>Last Name</th>
					</tr>
					<?php 
foreach ($results as $teacher) {
    ?>
					<tr>
						<td><?php 
    echo $teacher['teacher_id'];
    ?>
	</td>
						<td><?php 
    echo $teacher['fname'];
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $sessionid = $this->_customdata['sessionid'];
     if (!($att = get_record('attendance_sessions', 'id', $sessionid))) {
         error('No such session in this course');
     }
     $mform->addElement('header', 'general', get_string('changesession', 'attforblock'));
     $mform->setHelpButton('general', array('changesession', get_string('changesession', 'attforblock'), 'attforblock'));
     $mform->addElement('static', 'olddate', get_string('olddate', 'attforblock'), userdate($att->sessdate, get_string('strftimedmyhm', 'attforblock')));
     $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate', 'attforblock'));
     for ($i = 0; $i <= 23; $i++) {
         $hours[$i] = sprintf("%02d", $i);
     }
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = sprintf("%02d", $i);
     }
     $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours);
     $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true);
     $mform->addGroup($durselect, 'durtime', get_string('duration', 'attforblock'), array(' '), true);
     //  add a session title field to the form from either a drop down list or a text field for new names
     $sessionsgroup = array();
     $options = array('0' => '');
     if (count_records_select('attendance_sessiontitles')) {
         // check if session titles exist
         $sessiontitles = get_sessiontitles($course->id, false);
         foreach ($sessiontitles as $sessiontitle) {
             $options[$sessiontitle->sessiontitle] = $sessiontitle->sessiontitle;
         }
     }
     $sessionsgroup[] =& $mform->createElement('select', 'ssessiontitle', get_string('sessiontitle', 'attforblock'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $sessionsgroup[] =& $mform->createElement('text', 'hsessiontitle', get_string('newsessiontitle', 'attforblock'), 'size="20"');
     $mform->addGroup($sessionsgroup, 'sessiongroup', 'Session Title', ' ' . get_string('addnew', 'attforblock'), false);
     //  add a session title field to the form from either a drop down list or a text field for new names
     $groupsgroup = array();
     $options = array('0' => '');
     if (count_records_select('groups')) {
         // check if groups exist for this course
         $groups = get_records_select('groups');
         foreach ($groups as $group) {
             $options[$group->id] = $group->name;
         }
     }
     $groupsgroup[] =& $mform->createElement('select', 'sgroup', get_string('group'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $groupsgroup[] =& $mform->createElement('text', 'hgroup', get_string('newgroup', 'attforblock'), 'size="20"');
     $mform->addGroup($groupsgroup, 'groupgroup', 'Group', ' ' . get_string('addnew', 'attforblock'), false);
     //  add a subject field to the form
     $subjectgroup = array();
     $options = array('0' => '');
     if (count_records_select('attendance_subjects')) {
         // check if subjects exist
         $subjects = get_subjects($course->id, false);
         foreach ($subjects as $subject) {
             $options[$subject->subject] = $subject->subject;
         }
     }
     $subjectgroup[] =& $mform->createElement('select', 'ssubject', get_string('subject', 'attforblock'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $subjectgroup[] =& $mform->createElement('text', 'hsubject', get_string('newteacher', 'attforblock'), 'size="20"');
     $mform->addGroup($subjectgroup, 'subjectgroup', 'Subject', ' ' . get_string('addnew', 'attforblock'), false);
     //  add a teacher field to the form
     $teachersgroup = array();
     $options = array('0' => '');
     if (count_records_select('attendance_teachers')) {
         // check if teachers exist
         $teachers = get_teachers($course->id, false);
         foreach ($teachers as $teacher) {
             $options[$teacher->teacher] = $teacher->teacher;
         }
     }
     $teachersgroup[] =& $mform->createElement('select', 'steacher', get_string('teacher', 'attforblock'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $teachersgroup[] =& $mform->createElement('text', 'hteacher', get_string('newteacher', 'attforblock'), 'size="20"');
     $mform->addGroup($teachersgroup, 'teachersgroup', 'Teacher', ' ' . get_string('addnew', 'attforblock'), false);
     //  add a description field to the form
     $mform->addElement('text', 'sdescription', get_string('description', 'attforblock'), 'size="48"');
     $mform->setType('sdescription', PARAM_TEXT);
     $mform->addRule('sdescription', get_string('maximumchars', '', 100), 'maxlength', 100, 'client');
     $dhours = floor($att->duration / HOURSECS);
     $dmins = floor(($att->duration - $dhours * HOURSECS) / MINSECS);
     $mform->setDefaults(array('sessiondate' => $att->sessdate, 'durtime' => array('hours' => $dhours, 'minutes' => $dmins), 'sdescription' => $att->description, 'ssubject' => $att->subject, 'steacher' => $att->teacher, 'ssessiontitle' => $att->sessiontitle));
     //-------------------------------------------------------------------------------
     // buttons
     $submit_string = get_string('update', 'attforblock');
     $this->add_action_buttons(true, $submit_string);
     $mform->addElement('hidden', 'id', $cm->id);
     $mform->addElement('hidden', 'sessionid', $sessionid);
     $mform->addElement('hidden', 'action', 'update');
 }
Example #3
0
     // Otherwise, just skip down to the list redraw.
     if ($choice == 'Modify') {
         if (empty($course_nbr)) {
             $error_msg .= "Course Number is required.<BR>";
         }
         if (empty($course_name)) {
             $error_msg .= "Course Name is required.<BR>";
         }
         if (empty($teacher_id)) {
             $error_msg .= "Teacher is required.<BR>";
         }
         if (empty($course_type)) {
             $error_msg .= "Course Type is required.<BR>";
         }
         if ($error_msg != "") {
             $teachers = get_teachers();
             $course_types = get_course_types();
             include 'course_modify.php';
             exit;
         } else {
             modify_course($course_id, $course_name, $course_short_name, $course_desc, $teacher_id, $course_nbr, $room, $course_type);
         }
     }
     $courseList = get_course_list();
     include 'course_list.php';
     exit;
     break;
 case 'delete_course':
     $course_id = filter_input(INPUT_GET, 'course_id');
     delete_course($course_id);
     $courseList = get_course_list();
                print_error('cantaddteacher', 'attforblock', "addteachers.php?id={$id}");
            }
            break;
    }
}
show_tabs($cm, $context, 'teachers');
if ($submitsettings) {
    config_save();
    //////////////////////////////
    notice(get_string('teachersupdated', 'attforblock'), 'addteachers.php?id=' . $id);
}
$i = 1;
$table->width = '400px';
$table->head = array('#', get_string('teacher', 'attforblock'), get_string('action'));
$table->align = array('center', 'center', 'center', 'center');
$teachers = get_teachers($course->id, true);
$deltitle = get_string('delete');
if (count_records_select('attendance_teachers', 'deleted = 0')) {
    // check if session titles exist
    foreach ($teachers as $st) {
        $table->data[$i][] = $i;
        $table->data[$i][] = '<input type="text" name="teacher[' . $st->id . ']" size="30" maxlength="30" value="' . $st->teacher . '" />';
        $deleteact = "<a title=\"{$deltitle}\" href=\"addteachers.php?id={$cm->id}&amp;st={$st->id}&amp;action=delete\">" . "<img src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$deltitle}\" /></a>&nbsp;";
        $table->data[$i][] = $deleteact;
        $i++;
    }
}
$new_row = array('*', '<input type="text" name="newteacher" size="30" maxlength="30" value="" />', '<input type="submit" name="action" value="' . get_string('add', 'attforblock') . '"/>');
$table->data[$i] = $new_row;
echo '<div><div class="generalbox boxwidthwide">';
echo '<form method="post" action="addteachers.php" onsubmit="return validateSession()">';
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $mform->addElement('header', 'general', get_string('addsession', 'attforblock'));
     //fill in the data depending on page params
     //later using set_data
     $mform->addElement('checkbox', 'addmultiply', '', get_string('createmultiplesessions', 'attforblock'));
     $mform->setHelpButton('addmultiply', array('createmultiplesessions', get_string('createmultiplesessions', 'attforblock'), 'attforblock'));
     $mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attforblock'));
     for ($i = 0; $i <= 23; $i++) {
         $hours[$i] = sprintf("%02d", $i);
     }
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = sprintf("%02d", $i);
     }
     $durtime = array();
     $durtime[] =& MoodleQuickForm::createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true);
     $durtime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true);
     $mform->addGroup($durtime, 'durtime', get_string('duration', 'attforblock'), array(' '), true);
     $mform->addElement('date_selector', 'sessionenddate', get_string('sessionenddate', 'attforblock'));
     $mform->disabledIf('sessionenddate', 'addmultiply', 'notchecked');
     $sdays = array();
     if ($CFG->calendar_startwday === '0') {
         //week start from sunday
         $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar'));
     }
     $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Mon', '', get_string('monday', 'calendar'));
     $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Tue', '', get_string('tuesday', 'calendar'));
     $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Wed', '', get_string('wednesday', 'calendar'));
     $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Thu', '', get_string('thursday', 'calendar'));
     $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Fri', '', get_string('friday', 'calendar'));
     $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Sat', '', get_string('saturday', 'calendar'));
     if ($CFG->calendar_startwday !== '0') {
         //week start from sunday
         $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar'));
     }
     $mform->addGroup($sdays, 'sdays', get_string('sessiondays', 'attforblock'), array(' '), true);
     $mform->disabledIf('sdays', 'addmultiply', 'notchecked');
     $period = array(1 => 1, 2, 3, 4, 5, 6, 7, 8);
     $periodgroup = array();
     $periodgroup[] =& MoodleQuickForm::createElement('select', 'period', '', $period, false, true);
     $periodgroup[] =& MoodleQuickForm::createElement('static', 'perioddesc', '', get_string('week', 'attforblock'));
     $mform->addGroup($periodgroup, 'periodgroup', get_string('period', 'attforblock'), array(' '), false);
     $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked');
     //  add a Groups field to the form from either a drop down list or a text field for new names
     $selectgroups = array();
     $options = array('0' => '');
     if (count_records_select('groups', 'courseid = ' . $course->id)) {
         // check if groups exist
         $groups = get_records_select('groups');
         foreach ($groups as $group) {
             $options[$group->id] = $group->name;
         }
     }
     $selectgroups[] =& $mform->createElement('select', 'sgroup', get_string('group'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $selectgroups[] =& $mform->createElement('text', 'hgroup', get_string('addnew', 'attforblock'), 'size="20"');
     $mform->addGroup($selectgroups, 'sessiongroup', get_string('group'), ' ' . get_string('addnew', 'attforblock'), false);
     //  add a session title field to the form from either a drop down list or a text field for new names
     $sessionsgroup = array();
     $options = array('0' => '');
     if (count_records_select('attendance_sessiontitles')) {
         // check if session titles exist
         $sessiontitles = get_sessiontitles($course->id, false);
         foreach ($sessiontitles as $sessiontitle) {
             $options[$sessiontitle->sessiontitle] = $sessiontitle->sessiontitle;
         }
     }
     $sessionsgroup[] =& $mform->createElement('select', 'ssessiontitle', get_string('sessiontitle', 'attforblock'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $sessionsgroup[] =& $mform->createElement('text', 'hsessiontitle', get_string('newsessiontitle', 'attforblock'), 'size="20"');
     $mform->addGroup($sessionsgroup, 'sessiongroup', get_string('sessiontitle', 'attforblock'), ' ' . get_string('addnew', 'attforblock'), false);
     //  add a subject field to the form
     $subjectgroup = array();
     $options = array('0' => '');
     if (count_records_select('attendance_subjects')) {
         // check if subjects exist
         $subjects = get_subjects($course->id, false);
         foreach ($subjects as $subject) {
             $options[$subject->subject] = $subject->subject;
         }
     }
     $subjectgroup[] =& $mform->createElement('select', 'ssubject', get_string('subject', 'attforblock'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $subjectgroup[] =& $mform->createElement('text', 'hsubject', get_string('newteacher', 'attforblock'), 'size="20"');
     $mform->addGroup($subjectgroup, 'subjectgroup', get_string('subject', 'attforblock'), ' ' . get_string('addnew', 'attforblock'), false);
     //  add a teacher field to the form
     $teachersgroup = array();
     $options = array('0' => '');
     if (count_records_select('attendance_teachers')) {
         // check if teachers exist
         $teachers = get_teachers($course->id, false);
         foreach ($teachers as $teacher) {
             $options[$teacher->teacher] = $teacher->teacher;
         }
     }
     $teachersgroup[] =& $mform->createElement('select', 'steacher', get_string('teacher', 'attforblock'), $options, array('size' => 1, 'class' => 'pool', 'style' => 'width:200px;'));
     $teachersgroup[] =& $mform->createElement('text', 'hteacher', get_string('newteacher', 'attforblock'), 'size="20"');
     $mform->addGroup($teachersgroup, 'teachersgroup', get_string('teacher', 'attforblock'), ' ' . get_string('addnew', 'attforblock'), false);
     //  add a description field to the form
     $mform->addElement('text', 'sdescription', get_string('description', 'attforblock'), 'size="48"');
     $mform->setType('sdescription', PARAM_TEXT);
     $mform->addRule('sdescription', get_string('maximumchars', '', 100), 'maxlength', 100, 'client');
     //  add hidden buttons for course module id and action type
     $submit_string = get_string('addsession', 'attforblock');
     $this->add_action_buttons(false, $submit_string);
     //  hidden elements
     $mform->addElement('hidden', 'id', $cm->id);
     $mform->addElement('hidden', 'action', 'add');
 }
 function definition()
 {
     global $CFG, $USER, $currentgroup, $students, $context, $sort;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     //	Add date selectors for from and to dates
     $mform->addElement('date_selector', 'fdatefrom', get_string('datefrom', 'attforblock'));
     $mform->addElement('date_selector', 'fdateto', get_string('dateto', 'attforblock'));
     //	add radio buttons to select the report type
     $reporttype = array();
     $reporttype[] =& MoodleQuickForm::createElement('radio', 'reporttype', '', get_string('all'), 'all', '');
     $reporttype[] =& MoodleQuickForm::createElement('radio', 'reporttype', '', get_string('summaryonly', 'attforblock'), 'summary', '');
     $reporttype[] =& MoodleQuickForm::createElement('radio', 'reporttype', '', get_string('detailonly', 'attforblock'), 'detailed', '');
     $mform->addGroup($reporttype, 'reporttype', get_string('reporttype', 'attforblock'), array(' '), false);
     $mform->setDefault('reporttype', 'all');
     //  add a course select element to the form
     $courselist = array('-1' => get_string('all'));
     $courses = get_my_courses($USER->id, 'fullname ASC, sortorder ASC,visible DESC', '*', false, 21);
     foreach ($courses as $course) {
         $courselist[$course->id] = $course->fullname;
     }
     $mform->addElement('select', 'coursemenu', get_string('course'), $courselist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     //  add a group select element to the form
     $grouplist = array('-1' => get_string('all'));
     $groups = get_records('groups');
     foreach ($groups as $group) {
         $grouplist[$group->id] = $group->name;
     }
     $mform->addElement('select', 'groupmenu', get_string('group'), $grouplist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     if ($currentgroup) {
         $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.{$sort} ASC", '', '', $currentgroup, '', false);
     } else {
         $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.{$sort} ASC", '', '', '', '', false);
     }
     //	add a student select element to the form
     $studentlist = array();
     $studentlist[0] = get_string('all');
     foreach ($students as $student) {
         $studentlist[$student->id] = fullname($student);
     }
     $mform->addElement('select', 'studentmenu', get_string('student', 'attforblock'), $studentlist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     //  add a subject select element to the form
     $subjectlist = array('-1' => get_string('all'));
     if (count_records_select('attendance_subjects')) {
         // check if subjects exist
         $subjects = get_subjects($course->id, true);
         foreach ($subjects as $subject) {
             $subjectlist[$subject->subject] = $subject->subject;
         }
     }
     $mform->addElement('select', 'subjectmenu', get_string('subject', 'attforblock'), $subjectlist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     //  add a teacher select element to the form
     $teacherlist = array('-1' => get_string('all'));
     if (count_records_select('attendance_teachers')) {
         // check if teachers exist
         $teachers = get_teachers($course->id, true);
         foreach ($teachers as $teacher) {
             $teacherlist[$teacher->teacher] = $teacher->teacher;
         }
     }
     $mform->addElement('select', 'teachermenu', get_string('teacher', 'attforblock'), $teacherlist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     //	Define the options of the drop down menu for make up notes and sicknote
     $optionlist = array('all' => get_string('all'), 'notrequired' => get_string('notrequired', 'attforblock'), 'outstanding' => get_string('outstanding', 'attforblock'), 'submitted' => get_string('submitted', 'attforblock'), 'cleared' => get_string('cleared', 'attforblock'));
     $mform->addElement('select', 'makeupnotemenu', get_string('makeupnote', 'attforblock'), $optionlist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     $mform->addElement('select', 'sicknotemenu', get_string('sicknote', 'attforblock'), $optionlist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     //  	add a status select element to the form
     $statuslist = array('-1' => get_string('all'));
     if (count_records_select('attendance_statuses')) {
         // check if statuses exist
         $courses = get_my_courses($USER->id, 'fullname ASC, sortorder ASC,visible DESC', '*', false, 21);
         foreach ($courses as $course) {
             //$statuslist['-1'.$course->id] = $course->fullname;
             $statuses = get_statuses($course->id);
             // add a check to see if all courses or only one has been selected:  get_statuses for the course selected and get_status for all courses
             foreach ($statuses as $status) {
                 $statuslist[$status->id] = $course->fullname . ' - * ' . $status->description;
             }
         }
     }
     $select = $mform->addElement('select', 'statusmenu', get_string('status', 'attforblock'), $statuslist, array('size' => 1, 'class' => 'pool', 'style' => 'width:220px;'));
     //	add radio buttons to select the sort order
     $sortmenu = array();
     $sortmenu[] =& MoodleQuickForm::createElement('radio', 'sortmenu', '', get_string('firstname'), 'firstname', '');
     $sortmenu[] =& MoodleQuickForm::createElement('radio', 'sortmenu', '', get_string('lastname'), 'lastname', '');
     $mform->addGroup($sortmenu, 'yesno', get_string('sortby', 'attforblock'), array(' '), false);
     $mform->setDefault('sortmenu', 'lastname');
     $lastquery = get_records('attendance_report_query');
     if ($lastquery) {
         foreach ($lastquery as $field) {
             $mform->setDefaults(array('fdatefrom' => $field->datefrom, 'fdateto' => $field->dateto, 'coursemenu' => $field->course, 'studentmenu' => $field->student, 'teachermenu' => $field->teacher, 'subjectmenu' => $field->subject, 'makeupnotemenu' => $field->makeupnote, 'sicknotemenu' => $field->sicknote, 'statusmenu' => $field->status, 'yesno' => $field->sortby, 'reporttype' => $field->reporttype));
         }
     }
     //  add hidden buttons for course module id and action type
     $submit_string = get_string('update');
     $this->add_action_buttons(false, $submit_string);
     //  hidden elements
     $mform->addElement('hidden', 'id', $cm->id);
     $mform->addElement('hidden', 'action', 'update');
 }
Example #7
0
    $audit = intval($_GET['audit']);
    if ($audit) {
        $wheresql .= ' AND audit=' . $audit . ' ';
    }
    $orderby = " order by refreshtime desc";
    require_once QISHI_ROOT_PATH . 'include/page.class.php';
    $perpage = 10;
    $total_sql = "SELECT COUNT(*) AS num FROM " . table('train_teachers') . $wheresql;
    $total_val = $db->get_total($total_sql);
    $page = new page(array('total' => $total_val, 'perpage' => $perpage, 'getarray' => $_GET));
    $offset = ($page->nowindex - 1) * $perpage;
    $sql = 'select * from ' . table('train_teachers') . $wheresql . $orderby;
    $smarty->assign('title', '讲师管理 - 培训会员中心 - ' . $_CFG['site_name']);
    $smarty->assign('act', $act);
    $smarty->assign('total', $total);
    $smarty->assign('teachers', get_teachers($offset, $perpage, $sql, true));
    $smarty->assign('page', $page->show(3));
    $smarty->display('member_train/train_teachers.htm');
} elseif ($act == 'add_teachers') {
    if ($train_profile['trainname']) {
        $pid = intval($_REQUEST['pid']);
        $uid = intval($_SESSION['uid']);
        $teachers = get_teachers_one($pid, $uid);
        $smarty->assign('teachers', $teachers);
        if ($teachers) {
            $smarty->assign('go_teachers_show', 1);
        }
        $smarty->assign('act', $act);
        $smarty->assign('pid', $pid);
        $smarty->assign('title', '讲师信息 - 培训会员中心 - ' . $_CFG['site_name']);
        if ($_CFG['operation_train_mode'] == "2") {