Example #1
0
/** \file
 * \brief Definition of Dublin Core handler.
 *
 * It is not working as it does not provide any content to the metadata node. It only included
 * to demonstrate how a new metadata can be supported. For a working
 * example, please see record_rif.php.
 *
 * @author: Ismail Fahmi, ismail.fahmi@gmail.com
 *
 * \sa oaidp-config.php 
 */
function create_metadata($outputObj, $cur_record, $identifier, $setspec, $db)
{
    if (!defined('SLIMS_SERVER_NAME')) {
        define('SLIMS_SERVER_NAME', $_SERVER['SERVER_NAME']);
    }
    if (!defined('SLIMS_BASE_URL')) {
        define('SLIMS_BASE_URL', 'http://' . SLIMS_SERVER_NAME . dirname($_SERVER['SCRIPT_NAME']));
    }
    $metadata_node = $outputObj->create_metadata($cur_record);
    $oai_node = $outputObj->addChild($metadata_node, "oai_dc:dc");
    $oai_node->setAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
    $oai_node->setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
    $oai_node->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    $oai_node->setAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd");
    $record = get_record($identifier, $db);
    $authors = get_authors($identifier, $db);
    $subjects = get_subjects($identifier, $db);
    $outputObj->addChild($oai_node, 'dc:title', xml_safe($record['title']));
    foreach ($authors as $author) {
        $outputObj->addChild($oai_node, 'dc:creator', xml_safe($author['author_name']));
    }
    foreach ($subjects as $subject) {
        $outputObj->addChild($oai_node, 'dc:subject', xml_safe($subject['topic']));
    }
    $outputObj->addChild($oai_node, 'dc:publisher', xml_safe($record['publisher_name']));
    $outputObj->addChild($oai_node, 'dc:date', date_safe($record['publish_year']));
    $outputObj->addChild($oai_node, 'dc:language', $record['language_id']);
    $outputObj->addChild($oai_node, 'dc:format', $record['gmd_name']);
    $outputObj->addChild($oai_node, 'dc:identifier', SLIMS_BASE_URL . '/index.php?p=show_detail&id=' . $record['biblio_id']);
    if (!empty($record['isbn_issn'])) {
        $outputObj->addChild($oai_node, 'dc:identifier_isbn', xml_safe($record['isbn_issn']));
    }
    if (!empty($record['notes'])) {
        $outputObj->addChild($oai_node, 'dc:description', xml_safe($record['notes']));
    }
    if (!empty($record['publish_place'])) {
        $outputObj->addChild($oai_node, 'dc:location', xml_safe($record['publish_place']));
    }
    if (!empty($record['image'])) {
        $outputObj->addChild($oai_node, 'dc:identifier', SLIMS_BASE_URL . '/lib/phpthumb/phpThumb.php?src=../../images/docs/' . xml_safe($record['image']));
    }
    if (!empty($record['series_title'])) {
        $outputObj->addChild($oai_node, 'dc:series', xml_safe($record['series_title']));
    }
    if (!empty($record['collation'])) {
        $outputObj->addChild($oai_node, 'dc:description', xml_safe($record['collation']));
    }
    if (!empty($record['classification'])) {
        $outputObj->addChild($oai_node, 'dc:subject', xml_safe($record['classification']));
    }
    //print_r($record);
    //print_r($authors);
    //print_r($subjects);
}
Example #2
0
function get_formula($dbc, $db_name, $value)
{
    $formula_links = array();
    $formulae = array_unique(array_merge(get_subjects($dbc, $value, "治疗"), get_values($dbc, $value, '方剂加(调整)'), get_values($dbc, $value, '方剂(调整)'), get_values($dbc, $value, '被...治疗')));
    foreach ($formulae as $formula) {
        $formula_links[] = render_value($dbc, $db_name, $formula, false);
    }
    $formula_title = '';
    if (count($formula_links) != 0) {
        $formula_title .= implode(', ', $formula_links);
    }
    return $formula_title;
}
Example #3
0
function render_treatment($dbc, $db_name, $id)
{
    echo '<p>系统为您推荐如下的方剂:</p>';
    $formulas = array();
    $values = array_merge(get_subjects($dbc, PREFIX . $id, "治疗"), get_values($dbc, PREFIX . $id, "被...治疗"));
    foreach ($values as $value) {
        if (array_key_exists($value, $formulas)) {
            $formulas[$value] = $formulas[$value] + 1;
        } else {
            $formulas[$value] = 1;
        }
    }
    arsort($formulas);
    //$formulas = array_slice(array_keys($formulas), 0, 5);
    $formulas = array_keys($formulas);
    echo '<ol>';
    foreach ($formulas as $value) {
        //echo '<li class="list-group-item">';
        echo '<li>';
        echo render_value($dbc, $db_name, $value, true);
        echo '<p/></li>';
    }
    echo '</ol>';
}
Example #4
0
/**
 * 按考试名称,对成绩进行汇总
 * 学生学号,科目。。。,总分,年级排名,年级进退
 */
function scoreStatistics($class_code, $prj_id)
{
    //获取考试科目
    $subjects = get_subjects($class_code, $prj_id);
    if (count($subjects) < 1) {
        return array();
    }
    //获取考试成绩
    $sql = "select * FROM " . $GLOBALS['ecs']->table("score") . " WHERE class_code='" . $class_code . "' AND prj_id='" . $prj_id . "' AND student_code='" . $_SESSION['student_code'] . "'  ";
    $scores = $GLOBALS['db']->getAll($sql);
    //获取年级排名
    $sql = "select * FROM " . $GLOBALS['ecs']->table("grade_rank") . " WHERE class_code='" . $class_code . "' AND prj_id='" . $prj_id . "' AND student_code='" . $_SESSION['student_code'] . "' ";
    $grade_rank = $GLOBALS['db']->getRow($sql);
    //获取学生
    $s = get_student($class_code, $_SESSION['student_code']);
    $res = array();
    //学生学号,科目。。。,总分,年级排名,年级进退
    $res[$s['code']]['student_code'] = $s['code'];
    $res[$s['code']]['student_name'] = $s['name'];
    $total = 0;
    foreach ($subjects as $subject) {
        $hasScore = false;
        foreach ($scores as $score) {
            if ($score['subject'] == $subject['subject']) {
                $res[$s['code']][$score['subject']] = $score['score'];
                //科目=》成绩
                $total += $score['score'];
                $hasScore = true;
                break;
            }
        }
        if (!$hasScore) {
            $res[$s['code']][$subject["subject"]] = '';
            //科目=》成绩
        }
    }
    $res[$s['code']]['total'] = $total;
    //总分
    $res[$s['code']]['grade_rank'] = $grade_rank['grade_rank'];
    //年级排名
    $res[$s['code']]['up_down'] = $grade_rank['up_down'];
    //年级进退
    // 	print_r($res);
    return $res;
}
 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');
 }
 protected function subjects()
 {
     global $db;
     $params = array();
     if ($this->method == "GET") {
         if (sizeof($this->args) == 0) {
             return get_subjects($db, $params);
         } else {
             return "This returns all subjects, therefore no parameters are taken!";
         }
     } else {
         return "This only accepts GET requests!";
     }
 }
Example #7
0
<?php

define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
// require_once(ROOT_PATH. 'data/jpgraph/jpgraph.php');
// require_once(ROOT_PATH. 'data/jpgraph/jpgraph_line.php');
// require_once(ROOT_PATH. 'data/jpgraph/jpgraph_scatter.php');
// $graph = new Graph(800,600);	//图形大小
//查询条件加载
//班级所有学生
$students = get_students($_SESSION["class_code"]);
// print_r($students);echo '<br>';
//班级所有考试科目
$subjects = get_subjects($_SESSION["class_code"]);
// print_r($subjects);echo '<br>';
// if ($_REQUEST['act'] == 'score_trend')//学生历次考试成绩走势图
// {
// 	$student_code = empty($_REQUEST['search_student_code']) ? '' : trim($_REQUEST['search_student_code']);//学生学号
// 	$subject = empty($_REQUEST['search_subject']) ? '' : trim($_REQUEST['search_subject']);//科目
// 	$list = get_scores_by_exam($class_code, "", "", $student_code, " s.exam_code", $subject);
// 	$student = $list[0]["student_name"];
// 	$title = $student_code."-".$student."同学历次考试成绩走势图";
// 	$X = array();//横轴——历年的考试名称
// 	foreach($list as $k=>$v){
// 		$X[] = $v["exam_name"];
// 	}
// // 	print_r($X);echo '<br>';
// 	$X = array('A','B','C','D');
// 	$graph = score_trend($title, $X);
// }
require_once ROOT_PATH . 'data/jpgraph/jpgraph.php';
Example #8
0
    $id = get_entity_of_type($dbc, $name, $question_type);
    if ($id != '') {
        array_push($ids, $id);
    }
}
if (!empty($ids)) {
    echo '<p>您输入的症状集合为:';
    foreach ($ids as $id) {
        echo '&nbsp;' . render_value($dbc, $db_name, PREFIX . $id, false);
    }
    echo '</p>';
    echo '<hr>';
    echo '<p>&nbsp;系统为您推荐如下的证候:</p>';
    $formulas = array();
    foreach ($ids as $id) {
        $values = array_merge(get_subjects($dbc, PREFIX . $id, "由...组成"), get_values($dbc, PREFIX . $id, "组成"));
        foreach ($values as $value) {
            if (array_key_exists($value, $formulas)) {
                $formulas[$value] = $formulas[$value] + 1;
            } else {
                $formulas[$value] = 1;
            }
        }
    }
    arsort($formulas);
    //print_r($syndromes);
    $formulas = array_slice(array_keys($formulas), 0, 5);
    //echo '<ul class="list-group">';
    echo '<ol >';
    foreach ($formulas as $value) {
        //echo '<li class="list-group-item">';
Example #9
0
				<td>
					<select name="ageto">
						<?php 
echo options_html(16, 80);
?>
					</select>
				</td>			
				<td>
					<select name="category">
						<?php 
echo options_html(NULL, NULL, NULL, true);
?>
					</select>
				</td>	
		<?php 
$subjs = get_subjects();
foreach ($subjs as $id => $name) {
    ?>
				<td>
					<select name="subj<?php 
    echo $id;
    ?>
">
						<?php 
    echo options_html(1, 10);
    ?>
					</select>
				</td>			
				<td>
					<select name="subjto<?php 
    echo $id;
Example #10
0
    if ($id == 0) {
        //insert
        $sql = "insert into " . $ecs->table("exam_prj") . " (name,class_code,created )\r\n\t\tvalues \r\n\t\t\t('" . $_REQUEST["name"] . "','" . $_SESSION["class_code"] . "',\r\n\t\t\tnow())";
        $db->query($sql);
        admin_log(addslashes($_REQUEST["name"]), 'add', 'exam_prj');
        make_json_result("添加“" . $_REQUEST["name"] . "”成功!");
    } else {
        $sql = "update " . $ecs->table("exam_prj") . " set name='" . $_REQUEST["name"] . "'\r\n\t\t\twhere prj_id=" . $id;
        $db->query($sql);
        admin_log(addslashes($_REQUEST["name"]), 'update', 'exam_prj');
        make_json_result("修改“" . $id . "," . $_REQUEST["name"] . "”成功!");
    }
} elseif ($_REQUEST['act'] == 'ajax_delete') {
    $id = !empty($_REQUEST['prj_id']) ? intval($_REQUEST['prj_id']) : 0;
    //如果做了考试安排,则不能删除
    $subjects = get_subjects($class_code, $id);
    if (count($subjects) > 0) {
        make_json_error("《" . get_exam_prj_name($id) . "》已经做了考试安排,不能直接删除!");
        exit;
    }
    $sql = "select count(1) from " . $ecs->table("score") . " where prj_id=" . $id;
    if ($db->getOne($sql)) {
        make_json_error("《" . get_exam_prj_name($id) . "》已经在成绩录入中已使用,不能直接删除!");
        exit;
    }
    $sql = "delete from " . $ecs->table("exam_prj") . " where prj_id=" . $id;
    $db->query($sql);
    admin_log($_REQUEST["prj_id"], 'delete', 'exam_prj');
    make_json_result("删除成功!");
}
/**
Example #11
0
function get_form_by_edit($persons_edit)
{
    ?>
	<form method='get' >	
		<table class="edit" >
			<tr>
                                <td>Name</td>
                                <td>Surname</td>
                                <td>Age</td>
                                <td>Category</td>
		<?php 
    $subjs = get_subjects();
    foreach ($subjs as $id => $name) {
        ?>
 
                                <td><?php 
        echo $name;
        ?>
</td>
		<?php 
    }
    ?>
                                <td class="red">Delete</td>
                        </tr>

	<?php 
    $n = 1;
    foreach ($persons_edit as $key => $person) {
        ?>
			<tr>
				<td>
					<input type='text' name='key<?php 
        echo $n;
        ?>
'value='<?php 
        echo $key;
        ?>
'style='display:none;'/>
					<input type='text' value='<?php 
        echo $person["Name"];
        ?>
'name='Name<?php 
        echo $n;
        ?>
' />
				</td>
				<td>
					<input type='text' value='<?php 
        echo $person["Surname"];
        ?>
'name='Surname<?php 
        echo $n;
        ?>
' />
				</td>
				<td>
					<select name='Age<?php 
        echo $n;
        ?>
' >
						<?php 
        echo options_html(16, 80, $person['Age']);
        ?>
					</select>
				</td>
				<td>
					<select name='Category<?php 
        echo $n;
        ?>
' >
						<?php 
        echo options_html(NULL, NULL, NULL, $person['Category']);
        ?>
					</select>
				</td>

		<?php 
        foreach ($subjs as $id => $name) {
            ?>
	
				<td>
					<select name='<?php 
            echo $n . "subj" . $id;
            ?>
' >
						<?php 
            echo options_html(1, 10, $person[$name]);
            ?>
					</select>
				</td>
		<?php 
        }
        ?>
				<td>
					<input type='checkbox'name='del<?php 
        echo $n;
        ?>
' >
				</td>
			</tr>
	<?php 
        $n++;
    }
    ?>
			<tr>
				<td colspan=7>
					<input type='submit' name='update' value='Update' />
				</td>
			</tr>
		</table>
	</form>
<?php 
}
Example #12
0
        $sql = "update " . $ecs->table("score") . " set subject='" . $_REQUEST["exam_subject"] . "',\r\n\t\t\tstudent_code='" . $_REQUEST["student_code"] . "',\r\n\t\t\tprj_id='" . $exam_prj . "',\r\n\t\t\tscore='" . $_REQUEST["score"] . "'\r\n\t\t\twhere score_id=" . $id;
        $db->query($sql);
        admin_log(addslashes($_REQUEST["student_code"]), 'update', $sql);
        make_json_result("修改成功!");
    }
} elseif ($_REQUEST['act'] == 'ajax_delete') {
    $id = !empty($_REQUEST['score_id']) ? trim($_REQUEST['score_id']) : "";
    $sql = "delete from " . $ecs->table("score") . " where score_id in (" . $id . ")";
    $db->query($sql);
    admin_log($_REQUEST["score_id"], 'delete', 'score');
    make_json_result("删除成功!");
} elseif ($_REQUEST['act'] == 'exportbyprj') {
    $prj_id = empty($_REQUEST['search_prj_id']) ? '' : trim($_REQUEST['search_prj_id']);
    //考试名称
    //获取这个项目所有的考试科目
    $subjects = get_subjects($class_code, $prj_id);
    $content = "学号,姓名,";
    foreach ($subjects as $k => $v) {
        $content .= $v["subject"] . ",";
        //"-".$v["subject"].
    }
    $content .= "总分\n";
    $list = get_scores_by_exam($class_code, $prj_id, $_SESSION["student_code"], "", " s.student_code");
    $students = array();
    foreach ($list as $k => $v) {
        $student = array();
        $student["student_code"] = $v["student_code"];
        $student["student_name"] = $v["student_name"];
        $student[$v["subject"]] = $v["score"];
        //科目对于成绩
        $isExsit = false;
 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');
 }
                print_error('cantaddsubject', 'attforblock', "addsubjects.php?id={$id}");
            }
            break;
    }
}
show_tabs($cm, $context, 'subjects');
if ($submitsettings) {
    config_save();
    //////////////////////////////
    notice(get_string('subjectsupdated', 'attforblock'), 'addsubjects.php?id=' . $id);
}
$i = 1;
$table->width = '400px';
$table->head = array('#', get_string('subject', 'attforblock'), get_string('action'));
$table->align = array('center', 'center', 'center', 'center');
$subjects = get_subjects($course->id, true);
$deltitle = get_string('delete');
if (count_records_select('attendance_subjects', 'deleted = 0')) {
    // check if session titles exist
    foreach ($subjects as $st) {
        $table->data[$i][] = $i;
        $table->data[$i][] = '<input type="text" name="subject[' . $st->id . ']" size="30" maxlength="30" value="' . $st->subject . '" />';
        $deleteact = "<a title=\"{$deltitle}\" href=\"addsubjects.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="newsubject" 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="addsubjects.php" onsubmit="return validateSession()">';