Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
load->model('User_model');
$this->load->helper("url");
$this->load->library("pagination");
require_once APPPATH."/third_party/PHPExcel.php";
if (!$this->session->userdata('reg_number')) {
$this->session->set_flashdata('flash_data', 'You don\'t have access!');
redirect('Welcome');
}else{
if($this->session->userdata('type')!='super_user'){
$this->session->set_flashdata('flash_data', 'You don\'t have access!');
redirect('Welcome');
}
}
}
function index(){
$this->load->view('includes/super_header');
echo 'super user';
$this->load->view('includes/super_footer');
}
public function clean_sub_subjects(){
$exam = $_REQUEST['exam_id'];
$sql = "DELETE FROM ca
WHERE exam_id = $exam
AND subject_id IN (
SELECT subject_id FROM all_subjects WHERE is_sub = 1
)";
$this->db->query($sql);
redirect($_SERVER['HTTP_REFERER']);
}
public function angalia_ca_sub(){
$exam_id = 79;
foreach($this->db->distinct()->select('subject_id')->where('exam_id',$exam_id)->get('ca')->result() as $sub){
foreach($this->db->where('subject_id',$sub->subject_id)->where('is_sub',1)->get('all_subjects')->result() as $name){
if($name->is_sub == 1){
$count = $this->db->where('exam_id',$exam_id)->where('subject_id',$sub->subject_id)->count_all_results('ca');
if($count > 0){
echo $name->name." - ".$count." ";
//$this->db->where('subject_id',$name->subject_id)->where('exam_id',$exam_id)->delete('ca');
}
}
}
echo " ";
}
echo " SCHOOL GPA ++++++++++++++";
foreach($this->db->where('exam_id',$exam_id)->get('subjects_school_gpa')->result() as $sub){
foreach($this->db->where('subject_id',$sub->subject_id)->get('all_subjects')->result() as $name){
if($name->is_sub == 1){
// tunadelete hapa
echo $name->name." ";
//$this->db->where('subject_id',$name->subject_id)->where('school_id',$sub->school_id)->where('exam_id',$exam_id)->delete('subjects_school_gpa');
}
}
echo " ";
}
}
public function futa_ca_sub1(){
$exam_id = 79;
foreach($this->db->distinct()->select('reg_number')->where('exam_id',$exam_id)->get('ca')->result() as $reg){
$comb = '';
foreach($this->db->where('reg_number',$reg->reg_number)->get('classes')->result() as $class){
$comb = $class->stream;
}
$getcasub = $this->db->distinct()->select('main_subject_id')->where('reg_number',$reg->reg_number)->where('exam_id',$exam_id)->get('ca_sub');
echo $reg->reg_number.' - '.$comb.' ';
foreach($getcasub->result() as $main_subject){
$countca = $this->db->where('subject_id',$main_subject->main_subject_id)->where('exam_id',$exam_id)->where('reg_number',$reg->reg_number)->count_all_results('ca');
if($countca == 0){
//d nothing
foreach($this->db->where('subject_id',$main_subject->main_subject_id)->get('all_subjects')->result() as $rowname){
$subject_name = $rowname->name;
}
echo 'Futa hili = '.$main_subject->main_subject_id.' '.$subject_name.' ';
}else{
//la kufuta hili
//tafuta jina la somo
}
}
echo ' ';
}
}
public function futa_ca_sub(){
$exam_id = 79;
foreach($this->db->distinct()->select('reg_number')->where('exam_id',$exam_id)->get('ca')->result() as $reg){
foreach($this->db->where('reg_number',$reg->reg_number)->get('classes')->result() as $comb){
foreach($this->db->where('combination',$comb->stream)->get('combinations')->result() as $valid){
// find valid subjects;
$subids = explode(',',$valid->ids);
echo $comb->stream." ";
$sub = $this->db->distinct()->select('main_subject_id')->where('reg_number',$reg->reg_number)->where_not_in('main_subject_id',$subids)->get('ca_sub');
if($sub->num_rows() > 0){
echo "Invalid ca sub ";
foreach($sub->result() as $ss){
foreach($this->db->where('subject_id',$ss->main_subject_id)->get('all_subjects')->result() as $name){
echo $name->name.", ";
}
}
}
echo "";
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$ca = $this->db->distinct()->select('subject_id')->where('reg_number',$reg->reg_number)->where_not_in('subject_id',$subids)->where('exam_id',$exam_id)->get('ca');
if($ca->num_rows() > 0){
echo "Invalid ca ";
foreach($ca->result() as $ss){
foreach($this->db->where('subject_id',$ss->subject_id)->get('all_subjects')->result() as $name){
echo $name->name.", ";
}
}
}
}
}
// $count_sub = $this->db->distinct()->select('main_subject_id')->where('reg_number',$sub->reg_number)->where('exam_id',$exam_id)->count_all_results('ca_sub');
// $this->db->not_like('subject_id',26); ## GS
// $this->db->not_like('subject_id',28); ## BAM
// $this->db->not_like('subject_id',54); ## DIVINITY
// $this->db->not_like('subject_id',55); ## MUSIC
// $count_ca = $this->db->distinct()->select('subject_id')->where('reg_number',$sub->reg_number)->where('exam_id',$exam_id)->count_all_results('ca');
// $st = $count_ca > $count_sub ? 'style="color:red"':'style="color:green"';
// if($count_ca > $count_sub){
// echo '';
// echo " count sub ".$count_sub." ". " count ca ".$count_ca." ";
// foreach($this->db->where('reg_number',$sub->reg_number)->get('classes')->result() as $comb){
// echo $sub->reg_number.' '.$comb->stream." - ";
// foreach($this->db->where('school_id',$comb->school_id)->get('schools')->result() as $sch){
// echo $sch->school_name." - ";
// }
// }
// echo "SUBJECTS ";
// $this->db->not_like('subject_id',26); ## GS
// $this->db->not_like('subject_id',28); ## BAM
// $this->db->not_like('subject_id',54); ## DIVINITY
// $this->db->not_like('subject_id',55); ## MUSIC
// $this->db->distinct()->select('subject_id')->where('reg_number',$sub->reg_number)->where('exam_id',$exam_id);
// foreach($this->db->get('ca')->result() as $main){
// foreach($this->db->where('subject_id',$main->subject_id)->get('all_subjects')->result() as $name){
// echo $name->name.", ";
// }
// }
// echo '';
// echo " ";
// echo " ";
// }
}
}
public function testing_endtime(){
$now = time();
$endtime = '';
foreach($this->db->limit(5)->where('examination_id',52)->get('examination')->result() as $exam){
echo "Exam ".$exam->end_time." ".$exam->upload_deadline." ";
$endtime = $exam->upload_deadline." ".$exam->end_time;
$endtime = strtotime($endtime);
echo "Now: ".$now." End: ".$endtime;
if($now > $endtime){
echo "Terminate";
}else{
echo "Allowed";
}
}
}
public function school_upload(){
$exam = $_REQUEST['exam_id'];
$status=0;
foreach($this->db->select('school_upload')->where('examination_id',$exam)->get('examination')->result() as $ex){
$status = $ex->school_upload;
}
if($status == 0){
$status = 1;
}else{
$status = 0;
}
$this->db->where('examination_id',$exam)->update('examination',array('school_upload'=>$status));
redirect($_SERVER['HTTP_REFERER']);
}
public function upload_questions(){
$exam = $_REQUEST['exam_id'];
$status=0;
foreach($this->db->select('upload_questions')->where('examination_id',$exam)->get('examination')->result() as $ex){
$status = $ex->upload_questions;
}
if($status == 0){
$status = 1;
}else{
$status = 0;
}
$this->db->where('examination_id',$exam)->update('examination',array('upload_questions'=>$status));
redirect($_SERVER['HTTP_REFERER']);
}
public function upload_deadline(){
$time12 = $this->input->post('time');
$time24 = date("H:i", strtotime($time12));
$this->db->where('examination_id',$this->input->post('exam_id'));
$this->db->update('examination',array('upload_deadline'=>$this->input->post('date'),'end_time'=>$time24));
redirect($_SERVER['HTTP_REFERER']);
}
public function school_report(){
$exam = $_REQUEST['exam_id'];
$status=0;
foreach($this->db->select('school_report')->where('examination_id',$exam)->get('examination')->result() as $ex){
$status = $ex->school_report;
}
if($status == 0){
$status = 1;
}else{
$status = 0;
}
$this->db->where('examination_id',$exam)->update('examination',array('school_report'=>$status));
redirect($_SERVER['HTTP_REFERER']);
}
public function create_combination(){
exit;
$exam_id = $_REQUEST['id'];
$candidate = $_REQUEST['cand'];
// echo $exam_id.' - '.$candidate;exit;
$students_updated=0;
$this->db->where('examination_id',$exam_id);
$gett=$this->db->get('examination');
$count=$gett->num_rows();
foreach($gett->result() as $rows){
$month=$rows->month;
$class=$rows->class_level;
$year=$rows->academic_year;
$academic_year=$rows->academic_year;
$region=$rows->region;
$district_exam=$rows->district;
$district=$rows->district;
$exam_header=$rows->heading;
$exam_name=$rows->exam_name;
$dateObj = DateTime::createFromFormat('!m', $month);
$monthName = $dateObj->format('F');
$status = $rows->status;
$category = $rows->category;
$group_id = $rows->group_id;
}
/*
$this->db->where('academic_year', $academic_year);
$this->db->where('stream', 'UNK');
$this->db->where('candidate',$candidate);
foreach($this->db->get('classes')->result() as $rt){;
echo $rt->reg_number.' ';
$this->db->select('s.full_name,c.school_name,s.id_number');
$this->db->where('s.reg_number',$rt->reg_number);
$this->db->from('students as s');
$this->db->join('schools as c','c.school_id=s.school_id');
$g = $this->db->get();
foreach($g->result() as $sc){
echo $sc->school_name." ".$sc->id_number." ";
}
}
exit;
*/
$this->db->distinct();
$this->db->select('reg_number');
$this->db->where('exam_id',$exam_id);
foreach($this->db->get('ca')->result() as $students){
$this->db->distinct();
$this->db->select('subject_id');
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$students->reg_number);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->order_by('subject_id','asc');
$this->db->limit(3);
$subjects = $this->db->get('ca');
$sum = '';
foreach($subjects->result() as $subs){
$sum.= $subs->subject_id; // Concatinate the ID's
//echo $subs->subject_id;
}
//echo " ";
/*
$this->db->select('s.full_name,c.school_name,s.id_number');
$this->db->where('s.reg_number',$students->reg_number);
$this->db->from('students as s');
$this->db->join('schools as c','c.school_id=s.school_id');
$g = $this->db->get();
foreach($g->result() as $sc){
echo $sc->school_name." ".$sc->id_number." ";
}
echo $students->reg_number;
*/
$this->db->where('id_sum',$sum);
$c = $this->db->get('combinations');
foreach($c->result() as $comb){
$data_stream = array('stream'=>$comb->combination);
}
if($c->num_rows() == 0){
## UNK Combination
$data_stream = array('stream'=>'UNK');
if($subjects->num_rows() == 3 ){
//echo " UNK - ".$subjects->num_rows();
$data_stream = array('stream'=>'UNK');
}else{
// echo " Incomplete ".$subjects->num_rows();
$this->db->where('reg_number',$students->reg_number);
$this->db->where('academic_year', $academic_year);
$this->db->where('candidate',$candidate);
foreach($this->db->get('classes')->result() as $rt){;
$data_stream = array('stream'=>$rt->stream);
}
}
$this->db->where('reg_number',$students->reg_number);
$this->db->where('academic_year', $academic_year);
$this->db->where('candidate',$candidate);
$this->db->update('classes',$data_stream);
$this->db->where('reg_number',$students->reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->update('ca',$data_stream);
$this->db->where('reg_number',$students->reg_number);
$this->db->where('exam_id',$exam_id);
$this->db->where('candidate',$candidate);
$this->db->update('monthly_results',$data_stream);
}else{
$students_updated++;
//echo " ".$data['stream']." Complete";
$this->db->where('reg_number',$students->reg_number);
$this->db->where('academic_year', $academic_year);
$this->db->where('candidate',$candidate);
$this->db->update('classes',$data_stream);
$this->db->where('reg_number',$students->reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->update('ca',$data_stream);
$this->db->where('reg_number',$students->reg_number);
$this->db->where('exam_id',$exam_id);
$this->db->where('candidate',$candidate);
$this->db->update('monthly_results',$data_stream);
}
//echo " ";
}
?>
Info!
db->where('examination_id',$exam_id);
$gett=$this->db->get('examination');
$count=$gett->num_rows();
foreach($gett->result() as $rows){
$month=$rows->month;
$class=$rows->class_level;
$year=$rows->academic_year;
$academic_year=$rows->academic_year;
$region=$rows->region;
$district_exam=$rows->district;
$district=$rows->district;
$exam_header=$rows->heading;
$exam_name=$rows->exam_name;
$dateObj = DateTime::createFromFormat('!m', $month);
$monthName = $dateObj->format('F');
$status = $rows->status;
$category = $rows->category;
$group_id = $rows->group_id;
}
## Monthly results for each school
if($category == 'P'){
#######################################
$this->db->distinct();
$this->db->select('school_id');
if($group_id==0){
$this->db->where('region_id',$region);
}else{
//this fro group id
}
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->order_by('id',"asc");
$this->db->limit($limit,$start);
$g = $this->db->get('ca');
foreach($g->result() as $schools){
$school = $schools->school_id;
foreach($this->db->where('school_id',$school)->get('schools')->result() as $ddd){
$district = $ddd->district;
$region = $ddd->region;
$stream = 'A';
}
$sum_of_marks=0;
$required_subjects_for_calcultion=0;
$required_subjects_for_calcultion_average=0;
$average_of_marks=0;
$grade='';
$remark='';
$grade1='';
$sum_of_marks2=0;
$mark_grade='';
$avg_cal='';
$div_cal='';
$complete='';
## select sum of marks for this monly and this student for reqiured only
$this->db->select('SUM(mark) as mark, AVG(mark) as avg, reg_number');
$this->db->where('school_id',$school);
$this->db->where('exam_id',$exam_id);
$this->db->where('candidate',$candidate);
$this->db->where('status', 0);
$this->db->group_by('reg_number');
$get_ca=$this->db->get('ca');
foreach($get_ca->result() as $row_ca){
$sum_of_marks = round($row_ca->mark);
$average_of_marks = round($row_ca->avg);
$reg_number = $row_ca->reg_number;
## Select all entered and included to the calculations
$this->db->where('school_id',$school);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->where('status', 0);
$required_subjects_for_calcultion=$this->db->count_all_results('ca');
//this for average take all subjects
$this->db->where('school_id',$school);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->where('status', 0);
$required_subjects_for_calcultion_average=$this->db->count_all_results('ca');
$subjects = 4;
if($category =='A'){
$subjects = 2;
}
if($required_subjects_for_calcultion>$subjects){
//complete results
$complete=1;
}else{
//incoplete results
$complete=0;
}
if($required_subjects_for_calcultion==0){
// No results calculations, because subjects for results calcultions not set';
}else{
//finding the grades from the score
$this->db->where('students_type',$category);
$get_grades=$this->db->get('grade_settings');
foreach($get_grades->result() as $row_grade){
if($row_grade->start_mark<=round($average_of_marks) && round($average_of_marks)<=$row_grade->end_mark){
$grade=$row_grade->grade;
$remark=$row_grade->remark;
//inserting values to the databse without positions
$data3=array(
'school_id'=>$school,
'reg_number'=>$reg_number,
'class_level'=>$class,
'district_id'=>$district,
'region_id'=>$region,
'exam_id'=>$exam_id,
'stream'=>$stream,
'candidate'=>$candidate,
'academic_year'=>$academic_year,
'month'=>$month,
'total_marks'=>$sum_of_marks,
'average'=>$average_of_marks,
'grade'=>$grade,
'remark'=>$remark,
'category'=>$category,
'division'=>'---',
'complete'=>$complete,
);
$this->db->where('school_id',$school);
$this->db->where('district_id', $district);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('month',$month);
$this->db->where('academic_year',$academic_year);
$this->db->where('class_level',$class);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('category', $category);
$count_entered= $this->db->count_all_results('monthly_results');
if($count_entered>0){
$this->db->where('school_id',$school);
$this->db->where('district_id', $district);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('month',$month);
$this->db->where('academic_year',$academic_year);
$this->db->where('class_level',$class);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('category', $category);
$this->db->update('monthly_results',$data3);
//there should be updating on mid term results
}else{
$this->db->insert('monthly_results',$data3);
//there should be inserting into mid term results
}
}
}
$subjects = 5;
$this->db->where('school_id',$school);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->where('status', 0);
$this->db->order_by('mark', 'desc');
$this->db->limit($subjects);
$ca = $this->db->get('ca');
$point = 42; $gpa=8;$division = "---"; $division_remark="Pass";
if($ca->num_rows() == $subjects){
$point = 0;
foreach($ca->result() as $mark){
$this->db->where('students_type',$category);
$this->db->where('grade',$mark->grade);
$get_points=$this->db->get('point_settings');
foreach($get_points->result() as $row_point){
$point= $point+$row_point->point;
}
}
//finding division
if($grade=='E'){
$division_remark="Fail";
}
$gpa = round($point/5,4);
$data = array(
//'division'=>$division,
//'point'=>$point,
'gpa'=>$gpa,
'remark'=>$division_remark,
);
//print_r($data);
//echo "
";
$this->db->where('school_id',$school);
$this->db->where('exam_id',$exam_id);
$this->db->where('academic_year',$academic_year);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->update('monthly_results',$data);
}else{
$data = array(
// 'division'=>$division,
// 'point'=>$point,
'gpa'=>$gpa,
'remark'=>$division_remark,
);
$this->db->where('school_id',$school);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('category', $category);
$this->db->update('monthly_results',$data);
}
}
}
#######################################
}
}else{
//echo $exam_name;exit;
$this->db->distinct();
//$this->db->where('school_id','SS5c3c69535aa4b');
$this->db->select('school_id');
if($group_id==0){
$this->db->where('region_id',$region);
}else{
//$this->db->where('group_id',$group_id);
}
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->order_by('id',"asc");
$this->db->limit($limit,$start);
$g = $this->db->get('ca');
foreach($g->result() as $schools){
$school = $schools->school_id;
foreach($this->db->where('school_id',$school)->get('schools')->result() as $ddd){
$district = $district_exam = $ddd->district;
$region = $ddd->region;
}
//echo $group_id.' '. $region.' '.$district_exam.' - '.$district;exit;
$sum_of_marks=0;
$required_subjects_for_calcultion=0;
$required_subjects_for_calcultion_average=0;
$average_of_marks=0;
$grade='';
$remark='';
$grade1='';
$sum_of_marks2=0;
$mark_grade='';
$avg_cal='';
$div_cal='';
$complete='';
$subjects = 7;
if($category =='A'){
$subjects = 3;
}
## select sum of marks for this monly and this student for reqiured only
$this->db->select('SUM(mark) as mark, AVG(mark) as avg, reg_number');
$this->db->where('school_id',$school);
$this->db->where('exam_id',$exam_id);
$this->db->where('candidate',$candidate);
$this->db->where('status', 0);
$this->db->group_by('reg_number');
$get_ca=$this->db->get('ca');
foreach($get_ca->result() as $row_ca){
$sum_of_marks=0;
$reg_number = $row_ca->reg_number;
//print_r($row_ca); echo "
";
$sum_of_marks = $row_ca->mark;
$average_of_marks = $row_ca->avg;
$this->db->where('reg_number',$reg_number);
$this->db->where('school_id',$school);
$this->db->where('candidate',$candidate);
$this->db->where('academic_year',$academic_year);
foreach($this->db->get('classes')->result() as $classes){
$class = $classes->class_level;
$district = $classes->district;
$region = $classes->region;
$stream = $classes->stream;
}
//this for average take all subjects
$this->db->where('school_id',$school);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->where('status', 0);
$count_subjects=$this->db->count_all_results('ca');
$subjects = 6;
if($category =='A'){
$subjects = 2;
}
if($count_subjects > $subjects){
$complete=1;
}else{
$complete=0;
}
$this->db->where('school_id',$school);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->where('status', 0);
$this->db->order_by('mark', 'desc');
//$this->db->limit($subjects);
$required_subjects_for_calcultion = $this->db->count_all_results('ca');
if($required_subjects_for_calcultion==0){
// No results calculations, because subjects for results calcultions not set';
}else{
//finding the grades from the score
$this->db->where('students_type',$category);
$get_grades=$this->db->get('grade_settings');
foreach($get_grades->result() as $row_grade){
if($row_grade->start_mark<=round($average_of_marks) && round($average_of_marks)<=$row_grade->end_mark){
$grade=$row_grade->grade;
$remark=$row_grade->remark;
//inserting values to the databse without positions
$this->db->where('reg_number',$reg_number);
$this->db->where('school_id',$school);
$this->db->where('candidate',$candidate);
$this->db->where('academic_year',$academic_year);
foreach($this->db->get('classes')->result() as $classes){
$class = $classes->class_level;
$district = $classes->district;
$region = $classes->region;
$stream = $classes->stream;
}
if($category == 'P'){
$stream = 'A';
}
$data3=array(
'school_id'=>$school,
'reg_number'=>$reg_number,
'class_level'=>$class,
'district_id'=>$district,
'region_id'=>$region,
'exam_id'=>$exam_id,
'stream'=>$stream,
'candidate'=>$candidate,
'academic_year'=>$academic_year,
'month'=>$month,
'total_marks'=>round($sum_of_marks),
'average'=>round($average_of_marks),
'grade'=>$grade,
'remark'=>$remark,
'category'=>$category,
'division'=>'---',
'complete'=>$complete,
);
$this->db->where('school_id',$school);
$this->db->where('district_id', $district);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$count_entered= $this->db->count_all_results('monthly_results');
if($count_entered>0){
$this->db->where('school_id',$school);
$this->db->where('district_id', $district);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->update('monthly_results',$data3);
}else{
$this->db->insert('monthly_results',$data3);
}
}
}
## Division calculation here
//echo "Division calculation here";
## Finding best seven subejcts which are included in div cal
$subjects = 7;
if($category =='A'){
$subjects = 3;
}
$this->db->where('school_id',$school);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->where('status', 0);
$this->db->order_by('mark', 'desc');
$this->db->limit($subjects);
$ca = $this->db->get('ca');
$point = 42; $gpa=8;$division = "---"; $division_remark="Fail";
if($ca->num_rows() == $subjects){
$point = 0;
foreach($ca->result() as $mark){
$this->db->where('students_type',$category);
$this->db->where('grade',$mark->grade);
$get_points=$this->db->get('point_settings');
foreach($get_points->result() as $row_point){
$point= $point+$row_point->point;
}
}
//finding division
$this->db->where('students_type',$category);
$get_div=$this->db->get('division_settings');
foreach($get_div->result() as $row_div){
if($row_div->start_point<=round($point) && round($point)<=$row_div->end_point){
$division=$row_div->division;
$division_remark=$row_div->remark;
}
}
$gpa = round($point/7,4);
if($category =='A'){
$gpa = round($point/3,4);
}
$data = array(
'division'=>$division,
'point'=>$point,
'complete_sort'=>1,
'complete'=>$point==42 ? 0:1,
'gpa'=>$gpa,
'remark'=>$division_remark,
);
//print_r($data);
//echo "
";
$this->db->where('school_id',$school);
$this->db->where('exam_id',$exam_id);
$this->db->where('academic_year',$academic_year);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->update('monthly_results',$data);
}else{
if($region == 3){
$complete = 1;
$pointNew = 0;
// finding subject done and their grades
foreach($ca->result() as $mark){
$this->db->where('students_type',$category);
$this->db->where('grade',$mark->grade);
$get_points=$this->db->get('point_settings');
foreach($get_points->result() as $row_point){
$pointNew= $pointNew+$row_point->point;
}
}
// special case for dodoma division calculation for incomplete
if($subjects == 3){
$pointNew = $pointNew + 7*($subjects - $ca->num_rows());
}else{
$pointNew = $pointNew + 5*($subjects - $ca->num_rows());
}
$this->db->where('students_type',$category);
$get_div=$this->db->get('division_settings');
foreach($get_div->result() as $row_div){
if($row_div->start_point<=round($pointNew) && round($pointNew)<=$row_div->end_point){
if($row_div->division != 0){
$division='IV';
}else{
$division = 0;
}
$division_remark=$row_div->remark;
}
}
if($point > 2){
$division = 'IV';
}else{
$division = 0;
}
}else{
$complete = $point==42 ? 0:1; // other regions
}
$data = array(
'division'=>$division,
'point'=>$point,
// 'complete'=>$point==42 ? 0:1,
'complete_sort'=>0,
'complete'=>$complete,
'gpa'=>$gpa,
'remark'=>$division_remark,
);
$this->db->where('school_id',$school);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('category', $category);
$this->db->update('monthly_results',$data);
}
/*
//deleting monthly results if all ca for the specific month have been deleted
$this->db->where('school_id',$school);
$this->db->where('district_id', $district);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$check_from_ca= $this->db->count_all_results('ca');
if($check_from_ca<1){
$this->db->where('school_id', $school);
$this->db->where('district_id', $district);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('month', $month);
$this->db->where('academic_year',$academic_year);
$this->db->where('class_level', $class);
$this->db->where('category', $category);
$this->db->delete('monthly_results');
}
*/
}
}
}
}
## End monthly results
redirect($_SERVER['HTTP_REFERER']);
}
/*
public function calculate_results(){
$exam_id = $_REQUEST['id'];
$candidate = $_REQUEST['cand'];
$limit = $_REQUEST['limit'];
$order = $_REQUEST['order'];
$this->db->where('examination_id',$exam_id);
$gett=$this->db->get('examination');
$count=$gett->num_rows();
foreach($gett->result() as $rows){
$month=$rows->month;
$year=$rows->academic_year;
$academic_year=$rows->academic_year;
$region=$rows->region;
$district_exam=$rows->district;
$exam_header=$rows->heading;
$exam_name=$rows->exam_name;
$dateObj = DateTime::createFromFormat('!m', $month);
$monthName = $dateObj->format('F');
$status = $rows->status;
$category = $rows->category;
}
## Monthly results for each school
$this->db->distinct();
$this->db->select('school_id');
$this->db->where('exam_id',$exam_id);
$this->db->order_by('id',$order);
$this->db->limit($limit);
$g = $this->db->get('ca');
foreach($g->result() as $schools){
$school = $schools->school_id;
$sum_of_marks=0;
$required_subjects_for_calcultion=0;
$required_subjects_for_calcultion_average=0;
$average_of_marks=0;
$grade='';
$remark='';
$grade1='';
$sum_of_marks2=0;
$mark_grade='';
$avg_cal='';
$div_cal='';
$complete='';
$subjects = 7;
if($category =='A'){
$subjects = 3;
}
## select sum of marks for this monly and this student for reqiured only
$this->db->distinct();
$this->db->select('reg_number');
$this->db->where('school_id',$school);
$this->db->where('exam_id',$exam_id);
$this->db->where('candidate',$candidate);
$this->db->where('status', 0);
$get_ca=$this->db->get('ca');
foreach($get_ca->result() as $row_ca){
$sum_of_marks=0;
$reg_number = $row_ca->reg_number;
$this->db->where('school_id',$school);
$this->db->where('region_id',$region);
$this->db->where('exam_id',$exam_id);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',60); ## AC
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->where('status', 0);
$this->db->order_by('mark', 'desc');
$this->db->limit($subjects);
$ca = $this->db->get('ca');
foreach($ca->result() as $cass){
$sum_of_marks = $sum_of_marks + $cass->mark;
}
$this->db->where('reg_number',$reg_number);
$this->db->where('school_id',$school);
$this->db->where('academic_year',$academic_year);
foreach($this->db->get('classes')->result() as $classes){
$class = $classes->class_level;
$district = $classes->district;
$region = $classes->region;
$stream = $classes->stream;
}
## Select all entered and included to the calculations
$this->db->where('school_id',$school);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->not_like('subject_id',26); ## GS
$this->db->not_like('subject_id',28); ## BAM
$this->db->not_like('subject_id',54); ## DIVINITY
$this->db->not_like('subject_id',55); ## MUSIC
$this->db->where('status', 0);
$required_subjects_for_calcultion=$this->db->count_all_results('ca');
//this for average take all subjects
$this->db->where('school_id',$school);
$this->db->where('reg_number',$reg_number);
$this->db->where('candidate',$candidate);
$this->db->where('exam_id',$exam_id);
$this->db->where('status', 0);
$required_subjects_for_calcultion_average=$this->db->count_all_results('ca');
$subjects = 6;
if($category =='A'){
$subjects = 2;
}
if($required_subjects_for_calcultion>$subjects){
//complete results
$complete=1;
}else{
//incoplete results
$complete=0;
}
if($required_subjects_for_calcultion==0){
// No results calculations, because subjects for results calcultions not set';
}else{
$average_of_marks=($sum_of_marks/$required_subjects_for_calcultion_average); //for considering total marks over total subjects required
$average_of_marks=round($average_of_marks);
//finding the grades from the score
$this->db->where('students_type',$category);
$get_grades=$this->db->get('grade_settings');
foreach($get_grades->result() as $row_grade){
if($row_grade->start_mark<=round($average_of_marks) && round($average_of_marks)<=$row_grade->end_mark){
$grade=$row_grade->grade;
$remark=$row_grade->remark;
//inserting values to the databse without positions
$this->db->where('reg_number',$reg_number);
$this->db->where('school_id',$school);
$this->db->where('academic_year',$academic_year);
foreach($this->db->get('classes')->result() as $classes){
$class = $classes->class_level;
$district = $classes->district;
$region = $classes->region;
$stream = $classes->stream;
}
$data3=array(
'school_id'=>$school,
'reg_number'=>$reg_number,
'class_level'=>$class,
'district_id'=>$district,
'region_id'=>$region,
'exam_id'=>$exam_id,
'stream'=>$stream,
'candidate'=>$candidate,
'academic_year'=>$academic_year,
'month'=>$month,
'total_marks'=>$sum_of_marks,
'average'=>$average_of_marks,
'grade'=>$grade,
'remark'=>$remark,
'category'=>$category,
'division'=>'---',
'complete'=>$complete,
);
//print_r($data3); echo "
load->view('includes/super_header');
$this->load->view('users/superuser/assign_subjects_o');
$this->load->view('includes/super_footer');
}
public function assign_subjects_p(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/assign_subjects_p');
$this->load->view('includes/super_footer');
}
public function assign_subjects_a(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/assign_subjects_a');
$this->load->view('includes/super_footer');
}
public function assign_sub_subjects_o(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/assign_sub_subjects_o');
$this->load->view('includes/super_footer');
}
public function assign_sub_subjects_a(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/assign_sub_subjects_a');
$this->load->view('includes/super_footer');
}
public function register_user(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/register_user');
$this->load->view('includes/super_footer');
}
public function primary_register_user(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/primary_register_user');
$this->load->view('includes/super_footer');
}
public function view_results_primary(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/view_results_primary');
$this->load->view('includes/super_footer');
}
public function view_results_O_level(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/view_results_O_level');
$this->load->view('includes/super_footer');
}
public function view_results_O_level_calculate(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/view_results_O_level_calculate');
$this->load->view('includes/super_footer');
}
public function set_exam_public(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/set_exam_public');
$this->load->view('includes/super_footer');
}
public function upload_results_o_level_officer(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/upload_results_o_level_officer');
$this->load->view('includes/super_footer');
}
public function upload_results_officers_o_level(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/upload_results_officers_o_level');
$this->load->view('includes/super_footer');
}
public function insert_results_O_level(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/insert_results_O_level');
$this->load->view('includes/super_footer');
}
public function view_results_a_level(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/view_results_a_level');
$this->load->view('includes/super_footer');
}
public function register_groups(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/register_groups');
$this->load->view('includes/super_footer');
}
public function primary_register_groups(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/primary_register_groups');
$this->load->view('includes/super_footer');
}
public function register_subjects(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/register_subjects');
$this->load->view('includes/super_footer');
}
public function view_users(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/view_users');
$this->load->view('includes/super_footer');
}
public function view_group_schools(){
$this->load->view('includes/super_header');
$this->load->view('users/superuser/view_group_schools');
$this->load->view('includes/super_footer');
}
public function load_category(){
$cat = $this->input->post('category');
if($cat == 1){
// region
?>