예제 #1
0
 public function batch_save_solutions($task_set_id)
 {
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->get_by_id($task_set_id);
     if ($task_set->exists()) {
         $data = $this->input->post('batch_valuation');
         $saved_count = 0;
         $save_status = TRUE;
         if (is_array($data) && count($data) > 0) {
             foreach ($data as $student_id => $solution_data) {
                 $student = new Student();
                 $student->get_by_id($student_id);
                 $task_set_check = new Task_set();
                 $task_set_check->where_related('course/participant/student', 'id', intval($student_id));
                 $task_set_check->where_related('course/participant', 'allowed', 1);
                 $task_set_check->group_start();
                 $task_set_check->or_group_start();
                 $task_set_check->group_start();
                 $task_set_check->or_where('group_id', NULL);
                 $task_set_check->or_where('`course_participants`.`group_id` = `task_sets`.`group_id`');
                 $task_set_check->group_end();
                 $task_set_check->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
                 $task_set_check->group_end();
                 $task_set_check->or_where_related('task_set_permission', '`group_id` = `course_participants`.`group_id`');
                 $task_set_check->or_where_related('solution', 'student_id', $student->id);
                 $task_set_check->group_end();
                 $task_set_check->get_by_id($task_set_id);
                 if ($student->exists() && $task_set_check->exists() && array_key_exists('points', $solution_data) && is_numeric($solution_data['points'])) {
                     $solution = new Solution();
                     $solution->where_related_student('id', $student->id);
                     $solution->where_related_task_set('id', $task_set->id);
                     $solution->get();
                     if (is_null($solution->points) || floatval($solution->points) !== floatval($solution_data['points']) || $solution->not_considered != intval(@$solution_data['not_considered'])) {
                         $solution->teacher_id = $this->usermanager->get_teacher_id();
                         $solution->points = floatval($solution_data['points']);
                         $solution->revalidate = 0;
                         $solution->not_considered = intval(@$solution_data['not_considered']);
                         $save_status = $save_status & $solution->save(array($task_set, $student));
                         $saved_count++;
                     }
                 }
             }
         }
         if ($this->db->trans_status() && $save_status && $saved_count > 0) {
             $this->db->trans_commit();
             $this->messages->add_message('lang:admin_solutions_batch_valuation_success_message_save_ok', Messages::MESSAGE_TYPE_SUCCESS);
             $this->_action_success();
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_solutions_batch_valuation_error_message_save_failed', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message('lang:admin_solutions_batch_valuation_error_message_save_failed', Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(create_internal_url('admin_solutions/batch_valuation_list/' . $task_set_id));
 }
예제 #2
0
 public function select_group()
 {
     $group_id = $this->input->post('group_id');
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $group = new Group();
     $group->get_by_id($group_id);
     if ($group->exists()) {
         $course = $group->course->get();
         if (is_null($course->groups_change_deadline) || date('U', strtotime($course->groups_change_deadline)) >= time()) {
             $student = new Student();
             $student->get_by_id($this->usermanager->get_student_id());
             if ($student->is_related_to('active_course', $course->id)) {
                 $participant = new Participant();
                 $participant->where_related($student);
                 $participant->where_related($course);
                 $participant->where('allowed', 1);
                 $participant->get();
                 if ($participant->exists()) {
                     if (!$participant->is_related_to($group)) {
                         $participant->save($group);
                         $participant->where_related($course);
                         $participant->where_related($group);
                         $participant->where('allowed', 1);
                         $participants_count = $participant->count();
                         $room = new Room();
                         $room->where_related($group)->order_by('capacity', 'asc')->limit(1)->get();
                         if ($participants_count > intval($room->capacity)) {
                             $this->db->trans_rollback();
                             $this->messages->add_message('lang:groups_message_group_is_full', Messages::MESSAGE_TYPE_ERROR);
                         } else {
                             $this->db->trans_commit();
                             $this->messages->add_message(sprintf($this->lang->line('groups_message_group_changed'), $this->lang->text($group->name)), Messages::MESSAGE_TYPE_SUCCESS);
                             $this->_action_success();
                             $this->output->set_internal_value('course_id', $participant->course_id);
                         }
                     } else {
                         $this->db->trans_rollback();
                         $this->messages->add_message('lang:groups_message_you_are_in_group', Messages::MESSAGE_TYPE_ERROR);
                     }
                 } else {
                     $this->db->trans_rollback();
                     $this->messages->add_message('lang:groups_message_cant_found_participant_record', Messages::MESSAGE_TYPE_ERROR);
                 }
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:groups_message_cant_change_group_of_inactive_course', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:groups_message_groups_switching_disabled', Messages::MESSAGE_TYPE_ERROR);
         }
     } else {
         $this->db->trans_rollback();
         $this->messages->add_message('lang:groups_message_group_not_found', Messages::MESSAGE_TYPE_ERROR);
     }
     redirect(create_internal_url('groups'));
 }
}
if ($page > $total_pages) {
    $page = $total_pages;
}
$start = $limit * $page - $limit;
if ($start < 0) {
    $start = 0;
}
if (!$sidx) {
    $sidx = 1;
}
$grades = Grade::get_by_sql("SELECT * FROM " . T_STUDENT_GRADES . $where . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($grades as $grade) {
    $student = Student::get_by_id($grade->student_id);
    $s .= "<row id='" . $grade->id . "'>";
    $s .= "<cell></cell>";
    $s .= "<cell>" . $grade->id . "</cell>";
    $s .= "<cell>" . $grade->grade . "</cell>";
    $s .= "<cell>" . $grade->subject_id . "</cell>";
    $s .= "<cell>" . $student->id . "</cell>";
    $s .= "<cell>" . $student->get_full_name() . "</cell>";
    $s .= "</row>";
}
$s .= "</rows>";
echo $s;
        $discovery->referrals = $_POST['e_referrals'];
        $discovery->others = $_POST['e_others'];
        $discovery->update();
        //----------------------------------------------------------------------------------------------------------------------------------//
        $enrollmentDetail = EnrollmentDetail::get_by_id($student->enrollment_detail_id);
        $enrollmentDetail->status = $_POST['f_status'];
        $enrollmentDetail->program = $_POST['f_program'];
        $enrollmentDetail->schedule = $_POST['f_schedule'];
        $enrollmentDetail->payment = $_POST['f_payment'];
        $enrollmentDetail->studentcontactnumber = $_POST['f_studentcontactnumber'];
        $enrollmentDetail->update();
        //----------------------------------------------------------------------------------------------------------------------------------//
        $appointmentDetail = AppointmentDetail::get_by_id($student->appointment_detail_id);
        $appointmentDetail->visitschedule = strtotime($_POST['g_visitschedule']);
        $appointmentDetail->visitpurpose = $_POST['g_visitpurpose'];
        $appointmentDetail->officer = $_POST['g_officer'];
        $appointmentDetail->update();
        //----------------------------------------------------------------------------------------------------------------------------------//
    } else {
        if ($_POST['oper'] == 'del') {
            $student = Student::get_by_id($_POST['id']);
            $student->delete();
            AppointmentDetail::get_by_id($student->appointment_detail_id)->delete();
            EnrollmentDetail::get_by_id($student->enrollment_detail_id)->delete();
            StiDiscovery::get_by_id($student->sti_discovery_id)->delete();
            SchoolConsidered::get_by_id($student->school_considered_id)->delete();
            SchoolLastAttended::get_by_id($student->school_last_attended_id)->delete();
            PersonalInformation::get_by_id($student->personal_information_id)->delete();
        }
    }
}
?>
</h2>
        <h2>Subjects and Grades of <?php 
echo Student::get_by_id($student_id)->get_full_name();
?>
</h2>
        <h2>Course <?php 
echo Course::get_by_id(Student::get_by_id($student_id)->course_id)->code;
?>
</h2>
        <h2>Semester <?php 
echo Student::get_by_id($student_id)->semester;
?>
</h2>
        <h2>Year <?php 
echo Student::get_by_id($student_id)->year;
?>
</h2>
    </header>

    <section id="main_section">

        <section id="main_content">

          <a href="#" id="btn-message" style="color:white; background: #3182c1; border:none;">Send Message to Admins</a>
          <a href="logout.php" style="color:white; background: #3182c1; border:none;">Logout</a>

          <div id="tabs">
              <ul>
                  <li><a href="student_grades_subjects2.php?student_id=<?php 
echo $student_id;
예제 #6
0
 public function add_participant()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('participant[course]', 'lang:admin_participants_form_field_course', 'required');
     $this->form_validation->set_rules('participant[students][]', 'lang:admin_participants_form_field_students', 'required');
     if ($this->form_validation->run()) {
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $process_ok = TRUE;
         $participant_data = $this->input->post('participant');
         $course = new Course();
         $course->get_by_id(intval($participant_data['course']));
         $group = new Group();
         $group->get_by_id(intval(@$participant_data['group']));
         if (!$course->exists()) {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_participants_message_course_not_exists', Messages::MESSAGE_TYPE_ERROR);
             $process_ok = FALSE;
         }
         if ($process_ok && $course->exists()) {
             if ($group->exists() && !$group->is_related_to($course)) {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_participants_message_group_not_belongs_to_course', Messages::MESSAGE_TYPE_ERROR);
                 $process_ok = FALSE;
             }
         }
         $disapproved = 0;
         $added = 0;
         if ($process_ok) {
             foreach ($participant_data['students'] as $student_id) {
                 $student = new Student();
                 $student->where_related('participant/course', 'id', $course->id);
                 $student->get_by_id($student_id);
                 if ($student->exists()) {
                     continue;
                 }
                 $student->get_by_id($student_id);
                 $participant = new Participant();
                 $participant->allowed = intval(@$participant_data['allowed']);
                 $participant->save(array($student, $course, $group));
                 $added++;
                 if ($participant->allowed == 1) {
                     $disallowe_participant = FALSE;
                     if ($course->participant->where('allowed', 1)->count() > intval($course->capacity)) {
                         $disallowe_participant = TRUE;
                     }
                     if ($group->exists()) {
                         $group_for_test = new Group();
                         $rooms = $group_for_test->room;
                         $rooms->select_min('capacity');
                         $rooms->where('group_id', '${parent}.id', FALSE);
                         $group_for_test->select_subquery($rooms, 'group_capacity');
                         $group_for_test->include_related_count('participant');
                         $group_for_test->where_related_participant('allowed', 1);
                         $group_for_test->get_by_id(intval($group->id));
                         if ($group_for_test->exists()) {
                             if (intval($group_for_test->participant_count) > intval($group_for_test->group_capacity)) {
                                 $disallowe_participant = TRUE;
                             }
                         }
                     }
                     if ($disallowe_participant) {
                         $participant->allowed = 0;
                         $participant->save();
                         $disapproved++;
                     }
                 }
             }
         }
         if ($this->db->trans_status() && $process_ok) {
             $this->db->trans_commit();
             $info_approved = intval(@$participant_data['allowed']) == 1 ? $added - $disapproved : 0;
             $info_disappoved = intval(@$participant_data['allowed']) == 1 ? $disapproved : $added;
             $message = sprintf($this->lang->line('admin_participants_message_addition_successfull'), $info_approved, $info_disappoved);
             $this->messages->add_message($message, Messages::MESSAGE_TYPE_SUCCESS);
             $this->_action_success();
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_participants_messages_error_in_addition_transaction', Messages::MESSAGE_TYPE_ERROR);
         }
         redirect(create_internal_url('admin_participants/add_participant_form'));
     } else {
         $this->add_participant_form();
     }
 }
예제 #7
0
 private function get_task_set($task_set_id, &$course, &$student)
 {
     $student = new Student();
     $student->get_by_id($this->usermanager->get_student_id());
     $course = new Course();
     $course->where_related('active_for_student', 'id', $student->id);
     $course->where_related('participant', 'student_id', $student->id);
     $course->where_related('participant', 'allowed', 1);
     $course->include_related('period', 'name');
     $course->get();
     $task_set = new Task_set();
     if ($course->exists()) {
         $task_set->where('published', 1);
         $task_set->where_related_course($course);
         $task_set->include_related('solution');
         $task_set->add_join_condition('`solutions`.`student_id` = ?', array($student->id));
         $task_set->include_related('solution/teacher', 'fullname');
         $task_set->include_related_count('task', 'total_tasks');
         $task_set->where('content_type', 'project');
         $task_set->include_related('project_selection');
         $task_set->add_join_condition('`project_selections`.`student_id` = ? AND `project_selections`.`task_set_id` = `task_sets`.`id`', array($student->id));
         $task_set->include_related('project_selection/task');
         $task_set->order_by('publish_start_time', 'asc');
         $task_set->order_by('upload_end_time', 'asc');
         $task_set->order_by_with_overlay('name', 'asc');
         $task_set->get_by_id((int) $task_set_id);
     }
     return $task_set;
 }
    <header id="main_header">
        <h1>Subject Evaluation System</h1>
        <h2>Subjects and Grades of <?php 
echo Student::get_by_id($_GET['student_id'])->get_full_name();
?>
</h2>
        <h2>Course <?php 
echo Course::get_by_id(Student::get_by_id($_GET['student_id'])->course_id)->code;
?>
</h2>
        <h2>Semester <?php 
echo Student::get_by_id($_GET['student_id'])->semester;
?>
</h2>
        <h2>Year Level <?php 
echo Student::get_by_id($_GET['student_id'])->year;
?>
</h2>
    </header>

    <section id="main_section">

        <section id="main_content">

          <a href="logout.php" style="color:white;">Logout</a>
          
          <div id="tabs">
              <ul>

                  <?php 
$student_grades_subjects_enabled = false;
예제 #9
0
 public function log_in_as_student()
 {
     $uri_data = $this->uri->ruri_to_assoc(3);
     if (isset($uri_data['student_id'])) {
         $student = new Student();
         $student->get_by_id((int) $uri_data['student_id']);
         if ($this->usermanager->force_student_login($student)) {
             $this->messages->add_message('lang:students_force_loged_in', Messages::MESSAGE_TYPE_SUCCESS);
             redirect(create_internal_url('/'));
         }
     }
     $this->messages->add_message('lang:admin_students_failed_to_force_login', Messages::MESSAGE_TYPE_ERROR);
     redirect(create_internal_url('admin_students'));
 }
예제 #10
0
 public function select_project($task_set_id, $task_id, $student_id)
 {
     $output = new stdClass();
     $output->message = '';
     $output->status = FALSE;
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $task_set = new Task_set();
     $task_set->where('content_type', 'project');
     $task_set->get_by_id((int) $task_set_id);
     $task = new Task();
     $task->get_by_id((int) $task_id);
     $student = new Student();
     $student->get_by_id((int) $student_id);
     $course = new Course();
     $course->where_related_task_set($task_set);
     $course->get();
     $participant = new Participant();
     $participant->where_related_course($course);
     $participant->where_related($student);
     $participant->where('allowed', 1);
     $participant->get();
     $project_selection = new Project_selection();
     $project_selection->where_related_student($student);
     $project_selection->where_related_task_set($task_set);
     $project_selection->get();
     if ($task_set->exists() && $task->exists() && $task_set->is_related_to($task) && $student->exists() && $course->exists() && $participant->exists()) {
         if ($task_set->get_student_files_count($student->id) == 0) {
             $all_project_selections = new Project_selection();
             $all_project_selections->where_related_task_set($task_set);
             $all_project_selections->where_related_task($task);
             $currently_selected = $all_project_selections->count();
             $jf_task = $task_set->task->include_join_fields()->get_by_id($task_id);
             $maximum_selections = (int) $jf_task->join_max_projects_selections;
             if ($project_selection->exists()) {
                 if (!$project_selection->is_related_to($task)) {
                     if ($currently_selected < $maximum_selections) {
                         $project_selection->save($task);
                         $output->status = TRUE;
                         $output->message = $this->lang->line('admin_task_sets_project_selection_success');
                     } else {
                         $output->message = $this->lang->line('admin_task_sets_project_selection_no_room');
                     }
                 } else {
                     $output->message = $this->lang->line('admin_task_sets_project_selection_already_selected');
                 }
             } else {
                 if ($currently_selected < $maximum_selections) {
                     $project_selection->save(array('student' => $student, 'task_set' => $task_set, 'task' => $task));
                     $output->status = TRUE;
                     $output->message = $this->lang->line('admin_task_sets_project_selection_success');
                 } else {
                     $output->message = $this->lang->line('admin_task_sets_project_selection_no_room');
                 }
             }
         } else {
             $output->message = $this->lang->line('admin_task_sets_project_selection_already_submited_solutions');
         }
     } else {
         $output->message = $this->lang->line('admin_task_sets_project_selection_cant_find_data');
     }
     if ($output->status) {
         $this->db->trans_commit();
         $this->_action_success();
     } else {
         $this->db->trans_rollback();
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
if (!$sidx) {
    $sidx = 1;
}
$result = mysql_query("SELECT DISTINCT " . C_EVALUATED_STUDENT_ID . " FROM " . T_EVALUATED_SUBJECTS);
$distinct_ids = array();
while ($row = mysql_fetch_array($result)) {
    array_push($distinct_ids, $row['student_id']);
}
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($distinct_ids as $id) {
    $this_student = Student::get_by_id($id);
    $s .= "<row id='" . $this_student->id . "'>";
    $s .= "<cell></cell>";
    $s .= "<cell>" . $this_student->id . "</cell>";
    $s .= "<cell>" . $this_student->student_id . "</cell>";
    $s .= "<cell>" . $this_student->password . "</cell>";
    $s .= "<cell>" . $this_student->first_name . "</cell>";
    $s .= "<cell>" . $this_student->middle_name . "</cell>";
    $s .= "<cell>" . $this_student->last_name . "</cell>";
    $s .= "<cell>" . Course::get_by_id($this_student->course_id)->code . "</cell>";
    $s .= "<cell>" . $this_student->semester . "</cell>";
    $s .= "<cell>" . $this_student->year . "</cell>";
    $s .= "</row>";
}
$s .= "</rows>";
echo $s;
예제 #12
0
 private function get_task_set_by_id(&$course, &$group, &$student, $task_set_id)
 {
     $student = new Student();
     $student->get_by_id($this->usermanager->get_student_id());
     $course = new Course();
     $course->where_related('active_for_student', 'id', $student->id);
     $course->where_related('participant', 'student_id', $student->id);
     $course->where_related('participant', 'allowed', 1);
     $course->include_related('period', 'name');
     $course->get();
     $task_set = new Task_set();
     $task_set2 = new Task_set();
     $group = new Group();
     if ($course->exists()) {
         $group->where_related_participant('student_id', $student->id);
         $group->where_related_participant('course_id', $course->id);
         $group->get();
         $task_set->select('`task_sets`.*, `rooms`.`time_day` AS `pb_time_day`, `rooms`.`time_begin` AS `pb_time_begin`, `rooms`.`id` AS `pb_room_id`, `task_sets`.`publish_start_time` AS `pb_publish_start_time`, `task_sets`.`upload_end_time` AS `pb_upload_end_time`');
         $task_set->where('published', 1);
         $task_set->where_related_course($course);
         $task_set->include_related('solution');
         $task_set->add_join_condition('`solutions`.`student_id` = ?', array($student->id));
         $task_set->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
         $task_set->group_start();
         $task_set->or_where('group_id', NULL);
         $task_set->or_where('group_id', $group->id);
         $task_set->group_end();
         $task_set->include_related('room', '*', TRUE, TRUE);
         $task_set->include_related_count('task', 'total_tasks');
         $task_set->include_related('task_set_type');
         $task_set->select_subquery('(SELECT SUM(`points_total`) AS `points` FROM `task_task_set_rel` WHERE `task_set_id` = `${parent}`.`id` AND `task_task_set_rel`.`bonus_task` = 0)', 'total_points');
         $task_set->where('id', $task_set_id);
         $task_set->include_related('course', 'test_scoring_deadline');
         $task_set->where('content_type', 'task_set');
         $task_set2->select('`task_sets`.*, `task_set_permission_rooms`.`time_day` AS `pb_time_day`, `task_set_permission_rooms`.`time_begin` AS `pb_time_begin`, `task_set_permission_rooms`.`id` AS `pb_room_id`, `task_set_permissions`.`publish_start_time` AS `pb_publish_start_time`, `task_set_permissions`.`upload_end_time` AS `pb_upload_end_time`');
         $task_set2->where('published', 1);
         $task_set2->where_related_course($course);
         $task_set2->where_related('task_set_permission', 'group_id', $group->id);
         $task_set2->where_related('task_set_permission', 'enabled', 1);
         $task_set2->include_related('solution');
         $task_set2->add_join_condition('`solutions`.`student_id` = ?', array($student->id));
         $task_set2->include_related('task_set_permission/room', '*', 'room', TRUE);
         $task_set2->include_related_count('task', 'total_tasks');
         $task_set2->include_related('task_set_type');
         $task_set2->select_subquery('(SELECT SUM(`points_total`) AS `points` FROM `task_task_set_rel` WHERE `task_set_id` = `${parent}`.`id` AND `task_task_set_rel`.`bonus_task` = 0)', 'total_points');
         $task_set2->where('id', $task_set_id);
         $task_set2->include_related('course', 'test_scoring_deadline');
         $task_set2->where('content_type', 'task_set');
         $task_set3 = new Task_set();
         $task_set3->select('`task_sets`.*, NULL AS `pb_time_day`, NULL AS `pb_time_begin`, NULL AS `pb_room_id`, NULL AS `pb_publish_start_time`, "0000-00-00 00:00:00" AS `pb_upload_end_time`', FALSE);
         $task_set3->where('published', 1);
         $task_set3->where_related_course($course);
         $task_set3->include_related('solution');
         $task_set3->add_join_condition('`solutions`.`student_id` = ?', array($student->id));
         $task_set3->where_related('solution', 'student_id', $student->id);
         $task_set3->include_related('room', '*', TRUE, TRUE);
         $task_set3->include_related_count('task', 'total_tasks');
         $task_set3->include_related('task_set_type');
         $task_set3->select_subquery('(SELECT SUM(`points_total`) AS `points` FROM `task_task_set_rel` WHERE `task_set_id` = `${parent}`.`id` AND `task_task_set_rel`.`bonus_task` = 0)', 'total_points');
         $task_set3->where('id', $task_set_id);
         $task_set3->include_related('course', 'test_scoring_deadline');
         $task_set3->where('content_type', 'task_set');
         $task_set2->union(array($task_set, $task_set3), FALSE, '', 1, 0, 'id');
     }
     return $task_set2;
 }
예제 #13
0
 public function evaluate_test_result($task_set_id, $student_id, $version, $test_type, $token)
 {
     $task_set = new Task_set();
     $task_set->include_related('course', 'test_scoring_deadline');
     $task_set->get_by_id((int) $task_set_id);
     $student = new Student();
     $student->get_by_id((int) $student_id);
     $output = new stdClass();
     $output->result = FALSE;
     $output->message = '';
     $output->points_new = 0;
     $output->points_before = 0;
     $this->load->model('test_score');
     if ($task_set->exists() && $student->exists()) {
         if ($task_set->course_test_scoring_deadline >= date('Y-m-d H:i:s') && $task_set->enable_tests_scoring > 0) {
             $results = $this->test_score->get_data_for_student($student->id, $token, $test_type);
             $this->_transaction_isolation();
             $this->db->trans_start();
             $tests = new Test();
             $tests->where_related('task/task_set', 'id', $task_set->id);
             $tests->where('type', $test_type);
             $tests->where('enable_scoring >', 0);
             $tests->group_by('task_id');
             $tests->where('task_task_task_set_rel.bonus_task', 0);
             $tests->get_iterated();
             //$output->debug = $tests->check_last_query(array('', ''), TRUE);
             $test_count = $tests->result_count();
             $min_results = $task_set->test_min_needed > $test_count ? $test_count : $task_set->test_min_needed;
             $course = new Course();
             $course->where_related_task_set('id', $task_set->id);
             $course->get();
             $min_points_limit = -$course->default_points_to_remove;
             if ($test_count > 0) {
                 $total_score = 0;
                 $score_array = array();
                 $bonus_tasks_array = array();
                 $score_percentage = array();
                 $bonus_tasks_percentage = array();
                 if (count($results)) {
                     foreach ($results as $task_id => $score) {
                         $this->db->select('*');
                         $this->db->where('task_set_id', $task_set->id);
                         $this->db->where('task_id', (int) $task_id);
                         $query = $this->db->get('task_task_set_rel');
                         if ($query->num_rows() > 0) {
                             $task_rel = $query->row_object();
                             $min = $task_rel->test_min_points;
                             $max = $task_rel->test_max_points;
                             $diff = abs($max - $min);
                             $score_percent = (double) $score / 100;
                             $sub_score = round(10 * ($min + $diff * $score_percent)) / 10;
                             if ($task_rel->bonus_task == 0) {
                                 $score_array[$task_id] = $sub_score;
                                 $score_percentage[$task_id] = $score;
                             } else {
                                 $bonus_tasks_array[$task_id] = $sub_score;
                                 $bonus_tasks_percentage[$task_id] = $score;
                             }
                         }
                         $query->free_result();
                     }
                 }
                 $max_results = $task_set->test_max_allowed < count($score_array) ? $task_set->test_max_allowed : count($score_array);
                 arsort($score_array, SORT_NUMERIC);
                 $i = 0;
                 foreach ($score_array as $task_id => $points) {
                     if ($i < $max_results) {
                         $total_score += $points;
                         $i++;
                     } else {
                         break;
                     }
                 }
                 $total_score = $total_score < $min_points_limit ? $min_points_limit : $total_score;
                 arsort($bonus_tasks_array, SORT_NUMERIC);
                 $total_score += array_sum($bonus_tasks_array);
                 if (count($score_array) >= $min_results) {
                     $tasks = new Task();
                     $tasks->where_related_task_set('id', $task_set_id);
                     $tasks->order_by('`task_task_set_rel`.`sorting`', 'asc');
                     $tasks->get_iterated();
                     //$output->debug = $tasks->check_last_query(array('', ''), TRUE);
                     $output->evaluation = $this->parser->parse('backend/tests/evaluation_table.tpl', array('tasks' => $tasks, 'real_points' => $score_array, 'bonus_points' => $bonus_tasks_array, 'real_percentage' => $score_percentage, 'bonus_percentage' => $bonus_tasks_percentage, 'max_results' => $max_results), TRUE);
                     $solution = new Solution();
                     $solution->where('task_set_id', $task_set->id);
                     $solution->where('student_id', $student->id);
                     $solution->get();
                     $save_solution = FALSE;
                     $solution_not_considered = FALSE;
                     $output->points_new = $total_score;
                     if ($solution->exists()) {
                         if ($solution->not_considered == 0) {
                             $output->points_before = $solution->points;
                             if ($solution->points < $total_score || is_null($solution->points)) {
                                 $solution->points = $total_score;
                                 $solution->comment = '';
                                 $solution->teacher_id = NULL;
                                 $solution->best_version = (int) $version;
                                 $solution->revalidate = 0;
                                 $save_solution = TRUE;
                             }
                         } else {
                             $solution_not_considered = TRUE;
                         }
                     } else {
                         $solution->points = $total_score;
                         $solution->comment = '';
                         $solution->teacher_id = NULL;
                         $solution->best_version = (int) $version;
                         $solution->task_set_id = $task_set->id;
                         $solution->student_id = $student->id;
                         $solution->revalidate = 0;
                         $save_solution = TRUE;
                     }
                     if ($save_solution) {
                         $solution->save();
                         $output->result = TRUE;
                         $this->_action_success();
                     } else {
                         if (!$solution_not_considered) {
                             $output->message = sprintf($this->lang->line('admin_tests_test_result_nothing_to_update'), $output->points_new, $output->points_before);
                         } else {
                             $output->message = $this->lang->line('admin_tests_test_result_solution_not_considered');
                         }
                     }
                 } else {
                     $output->message = sprintf($this->lang->line('admin_tests_test_result_minimum_number_of_test_not_selected'), $min_results);
                 }
             } else {
                 $output->message = $this->lang->line('admin_tests_test_result_no_evaluationg_tests');
             }
             $this->db->trans_complete();
         } else {
             $output->message = $this->lang->line('admin_tests_test_result_disabled');
         }
     } else {
         $output->message = $this->lang->line('admin_tests_test_result_input_error');
     }
     $this->test_score->delete_token($token);
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($output));
 }
}
$course_id = Course::get_by_sql("SELECT * FROM " . T_COURSES . " WHERE " . C_COURSE_CODE . "='" . trim($_POST['course_code']) . "'")[0]->id;
if ($_POST['oper'] == 'add') {
    $student = new Student();
    $student->student_id = $_POST['student_id'];
    $student->password = $_POST['password'];
    $student->first_name = $_POST['first_name'];
    $student->middle_name = $_POST['middle_name'];
    $student->last_name = $_POST['last_name'];
    $student->course_id = $course_id;
    $student->semester = $_POST['semester'];
    $student->year = $_POST['year'];
    $student->create();
} else {
    if ($_POST['oper'] == 'edit') {
        $student = Student::get_by_id($_POST['id']);
        $student->student_id = $_POST['student_id'];
        $student->password = $_POST['password'];
        $student->first_name = $_POST['first_name'];
        $student->middle_name = $_POST['middle_name'];
        $student->last_name = $_POST['last_name'];
        $student->course_id = $course_id;
        $student->semester = $_POST['semester'];
        $student->year = $_POST['year'];
        $student->update();
    } else {
        if ($_POST['oper'] == 'del') {
            Student::get_by_id($_POST['id'])->delete();
        }
    }
}
    $total_pages = ceil($count / $limit);
} else {
    $total_pages = 0;
}
if ($page > $total_pages) {
    $page = $total_pages;
}
$start = $limit * $page - $limit;
if ($start < 0) {
    $start = 0;
}
if (!$sidx) {
    $sidx = 1;
}
$messages = Message::get_by_sql("SELECT * FROM " . T_MESSAGES . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($messages as $message) {
    $s .= "<row id='" . $message->id . "'>";
    $s .= "<cell></cell>";
    $s .= "<cell>" . $message->id . "</cell>";
    $s .= "<cell>" . $message->message . "</cell>";
    $s .= "<cell>" . Student::get_by_id($message->student_id)->student_id . "</cell>";
    $s .= "</row>";
}
$s .= "</rows>";
echo $s;
예제 #16
0
 public function delete_avatar()
 {
     $this->usermanager->student_login_protected_redirect();
     $student = new Student();
     $student->get_by_id($this->usermanager->get_student_id());
     $student->delete_avatar();
     $this->_action_success();
     redirect(create_internal_url('students/my_account'));
 }
예제 #17
0
 public function activate_course($course_id)
 {
     $this->_initialize_student_menu();
     $this->output->set_content_type('application/json');
     $output = new stdClass();
     $output->status = FALSE;
     $output->message = '';
     $output->content = '';
     $output->metainfo = '';
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $student = new Student();
     $student->get_by_id($this->usermanager->get_student_id());
     $course = new Course();
     $course->get_by_id($course_id);
     if ($course->exists()) {
         $participant = $student->participant->where_related($course)->where('allowed', 1)->get();
         if ($participant->exists()) {
             $student->save($course, 'active_course');
             $this->db->trans_commit();
             $this->usermanager->set_student_data_to_smarty();
             $period = $course->period->get();
             $output->content = $this->parser->parse('frontend/courses/period_courses.tpl', array('period' => $period), TRUE);
             $output->metainfo = $this->parser->parse('partials/frontend_general/selected_course.tpl', array(), TRUE);
             $output->status = TRUE;
             $output->message = sprintf($this->lang->line('courses_message_switched_to_course'), $this->lang->text($course->name) . ' / ' . $this->lang->text($period->name));
             $this->_action_success();
         } else {
             $output->message = $this->lang->line('courses_message_cant_switch_to_unsigned_course');
             $this->db->trans_rollback();
         }
     } else {
         $output->message = $this->lang->line('courses_message_course_not_found');
         $this->db->trans_rollback();
     }
     $this->output->set_output(json_encode($output));
 }
예제 #18
0
 /**
  * This function will send data from student session to smarty template variable called 'list_student_account' and create variable 'list_student_account_model' with student model.
  */
 public function set_student_data_to_smarty()
 {
     $this->CI->load->library('parser');
     $student = new Student();
     if ($this->is_student_session_valid()) {
         $student->get_by_id($this->get_student_id());
         $this->CI->parser->assign('list_student_account', $this->CI->session->userdata(SESSION_AUTH_LOGIN_STUDENT));
     } else {
         $this->CI->parser->assign('list_student_account', array());
     }
     $this->CI->parser->assign('list_student_account_model', $student);
 }
<?php

require_once "../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
    redirect_to("index.php");
}
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$student = Student::get_by_id($_GET['student_id']);
$count = count(Subject::get_by_sql("SELECT * FROM " . T_SUBJECTS));
if ($count > 0 && $limit > 0) {
    $total_pages = ceil($count / $limit);
} else {
    $total_pages = 0;
}
if ($page > $total_pages) {
    $page = $total_pages;
}
$start = $limit * $page - $limit;
if ($start < 0) {
    $start = 0;
}
if (!$sidx) {
    $sidx = 1;
}
$first = $_GET['first'];
if ($first == "true") {
    $future_sem = 1;
        if ($id == $subject->id) {
            return true;
        }
    }
    return false;
}
$student_id = $_GET['student_id'];
$subject_ids = $_POST['subject_ids'];
$student_grades = Grade::get_by_sql("SELECT * FROM " . T_STUDENT_GRADES . " WHERE " . C_GRADE_STUDENT_ID . "=" . $student_id);
$student_subjects = array();
foreach ($student_grades as $student_subject) {
    array_push($student_subjects, Subject::get_by_id($student_subject->subject_id));
}
$warnings = "";
foreach ($subject_ids as $id) {
    $thestudent = Student::get_by_id($student_id);
    $thestudent->semester = Subject::get_by_id($id)->semester;
    $thestudent->update();
    if (Grade::exists($id, $student_id)) {
        $newgrade = Grade::get_by_subj_stud($id, $student_id);
        $newgrade->delete();
    }
    $newgrade = new Grade();
    $newgrade->subject_id = $id;
    $newgrade->student_id = $student_id;
    $newgrade->grade = 0;
    $newgrade->create();
    $pre_subject = Subject::get_by_id($id);
    if (!EvaluatedSubject::exists($id, $student_id)) {
        $grade = Grade::get_by_subj_stud($pre_subject->id, $student_id);
        $gradepre = Grade::get_by_subj_stud($pre_subject->prereq_subject_id, $student_id);
예제 #21
0
 public function index($worker_id = 0)
 {
     $test_queue = new Test_queue();
     $execute_tests = FALSE;
     try {
         $this->db->query('SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;');
         $this->db->trans_begin();
         $test_queue->where('worker', NULL);
         $test_queue->where('status', 0);
         $test_queue->where('version >', 0);
         $test_queue->group_start(' NOT ');
         $test_queue->where('task_set_id', NULL);
         $test_queue->group_end();
         $test_queue->group_start(' NOT ');
         $test_queue->where('student_id', NULL);
         $test_queue->group_end();
         $test_queue->order_by('priority', 'asc');
         $test_queue->order_by('start', 'asc');
         $test_queue->limit(1);
         $sql_query = $test_queue->get_sql();
         $sql_query = rtrim($sql_query, '; ' . "\n\r") . ' FOR UPDATE;';
         $test_queue->query($sql_query);
         if ($test_queue->exists()) {
             $test_queue->worker = (int) $worker_id;
             $test_queue->status = 1;
             $test_queue->exec_start = date('Y-m-d H:i:s');
             $test_queue->where('worker', NULL);
             $test_queue->where('status', 0);
             if ($test_queue->save()) {
                 $this->db->trans_commit();
                 $execute_tests = TRUE;
             } else {
                 $this->db->trans_rollback();
             }
         } else {
             $this->db->trans_rollback();
         }
     } catch (Exception $e) {
     }
     if ($test_queue->exists() && $execute_tests) {
         //$this->db->query('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;');
         //$this->db->trans_begin();
         $this->lang->reinitialize_for_idiom($test_queue->system_language);
         $this->lang->load('admin/tests');
         $task_set = new Task_set();
         $task_set->include_related('course', 'test_scoring_deadline');
         $task_set->get_by_id($test_queue->task_set_id);
         $student = new Student();
         $student->get_by_id($test_queue->student_id);
         $tests = new Test();
         $tests->where_related($test_queue);
         $tests->get_iterated();
         try {
             if ($task_set->exists() && $student->exists() && $tests->exists()) {
                 $version = $test_queue->version;
                 $run_evaluation = $task_set->enable_tests_scoring > 0 && $task_set->course_test_scoring_deadline >= date('Y-m-d H:i:s') ? TRUE : FALSE;
                 $score_percent = array();
                 $score_points = array();
                 $bonus_percent = array();
                 $bonus_points = array();
                 $total_tests_count = $tests->result_count();
                 foreach ($tests as $test) {
                     $test_queue->single_test_exec_start = date('Y-m-d H:i:s');
                     $test_queue->save();
                     $files = $task_set->get_student_files($student->id, (int) $version);
                     if (isset($files[(int) $version]['filepath']) && file_exists($files[(int) $version]['filepath'])) {
                         $test_object = $this->load->test($test->type);
                         $test_object->initialize($test);
                         $token = '';
                         //echo 'Test queue ' . $test_queue->id . ' is running test ' . $test->id . ' ... ' . PHP_EOL;
                         try {
                             $test_output = $test_object->run($files[(int) $version]['filepath'], $run_evaluation && $test->enable_scoring > 0, $student->id, $token);
                             $test_score = $test_object->get_last_test_score();
                         } catch (Exception $e) {
                             $test_output = $e->getMessage();
                             $test_score = 0;
                         }
                         $test_queue->set_join_field($test, 'result_text', $test_output);
                         $test_queue->set_join_field($test, 'evaluation_table', $test_object->get_last_test_scoring());
                         $test_queue->set_join_field($test, 'result', $test_object->get_last_exit_code());
                         //echo 'Test queue ' . $test_queue->id . ' is done with test ' . $test->id . ' ... ' . PHP_EOL;
                         if ($run_evaluation && $test->enable_scoring > 0) {
                             $this->db->select('*');
                             $task_id = $test->task_id;
                             $this->db->where('task_set_id', $task_set->id);
                             $this->db->where('task_id', (int) $task_id);
                             $query = $this->db->get('task_task_set_rel');
                             if ($query->num_rows() > 0) {
                                 $task_rel = $query->row_object();
                                 $min = (double) $task_rel->test_min_points;
                                 $max = (double) $task_rel->test_max_points;
                                 $percent = (double) $test_score / 100.0;
                                 $points = (1.0 - $percent) * $min + $percent * $max;
                                 if ($task_rel->bonus_task == 0) {
                                     $test_queue->set_join_field($test, 'percent_points', $test_score);
                                     $test_queue->set_join_field($test, 'points', $points);
                                     $score_percent[$task_id] = isset($score_percent[$task_id]) ? $score_percent[$task_id] + $percent : $percent;
                                     $percent = (double) $score_percent[$task_id];
                                     $points = (1.0 - $percent) * $min + $percent * $max;
                                     $score_points[$task_id] = $points;
                                 } else {
                                     $test_queue->set_join_field($test, 'percent_bonus', $test_score);
                                     $test_queue->set_join_field($test, 'bonus', $points);
                                     $bonus_percent[$task_id] = isset($bonus_percent[$task_id]) ? $bonus_percent[$task_id] + $percent : $percent;
                                     $percent = (double) $bonus_percent[$task_id];
                                     $points = (1.0 - $percent) * $min + $percent * $max;
                                     $bonus_points[$task_id] = $points;
                                 }
                             }
                             $query->free_result();
                         }
                     } else {
                         //$this->db->trans_rollback();
                         $test_queue->worker = NULL;
                         $test_queue->status = 3;
                         $test_queue->finish = date('Y-m-d H:i:s');
                         $test_queue->save();
                         die;
                     }
                 }
                 $tests = new Test();
                 $tests->where_related('task/task_set', 'id', $task_set->id);
                 $tests->where('type', $test_queue->test_type);
                 $tests->where('enable_scoring >', 0);
                 $tests->group_by('task_id');
                 $tests->where('task_task_task_set_rel.bonus_task', 0);
                 $tests->get_iterated();
                 $test_count = $tests->result_count();
                 $min_results = $task_set->test_min_needed > $test_count ? $test_count : $task_set->test_min_needed;
                 $course = new Course();
                 $course->where_related_task_set('id', $task_set->id);
                 $course->get();
                 $min_points_limit = -$course->default_points_to_remove;
                 if ($test_count > 0 && $run_evaluation) {
                     $max_results = $task_set->test_max_allowed < count($score_points) ? $task_set->test_max_allowed : count($score_points);
                     arsort($score_points, SORT_NUMERIC);
                     $i = 0;
                     $total_score = 0;
                     foreach ($score_points as $task_id => $points) {
                         if ($i < $max_results) {
                             $total_score += $points;
                             $i++;
                         } else {
                             break;
                         }
                     }
                     $total_score = $total_score < $min_points_limit ? $min_points_limit : $total_score;
                     $total_bonus = array_sum($bonus_points);
                     $total_score += $total_bonus;
                     if (count($score_points) >= $min_results) {
                         $solution = new Solution();
                         $solution->where('task_set_id', $task_set->id);
                         $solution->where('student_id', $student->id);
                         $solution->get();
                         $save_solution = FALSE;
                         $solution_not_considered = FALSE;
                         $solution_disable_evaluation = FALSE;
                         $best_old_score = $min_points_limit;
                         if ($solution->exists()) {
                             if ($solution->not_considered == 0) {
                                 if ($solution->disable_evaluation_by_tests == 0) {
                                     if ($solution->tests_points < $total_score || is_null($solution->tests_points)) {
                                         $solution->tests_points = $total_score;
                                         $solution->teacher_id = NULL;
                                         $solution->best_version = (int) $version;
                                         $solution->revalidate = 0;
                                         $save_solution = TRUE;
                                     } else {
                                         $best_old_score = $solution->tests_points;
                                     }
                                 } else {
                                     $solution_disable_evaluation = TRUE;
                                 }
                             } else {
                                 $solution_not_considered = TRUE;
                             }
                         } else {
                             $solution->tests_points = $total_score;
                             $solution->comment = '';
                             $solution->teacher_id = NULL;
                             $solution->best_version = (int) $version;
                             $solution->task_set_id = $task_set->id;
                             $solution->student_id = $student->id;
                             $solution->revalidate = 0;
                             $save_solution = TRUE;
                         }
                         if ($save_solution) {
                             $solution->save();
                             $this->parser->clearCache('frontend/tasks/index.tpl');
                             $test_queue->result_message = $this->lang->line('admin_tests_test_result_new_points_added');
                         } else {
                             if (!$solution_disable_evaluation) {
                                 if (!$solution_not_considered) {
                                     $test_queue->result_message = sprintf($this->lang->line('admin_tests_test_result_nothing_to_update'), $total_score, $best_old_score);
                                 } else {
                                     $test_queue->result_message = $this->lang->line('admin_tests_test_result_solution_not_considered');
                                 }
                             } else {
                                 $test_queue->result_message = $this->lang->line('admin_tests_test_result_solution_disable_evaluation');
                             }
                         }
                         $test_queue->points = $total_score - $total_bonus;
                         $test_queue->bonus = $total_bonus;
                     } else {
                         $test_queue->result_message = sprintf($this->lang->line('admin_tests_test_result_minimum_number_of_test_not_selected'), $min_results);
                     }
                     $result_table_tasks = new Task();
                     $result_table_tasks->where_related_task_set('id', $task_set->id);
                     $result_table_tasks->order_by('`task_task_set_rel`.`sorting`', 'asc');
                     $result_table_tasks->get_iterated();
                     $test_queue->result_html = $this->parser->parse('backend/tests/evaluation_table.tpl', array('tasks' => $result_table_tasks, 'real_points' => $score_points, 'bonus_points' => $bonus_points, 'real_percentage' => $score_percent, 'bonus_percentage' => $bonus_percent, 'max_results' => $max_results), TRUE);
                     $test_queue->worker = NULL;
                     $test_queue->status = 2;
                     $test_queue->finish = date('Y-m-d H:i:s');
                     $test_queue->save();
                     //$this->db->trans_commit();
                 } else {
                     if ($total_tests_count && !$run_evaluation) {
                         $test_queue->worker = NULL;
                         $test_queue->status = 2;
                         $test_queue->finish = date('Y-m-d H:i:s');
                         $test_queue->result_message = $this->lang->line('admin_tests_test_result_testing_finished');
                         $test_queue->save();
                         //$this->db->trans_commit();
                     } else {
                         //$this->db->trans_rollback();
                         $test_queue->worker = NULL;
                         $test_queue->status = 3;
                         $test_queue->finish = date('Y-m-d H:i:s');
                         $test_queue->result_message = $this->lang->line('admin_tests_test_result_no_test_selected');
                         $test_queue->save();
                     }
                 }
             } else {
                 //$this->db->trans_rollback();
                 $test_queue->worker = NULL;
                 $test_queue->status = 3;
                 $test_queue->finish = date('Y-m-d H:i:s');
                 $test_queue->result_message = $this->lang->line('admin_tests_test_result_configuration_error');
                 $test_queue->save();
             }
         } catch (Exception $e) {
             //$this->db->trans_rollback();
             $test_queue->worker = NULL;
             $test_queue->status = 3;
             $test_queue->finish = date('Y-m-d H:i:s');
             $test_queue->result_message = $this->lang->line('admin_tests_test_result_execution_error');
             $test_queue->result_html = '<pre>' . $e->getMessage() . '</pre>';
             $test_queue->save();
         }
     }
     //@unlink($test_locks_path . 'worker_' . (int)$worker_id . '_lock.txt');
 }