Exemplo n.º 1
0
 public static function getInstance() {
     if (!self::$_submission) {
         self::$_submission = new grade_submission();
     }
     return self::$_submission;
 }
Exemplo n.º 2
0
    function definition_after_data() {
        global $DB, $PAGE, $USER, $hierarchy, $exams, $selected_class;

        $hierarchy = new hierarchy();
        $gradesub = new grade_submission();

        $mform = $this->_form;


        $id = $this->_customdata['id'];
        $selected_school = $mform->getElementValue('schoolid');
        $selected_program = array();
        $disable = ($id > 0) ? 'disabled="disabled"' : '';

        // for programs and semesters in a school
        if ($selected_school[0] > 0) {

            $programs_list = array();
            $programs_list = $hierarchy->get_records_cobaltselect_menu('local_program', "schoolid=$selected_school[0] AND visible=1", null, '', 'id,fullname', '--Select--');

            $programs_listdrop = $mform->createElement('select', 'programid', get_string('programslist', 'local_scheduleexam'), $programs_list, $disable);
            $mform->insertElementBefore($programs_listdrop, 'addprogramslisthere');
            if ($id < 0) {
                $mform->addRule('programid', get_string('programreq', 'local_scheduleexam'), 'required', null, 'client');
            }
            $semesters_list = array();
            $semesters_list = $hierarchy->get_school_semesters($selected_school[0]);

            $semesters_listdrop = $mform->createElement('select', 'semesterid', get_string('semesterslist', 'local_scheduleexam'), $semesters_list, $disable);
            $mform->insertElementBefore($semesters_listdrop, 'addsemesterslisthere');
            if ($id < 0) {
                $mform->addRule('semesterid', get_string('semestersreq', 'local_scheduleexam'), 'required', null, 'client');
            }

            $selected_semester = array();
            $selected_semester = $mform->getElementValue('semesterid');
        }

        // for clclasses assigned to a semester
        if (($selected_school[0]) AND ( $selected_semester[0] > 0)) {

            $clclasses_list = array();
            $clclasses_list = $hierarchy->get_records_cobaltselect_menu('local_clclasses', "semesterid=$selected_semester[0] and schoolid=$selected_school[0] AND visible=1", null, '', 'id,fullname', 'Select Class');

            $clclasses_listdrop = $mform->createElement('select', 'classid', get_string('clclasseslist', 'local_scheduleexam'), $clclasses_list, $disable);
            $mform->insertElementBefore($clclasses_listdrop, 'addclclasseslisthere');
            if ($id < 0)
                $mform->addRule('classid', get_string('clclassesreq', 'local_scheduleexam'), 'required', null, 'client');

            $selected_class = array();
            $selected_class = $mform->getElementValue('classid');
        }

        if (!empty($selected_class[0])) {

            $today = time();

            $users = $gradesub->get_class_users($selected_semester[0], $selected_class[0]);
            $exams = $gradesub->get_class_exams($selected_semester[0], $selected_class[0]);

            if (empty($users)) {
                echo '<div style="border:1px groove red; padding:10px;color:red;">' . (get_string('nousers', 'local_gradesubmission')) . '</div>';
            }
            if (empty($exams)) {
                echo '<div style="border:1px groove red; padding:10px;color:red;">' . (get_string('noexam', 'local_gradesubmission')) . '</div>';
            }

            foreach ($exams as $exam) {
                if ($exam->opendate > $today) {
                    $examsnotcomp = 1;
                    echo '<div style="border:1px groove red; padding:10px;color:red;">' . (get_string('examnotcompleted', 'local_gradesubmission')) . '</div>';
                }
            }
        }
    }
Exemplo n.º 3
0
echo '<div class="selfilterpos" id="school">';
$sch = new single_select(new moodle_url('/local/gradesubmission/submitgrades.php'), 'school', $schoolist, $school, null);
$sch->set_label(get_string('schoolid', 'local_collegestructure'));
echo $OUTPUT->render($sch);
echo '</div>';

if (isset($schoolist)) {

    $semesterslist = $hierarchy->get_school_semesters($school);
    echo '<div class="selfilterpos" id="semester">';
    $sem = new single_select(new moodle_url('/local/gradesubmission/submitgrades.php?school=' . $school), 'semester', $semesterslist, $semester, null);
    $sem->set_label(get_string('semester', 'local_semesters'));
    echo $OUTPUT->render($sem);
    echo '</div>';
}
$gradesub = grade_submission::getInstance();
if (isset($semester)) {

    echo '<div class="selfilterpos" id="class" >';

    $clclasseslist = $hierarchy->get_records_cobaltselect_menu('local_clclasses', "schoolid=$school and semesterid=$semester and visible=1", null, '', 'id,fullname', 'Select Class');
    $cls = new single_select(new moodle_url('/local/gradesubmission/submitgrades.php?school=' . $school . '&semester=' . $semester), 'class', $clclasseslist, $class, null);
    $cls->set_label(get_string('class', 'local_clclasses'));
    echo $OUTPUT->render($cls);
    echo '</div>';
}

if (!empty($class)) {
    $today = time();
    $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
    $users = $gradesub->get_class_users($semester, $class);