Best Atoum code snippet using score.sort
TrinityEGIS.php
Source:TrinityEGIS.php
...92 93 $rC = $this->_getRecordsData($dataSelect = array('*'), 94 $tables = array('triune_subject_elementary'), 95 $fieldName = array('subjectCode'), $where = array($subjectCode), 96 $join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, 97 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );98 if(empty($rC)) {99 $rC = $this->_getRecordsData($dataSelect1 = array('*'), 100 $tables = array('triune_subject_junior_high'), 101 $fieldName = array('subjectCode'), $where = array($subjectCode), 102 $join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, 103 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );104 105 if(empty($rC)) {106 $rC = $this->_getRecordsData($dataSelect2 = array('*'), 107 $tables = array('triune_subject_senior_high'), 108 $fieldName = array('subjectCode'), $where = array($subjectCode), 109 $join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, 110 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );111 }112 113 }114 115 116 $reportCategory = $rC[0]->reportCategory;117 //$reportCategory = 1;118 if($reportCategory == 1) {119 $results = null;120 121 if($gradingPeriod == '1') {122 $selectFields = "triune_grades_score_sheet_1.*, ";123 $selectFields = $selectFields . "triune_students_k12.studentNumber, concat(triune_students_k12.lastName, ', ', triune_students_k12.firstName, ' ', SUBSTR(triune_students_k12.middleName, 1, 1), '.') as fullName";124 $results = $this->_getRecordsData($dataSelect = array($selectFields), 125 $tables = array('triune_grades_score_sheet_1', 'triune_students_k12'), 126 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 127 $join = array('triune_grades_score_sheet_1.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 128 $sortBy = array('gender', 'lastName', 'firstName'), $sortOrder = array('desc', 'asc', 'asc'), $limit = null, 129 $fieldNameLike = null, $like = null, 130 $whereSpecial = null, $groupBy = null );131 } elseif($gradingPeriod == '2') {132 $selectFields = "triune_grades_score_sheet_2.*, ";133 $selectFields = $selectFields . "triune_students_k12.studentNumber, concat(triune_students_k12.lastName, ', ', triune_students_k12.firstName, ' ', SUBSTR(triune_students_k12.middleName, 1, 1), '.') as fullName";134 $results = $this->_getRecordsData($dataSelect = array($selectFields), 135 $tables = array('triune_grades_score_sheet_2', 'triune_students_k12'), 136 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 137 $join = array('triune_grades_score_sheet_2.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 138 $sortBy = array('gender', 'lastName', 'firstName'), $sortOrder = array('desc', 'asc', 'asc'), $limit = null, 139 $fieldNameLike = null, $like = null, 140 $whereSpecial = null, $groupBy = null );141 142 } elseif($gradingPeriod == '3') {143 $selectFields = "triune_grades_score_sheet_3.*, ";144 $selectFields = $selectFields . "triune_students_k12.studentNumber, concat(triune_students_k12.lastName, ', ', triune_students_k12.firstName, ' ', SUBSTR(triune_students_k12.middleName, 1, 1), '.') as fullName";145 $results = $this->_getRecordsData($dataSelect = array($selectFields), 146 $tables = array('triune_grades_score_sheet_3', 'triune_students_k12'), 147 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 148 $join = array('triune_grades_score_sheet_3.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 149 $sortBy = array('gender', 'lastName', 'firstName'), $sortOrder = array('desc', 'asc', 'asc'), $limit = null, 150 $fieldNameLike = null, $like = null, 151 $whereSpecial = null, $groupBy = null );152 153 }154 155 $data['scoreList'] = (array) $results;156 $wwColumnCtr = 0;157 $ptColumnCtr = 0; 158 $qaColumnCtr = 0; 159 160 $maxScoreCounter = (array) $results[0];161 $data['maxScoreRow'] = $maxScoreCounter;162 $maxScoreCount = count($maxScoreCounter); 163 for($w = 1; $w < 16; $w++) {164 if($maxScoreCounter['WW'.$w] > 0) {165 $wwColumnCtr++;166 } 167 }168 169 for($p = 1; $p < 11; $p++) {170 if($maxScoreCounter['PT'.$p] > 0) {171 $ptColumnCtr++;172 } 173 }174 for($q = 1; $q < 2; $q++) {175 if($maxScoreCounter['QA'.$q] > 0) {176 $qaColumnCtr++;177 } 178 }179 180 181 $data['wwColumnCount'] = $wwColumnCtr + 3;182 $data['ptColumnCount'] = $ptColumnCtr + 3;183 $data['qaColumnCount'] = $qaColumnCtr + 2;184 $titlesData = null;185 if($gradingPeriod == '1') {186 $titlesFields = "triune_grades_score_sheet_1_title.*";187 $titlesData = $this->_getRecordsData($dataSelect = array($titlesFields), 188 $tables = array('triune_grades_score_sheet_1_title'), 189 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 190 $join = null, $joinType = null, 191 $sortBy = null, $sortOrder = null, $limit = null, 192 $fieldNameLike = null, $like = null, 193 $whereSpecial = null, $groupBy = null );194 } elseif($gradingPeriod == '2') {195 $titlesFields = "triune_grades_score_sheet_2_title.*";196 $titlesData = $this->_getRecordsData($dataSelect = array($titlesFields), 197 $tables = array('triune_grades_score_sheet_2_title'), 198 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 199 $join = null, $joinType = null, 200 $sortBy = null, $sortOrder = null, $limit = null, 201 $fieldNameLike = null, $like = null, 202 $whereSpecial = null, $groupBy = null );203 } elseif($gradingPeriod == '3') {204 $titlesFields = "triune_grades_score_sheet_3_title.*";205 $titlesData = $this->_getRecordsData($dataSelect = array($titlesFields), 206 $tables = array('triune_grades_score_sheet_3_title'), 207 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 208 $join = null, $joinType = null, 209 $sortBy = null, $sortOrder = null, $limit = null, 210 $fieldNameLike = null, $like = null, 211 $whereSpecial = null, $groupBy = null );212 213 }214 $data['titles'] = (array) $titlesData[0];215 216 //echo $data['scoreList'][0]->studentNumber;217 //echo $data['titles']['titleWW1'];218 $data['hoy'] = $data['titles']['titleWW1'];219 $selectSP = "triune_grading_components.levelCode, triune_grading_components.departmentCode, triune_grading_components.gradingComponentCode, ";220 $selectSP = $selectSP . "triune_grading_components.componentPercentage, triune_grading_components.sy";221 $courseCode = substr($sectionCode, 0, 4);222 $scorePercentage = null;223 224 if($courseCode == '1001') {225 $scorePercentage = $this->_getRecordsData($dataSelect = array($selectSP), 226 $tables = array('triune_subject_elementary', 'triune_grading_components'), 227 $fieldName = array('sy', 'subjectCode' ), $where = array($_SESSION['sy'], $subjectCode), 228 $join = array('triune_subject_elementary.departmentCode = triune_grading_components.departmentCode'), $joinType = array('inner'), 229 $sortBy = null, $sortOrder = null, $limit = null, 230 $fieldNameLike = null, $like = null, 231 $whereSpecial = null, $groupBy = null );232 } elseif($courseCode == '1002') {233 $scorePercentage = $this->_getRecordsData($dataSelect = array($selectSP), 234 $tables = array('triune_subject_junior_high', 'triune_grading_components'), 235 $fieldName = array('sy', 'subjectCode' ), $where = array($_SESSION['sy'], $subjectCode), 236 $join = array('triune_subject_junior_high.departmentCode = triune_grading_components.departmentCode'), $joinType = array('inner'), 237 $sortBy = null, $sortOrder = null, $limit = null, 238 $fieldNameLike = null, $like = null, 239 $whereSpecial = null, $groupBy = null );240 } elseif($courseCode == '1005') {241 $selectSP = "triune_grading_components_sh.sy, triune_grading_components_sh.levelCode, triune_grading_components_sh.subjectComponentCode, ";242 $selectSP = $selectSP . "triune_grading_components_sh.gradingComponentCode, triune_grading_components_sh.componentPercentage";243 $scorePercentage = $this->_getRecordsData($dataSelect = array($selectSP), 244 $tables = array('triune_subject_senior_high', 'triune_grading_components_sh'), 245 $fieldName = array('sy', 'subjectCode' ), $where = array($_SESSION['sy'], $subjectCode), 246 $join = array('triune_subject_senior_high.subjectComponentCode = triune_grading_components_sh.subjectComponentCode'), $joinType = array('inner'), 247 $sortBy = null, $sortOrder = null, $limit = null, 248 $fieldNameLike = null, $like = null, 249 $whereSpecial = null, $groupBy = null );250 }251 252 253 $wwPct = 0;254 $ptPct = 0;255 $qaPct = 0;256 foreach($scorePercentage as $row) {257 if($row->gradingComponentCode == 'WW') {258 $wwPct = $row->componentPercentage;259 } else if($row->gradingComponentCode == 'PT') {260 $ptPct = $row->componentPercentage;261 } else if($row->gradingComponentCode == 'QA') {262 $qaPct = $row->componentPercentage;263 }264 }265 $data['wwPct'] = $wwPct;266 $data['ptPct'] = $ptPct;267 $data['qaPct'] = $qaPct;268 $transmutation = $this->_getRecordsData($dataSelect = array('*'), 269 $tables = array('triune_transmutation_k12'), 270 $fieldName = null, $where = null, 271 $join = null, $joinType = null, 272 $sortBy = array('transmutedScore'), $sortOrder = array('desc'), $limit = null, 273 $fieldNameLike = null, $like = null, 274 $whereSpecial = null, $groupBy = null );275 276 $data['transmutationTable'] = $transmutation;277 278 $this->load->library('Pdf');279 $this->load->view('EGIS/subject-grades-summary', $data);280 } else {281 $results = null;282 if($gradingPeriod == '1') {283 $selectFields = "triune_grades_score_sheet_1.*, ";284 $selectFields = $selectFields . "triune_students_k12.studentNumber, concat(triune_students_k12.lastName, ', ', triune_students_k12.firstName, ' ', SUBSTR(triune_students_k12.middleName, 1, 1), '.') as fullName";285 286 $results = $this->_getRecordsData($dataSelect = array($selectFields), 287 $tables = array('triune_grades_score_sheet_1', 'triune_students_k12'), 288 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 289 $join = array('triune_grades_score_sheet_1.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 290 $sortBy = array('gender', 'lastName', 'firstName'), $sortOrder = array('desc', 'asc', 'asc'), $limit = null, 291 $fieldNameLike = null, $like = null, 292 $whereSpecial = null, $groupBy = null );293 } elseif($gradingPeriod == '2') {294 $selectFields = "triune_grades_score_sheet_2.*, ";295 $selectFields = $selectFields . "triune_students_k12.studentNumber, concat(triune_students_k12.lastName, ', ', triune_students_k12.firstName, ' ', SUBSTR(triune_students_k12.middleName, 1, 1), '.') as fullName";296 297 $results = $this->_getRecordsData($dataSelect = array($selectFields), 298 $tables = array('triune_grades_score_sheet_2', 'triune_students_k12'), 299 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 300 $join = array('triune_grades_score_sheet_2.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 301 $sortBy = array('gender', 'lastName', 'firstName'), $sortOrder = array('desc', 'asc', 'asc'), $limit = null, 302 $fieldNameLike = null, $like = null, 303 $whereSpecial = null, $groupBy = null );304 } elseif($gradingPeriod == '3') {305 $selectFields = "triune_grades_score_sheet_3.*, ";306 $selectFields = $selectFields . "triune_students_k12.studentNumber, concat(triune_students_k12.lastName, ', ', triune_students_k12.firstName, ' ', SUBSTR(triune_students_k12.middleName, 1, 1), '.') as fullName";307 308 $results = $this->_getRecordsData($dataSelect = array($selectFields), 309 $tables = array('triune_grades_score_sheet_3', 'triune_students_k12'), 310 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 311 $join = array('triune_grades_score_sheet_3.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 312 $sortBy = array('gender', 'lastName', 'firstName'), $sortOrder = array('desc', 'asc', 'asc'), $limit = null, 313 $fieldNameLike = null, $like = null, 314 $whereSpecial = null, $groupBy = null );315 }316 317 318 $data['scoreList'] = (array) $results;319 $maxScoreCounter = (array) $results[0];320 $data['maxScoreRow'] = $maxScoreCounter;321 322 $titlesData = null;323 if($gradingPeriod == '1') {324 $titlesFields = "triune_grades_score_sheet_1_title.*";325 $titlesData = $this->_getRecordsData($dataSelect = array($titlesFields), 326 $tables = array('triune_grades_score_sheet_1_title'), 327 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 328 $join = null, $joinType = null, 329 $sortBy = null, $sortOrder = null, $limit = null, 330 $fieldNameLike = null, $like = null, 331 $whereSpecial = null, $groupBy = null );332 } elseif($gradingPeriod == '2') {333 $titlesFields = "triune_grades_score_sheet_2_title.*";334 $titlesData = $this->_getRecordsData($dataSelect = array($titlesFields), 335 $tables = array('triune_grades_score_sheet_2_title'), 336 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 337 $join = null, $joinType = null, 338 $sortBy = null, $sortOrder = null, $limit = null, 339 $fieldNameLike = null, $like = null, 340 $whereSpecial = null, $groupBy = null );341 } elseif($gradingPeriod == '3') {342 $titlesFields = "triune_grades_score_sheet_3_title.*";343 $titlesData = $this->_getRecordsData($dataSelect = array($titlesFields), 344 $tables = array('triune_grades_score_sheet_3_title'), 345 $fieldName = array('sy', 'sectionCode', 'subjectCode' ), $where = array($_SESSION['sy'], $sectionCode, $subjectCode), 346 $join = null, $joinType = null, 347 $sortBy = null, $sortOrder = null, $limit = null, 348 $fieldNameLike = null, $like = null, 349 $whereSpecial = null, $groupBy = null );350 }351 $data['titles'] = (array) $titlesData[0];352 353 $this->load->library('Pdf');354 $this->load->view('EGIS/subject-grades-summary-2', $data);355 }356 } 357 public function attendanceEGIS() {358 359 $this->load->view('EGIS/attendance-sheet-list');360 } 361 public function schoolDaysEGIS() {362 363 $this->load->view('EGIS/school-days-list');364 } 365 366 public function traitsEGIS() {367 368 $this->load->view('EGIS/traits-sheet-list');369 } 370 public function gradesRequestEGIS() {371 372 $this->load->view('EGIS/student-subject-list');373 } 374 375 public function classCardEGIS() {376 //echo "HELLO WORLD";377 $this->load->view('EGIS/classcard-setup');378 } 379 380 381 public function showClassCardDetailsEGIS() {382 $sectionCode = $_POST["sectionCode"];383 $studentNumber = $_POST["studentNumber"];384 $sectionCodeNS = $_POST["sectionCodeNS"];385 $userName = $this->_getUserName(1);386 //$sectionCode = '1002 3-9-INTEGRITY';387 //$studentNumber = '18-200073';388 //$sectionCodeNS = '10023-9-INTEGRITY';389 $gradingPeriod = $_SESSION['gP'];390 391 $data['sectionCode'] = $sectionCode;392 $data['studentNumber'] = $studentNumber;393 $data['sectionCodeNS'] = $sectionCodeNS;394 395 $results = $this->_getRecordsData($dataSelect1 = array('*'), 396 $tables = array('triune_students_k12'), $fieldName = array('studentNumber'), $where = array($studentNumber), $join = null, $joinType = null, 397 $sortBy = null, $sortOrder = null, $limit = null, 398 $fieldNameLike = null, $like = null, 399 $whereSpecial = null, $groupBy = null );400 401 402 $data['lastName'] = $results[0]->lastName;403 $data['firstName'] = $results[0]->firstName;404 $data['middleName'] = $results[0]->middleName;405 $data['gender'] = $results[0]->gender;406 $data['sYear'] = $_SESSION['sy'];407 $age = $this->_getYearsMonthsDays($results[0]->birthDate);408 $data['age'] = $age->y;409 $data['yearLevel'] = $results[0]->yearLevel;410 411 $courseCode = substr($sectionCode, 0, 4);412 $selectField1 = null;413 $selectField2 = null;414 415 $resultsGrades = null;416 echo $courseCode;417 if($courseCode == '1002') {418 $selectField1 = "triune_subject_junior_high.subjectDescription, triune_subject_junior_high.weight, triune_subject_junior_high.subjectCode, ";419 $selectField1 = $selectField1 . "triune_grades_score_sheet_1_summary.initialGrade, triune_grades_score_sheet_1_summary.transmutedGrade, ";420 $selectField1 = $selectField1 . "triune_subject_junior_high.displaySequence";421 $resultsGrades1 = $this->_getRecordsData($dataSelect2 = array($selectField1), 422 $tables = array('triune_grades_score_sheet_1_summary', 'triune_subject_junior_high'), 423 $fieldName = array('sy', 'studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 424 $join = array('triune_subject_junior_high ON triune_grades_score_sheet_1_summary.subjectCode = triune_subject_junior_high.subjectCode'), 425 $joinType = array('inner'), $sortBy = array('triune_subject_junior_high.displaySequence'), $sortOrder = array('asc'), $limit = null, 426 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );427 $selectField2 = "triune_subject_junior_high.subjectDescription, triune_subject_junior_high.weight, triune_subject_junior_high.subjectCode, ";428 $selectField2 = $selectField2 . "triune_grades_score_sheet_2_summary.initialGrade, triune_grades_score_sheet_2_summary.transmutedGrade, ";429 $selectField2 = $selectField2 . "triune_subject_junior_high.displaySequence";430 $resultsGrades2 = $this->_getRecordsData($dataSelect2 = array($selectField2), 431 $tables = array('triune_grades_score_sheet_2_summary', 'triune_subject_junior_high'), 432 $fieldName = array('sy', 'studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 433 $join = array('triune_subject_junior_high ON triune_grades_score_sheet_2_summary.subjectCode = triune_subject_junior_high.subjectCode'), 434 $joinType = array('inner'), $sortBy = array('triune_subject_junior_high.displaySequence'), $sortOrder = array('asc'), $limit = null, 435 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );436 $selectField3 = "triune_subject_junior_high.subjectDescription, triune_subject_junior_high.weight, triune_subject_junior_high.subjectCode, ";437 $selectField3 = $selectField3 . "triune_grades_score_sheet_3_summary.initialGrade, triune_grades_score_sheet_3_summary.transmutedGrade, ";438 $selectField3 = $selectField3 . "triune_subject_junior_high.displaySequence";439 $resultsGrades3 = $this->_getRecordsData($dataSelect3 = array($selectField3), 440 $tables = array('triune_grades_score_sheet_3_summary', 'triune_subject_junior_high'), 441 $fieldName = array('sy', 'studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 442 $join = array('triune_subject_junior_high ON triune_grades_score_sheet_3_summary.subjectCode = triune_subject_junior_high.subjectCode'), 443 $joinType = array('inner'), $sortBy = array('triune_subject_junior_high.displaySequence'), $sortOrder = array('asc'), $limit = null, 444 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );445 446 447 448 //print_r($resultsGrades1);449 //echo "---------------------------------------------------<br>";450 //print_r($resultsGrades2);451 452 453 454 } else if($courseCode == '1001') {455 $selectField1 = "triune_subject_elementary.subjectDescription, triune_subject_elementary.weight, triune_subject_elementary.subjectCode, ";456 $selectField1 = $selectField1 . "triune_grades_score_sheet_1_summary.initialGrade, triune_grades_score_sheet_1_summary.transmutedGrade, ";457 $selectField1 = $selectField1 . "triune_subject_elementary.displaySequence";458 $resultsGrades1 = $this->_getRecordsData($dataSelect2 = array($selectField1), 459 $tables = array('triune_grades_score_sheet_1_summary', 'triune_subject_elementary'), 460 $fieldName = array('sy', 'studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 461 $join = array('triune_subject_elementary ON triune_grades_score_sheet_1_summary.subjectCode = triune_subject_elementary.subjectCode'), 462 $joinType = array('inner'), $sortBy = array('triune_subject_elementary.displaySequence'), $sortOrder = array('asc'), $limit = null, 463 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );464 $selectField2 = "triune_subject_elementary.subjectDescription, triune_subject_elementary.weight, triune_subject_elementary.subjectCode, ";465 $selectField2 = $selectField2 . "triune_grades_score_sheet_2_summary.initialGrade, triune_grades_score_sheet_2_summary.transmutedGrade, ";466 $selectField2 = $selectField2 . "triune_subject_elementary.displaySequence";467 $resultsGrades2 = $this->_getRecordsData($dataSelect2 = array($selectField2), 468 $tables = array('triune_grades_score_sheet_2_summary', 'triune_subject_elementary'), 469 $fieldName = array('sy','studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 470 $join = array('triune_subject_elementary ON triune_grades_score_sheet_2_summary.subjectCode = triune_subject_elementary.subjectCode'), 471 $joinType = array('inner'), $sortBy = array('triune_subject_elementary.displaySequence'), $sortOrder = array('asc'), $limit = null, 472 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );473 $selectField3 = "triune_subject_elementary.subjectDescription, triune_subject_elementary.weight, triune_subject_elementary.subjectCode, ";474 $selectField3 = $selectField3 . "triune_grades_score_sheet_3_summary.initialGrade, triune_grades_score_sheet_3_summary.transmutedGrade, ";475 $selectField3 = $selectField3 . "triune_subject_elementary.displaySequence";476 $resultsGrades3 = $this->_getRecordsData($dataSelect3 = array($selectField3), 477 $tables = array('triune_grades_score_sheet_3_summary', 'triune_subject_elementary'), 478 $fieldName = array('sy','studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 479 $join = array('triune_subject_elementary ON triune_grades_score_sheet_3_summary.subjectCode = triune_subject_elementary.subjectCode'), 480 $joinType = array('inner'), $sortBy = array('triune_subject_elementary.displaySequence'), $sortOrder = array('asc'), $limit = null, 481 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );482 483 484 } else if($courseCode == '1005') {485 $selectField1 = "triune_subject_senior_high.subjectDescription, triune_subject_senior_high.weight, triune_subject_senior_high.subjectCode, ";486 $selectField1 = $selectField1 . "triune_grades_score_sheet_1_summary.initialGrade, triune_grades_score_sheet_1_summary.transmutedGrade, ";487 $selectField1 = $selectField1 . "triune_subject_senior_high.displaySequence";488 $resultsGrades1 = $this->_getRecordsData($dataSelect2 = array($selectField1), 489 $tables = array('triune_grades_score_sheet_1_summary', 'triune_subject_senior_high'), 490 $fieldName = array('sy', 'studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 491 $join = array('triune_subject_senior_high ON triune_grades_score_sheet_1_summary.subjectCode = triune_subject_senior_high.subjectCode'), 492 $joinType = array('inner'), $sortBy = array('triune_subject_senior_high.displaySequence'), $sortOrder = array('asc'), $limit = null, 493 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );494 $selectField2 = "triune_subject_senior_high.subjectDescription, triune_subject_senior_high.weight, triune_subject_senior_high.subjectCode, ";495 $selectField2 = $selectField2 . "triune_grades_score_sheet_2_summary.initialGrade, triune_grades_score_sheet_2_summary.transmutedGrade, ";496 $selectField2 = $selectField2 . "triune_subject_senior_high.displaySequence";497 $resultsGrades2 = $this->_getRecordsData($dataSelect2 = array($selectField2), 498 $tables = array('triune_grades_score_sheet_2_summary', 'triune_subject_senior_high'), 499 $fieldName = array('sy','studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 500 $join = array('triune_subject_senior_high ON triune_grades_score_sheet_2_summary.subjectCode = triune_subject_senior_high.subjectCode'), 501 $joinType = array('inner'), $sortBy = array('triune_subject_senior_high.displaySequence'), $sortOrder = array('asc'), $limit = null, 502 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );503 $selectField3 = "triune_subject_senior_high.subjectDescription, triune_subject_senior_high.weight, triune_subject_senior_high.subjectCode, ";504 $selectField3 = $selectField3 . "triune_grades_score_sheet_3_summary.initialGrade, triune_grades_score_sheet_3_summary.transmutedGrade, ";505 $selectField3 = $selectField3 . "triune_subject_senior_high.displaySequence";506 $resultsGrades3 = $this->_getRecordsData($dataSelect3 = array($selectField3), 507 $tables = array('triune_grades_score_sheet_3_summary', 'triune_subject_senior_high'), 508 $fieldName = array('sy','studentNumber'), $where = array($_SESSION['sy'], $studentNumber), 509 $join = array('triune_subject_senior_high ON triune_grades_score_sheet_3_summary.subjectCode = triune_subject_senior_high.subjectCode'), 510 $joinType = array('inner'), $sortBy = array('triune_subject_senior_high.displaySequence'), $sortOrder = array('asc'), $limit = null, 511 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );512 513 514 }515 $lE = $this->_getRecordsData($dataSelect2 = array('*'), 516 $tables = array('triune_grading_descriptor'), $fieldName = null, $where = null, $join = null, $joinType = null, 517 $sortBy = array('higherScale'), $sortOrder = array('desc'), 518 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );519 520 $data['lE'] = $lE;521 $gD = $this->_getRecordsData($dataSelect2 = array('*'), 522 $tables = array('triune_grading_descriptor_traits'), $fieldName = null, $where = null, $join = null, $joinType = null, 523 $sortBy = array('letterEquivalent'), $sortOrder = array('asc'), 524 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );525 526 $data['gD'] = $gD;527 528 $schoolDays = $this->_getRecordsData($dataSelect2 = array('*'), 529 $tables = array('triune_grades_school_days'), $fieldName = null, $where = null, $join = null, $joinType = null, 530 $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );531 532 $data['schoolDays'] = $schoolDays;533 534 $presentDays = $this->_getRecordsData($dataSelect2 = array('*'), 535 $tables = array('triune_grades_score_sheet_1_attendance'), 536 $fieldName = array('studentNumber', 'sectionCode'), $where = array($studentNumber, $sectionCode), 537 $join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 538 $groupBy = null );539 540 $data['presentDays'] = $presentDays;541 $traitsHeader = $this->_getRecordsData($dataSelect2 = array('*'), 542 $tables = array('triune_grades_traits_header'), 543 $fieldName = array('sy'), $where = array($_SESSION['sy']), 544 $join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 545 $groupBy = null );546 547 $traits1 = $this->_getRecordsData($dataSelect3 = array('*'), 548 $tables = array('triune_grades_score_sheet_1_traits'), $fieldName = array('sy', 'studentNumber', 'sectionCode'), 549 $where = array($_SESSION['sy'], $studentNumber, $sectionCode), $join = null, $joinType = null, $sortBy = null, $sortOrder = null, 550 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );551 $traits2 = $this->_getRecordsData($dataSelect3 = array('*'), 552 $tables = array('triune_grades_score_sheet_2_traits'), $fieldName = array('sy', 'studentNumber', 'sectionCode'), 553 $where = array($_SESSION['sy'], $studentNumber, $sectionCode), $join = null, $joinType = null, $sortBy = null, $sortOrder = null, 554 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );555 $traits3 = $this->_getRecordsData($dataSelect3 = array('*'), 556 $tables = array('triune_grades_score_sheet_3_traits'), $fieldName = array('sy', 'studentNumber', 'sectionCode'), 557 $where = array($_SESSION['sy'], $studentNumber, $sectionCode), $join = null, $joinType = null, $sortBy = null, $sortOrder = null, 558 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );559 560 $traits1g = (array) $traits1[0];561 $traits2g = (array) $traits2[0];562 $traits3g = (array) $traits3[0];563 564 //echo $traits1g['traits1'];565 //echo $traits1g['traits2'];566 //CLEAR CLASS CARD DATA567 $where = array($studentNumber, $sectionCode, $userName);568 $fieldName = array('studentNumber', 'sectionCode', 'userNumber');569 //CLEAR CLASS CARD DATA570 571 $this->db->trans_start();572 $this->_deleteRecords('triune_wip_grades_class_card', $fieldName, $where);573 $this->_deleteRecords('triune_wip_grades_class_card_traits', $fieldName, $where);574 575 foreach($resultsGrades1 as $row1) {576 $letterEquivalent = null;577 foreach($lE as $eRow) {578 if( ($eRow->lowerScale <= $row1->transmutedGrade) && ($eRow->higherScale >= $row1->transmutedGrade) ){579 580 $letterEquivalent = $eRow->letterEquivalent;581 }582 }583 $insertData = null;584 $insertData = array(585 'studentNumber' => $studentNumber,586 'sectionCode' => $sectionCode,587 'yearLevel' => $data['yearLevel'],588 'subjectCode' => $row1->subjectCode,589 'subjectDescription' => $row1->subjectDescription,590 'grades1' => $row1->transmutedGrade,591 'letterEquivalent1' => $letterEquivalent,592 'weight' => $row1->weight,593 'userNumber' => $userName,594 'timeStamp' => $this->_getTimeStamp(),595 ); 596 $insertedRecord1 =$this->_insertRecords($tableName = 'triune_wip_grades_class_card', $insertData); 597 } 598 //echo $studentNumber . ", " . $sectionCode . ", " . "<br>";599 foreach($resultsGrades2 as $row2) {600 $letterEquivalent2 = null;601 foreach($lE as $eRow) {602 if( ($eRow->lowerScale <= $row2->transmutedGrade) && ($eRow->higherScale >= $row2->transmutedGrade) ){603 604 $letterEquivalent2 = $eRow->letterEquivalent;605 }606 }607 $grades2 = array(608 'grades2' => $row2->transmutedGrade,609 'letterEquivalent2' => $letterEquivalent2,610 'userNumber' => $userName,611 'timeStamp' => $this->_getTimeStamp(),612 );613 614 echo $studentNumber . ", " . $sectionCode . ", " . $row2->subjectCode . "<br>";615 print_r($grades2);616 617 $this->_updateRecords($tableName = 'triune_wip_grades_class_card', 618 $fieldName = array('studentNumber', 'sectionCode', 'subjectCode'), 619 $where = array($studentNumber, $sectionCode, $row2->subjectCode), $grades2);620 } 621 foreach($resultsGrades3 as $row3) {622 $letterEquivalent3 = null;623 foreach($lE as $eRow) {624 if( ($eRow->lowerScale <= $row3->transmutedGrade) && ($eRow->higherScale >= $row3->transmutedGrade) ){625 626 $letterEquivalent3 = $eRow->letterEquivalent;627 }628 }629 $grades3 = array(630 'grades3' => $row3->transmutedGrade,631 'letterEquivalent3' => $letterEquivalent3,632 'userNumber' => $userName,633 'timeStamp' => $this->_getTimeStamp(),634 );635 636 //echo $studentNumber . ", " . $sectionCode . ", " . $row2->subjectCode . "<br>";637 //print_r($grades2);638 639 $this->_updateRecords($tableName = 'triune_wip_grades_class_card', 640 $fieldName = array('studentNumber', 'sectionCode', 'subjectCode'), 641 $where = array($studentNumber, $sectionCode, $row3->subjectCode), $grades3);642 } 643 644 645 646 647 648 $traitsCount = 10;649 650 for($t = 1; $t <= $traitsCount; $t++) {651 $traitsCol = "traits".$t;652 $insertT = null;653 $insertT = array(654 'studentNumber' => $studentNumber,655 'sectionCode' => $sectionCode,656 'yearLevel' => $data['yearLevel'],657 'traitsCode' => $traitsCol,658 'traitsDescription' => $traitsHeader[0]->$traitsCol,659 'userNumber' => $userName,660 'timeStamp' => $this->_getTimeStamp(),661 ); 662 $insertedRecord1 =$this->_insertRecords($tableName = 'triune_wip_grades_class_card_traits', $insertT); 663 664 }665 for($t1 = 1; $t1 <= 10; $t1++) {666 $traitsCol = "traits".$t1;667 668 //echo $traitsCol . " " . $traits1g[$traitsCol] . "<br>";669 $traits1 = array(670 'traitsScore1' => $traits1g[$traitsCol],671 'traitsScore2' => $traits2g[$traitsCol],672 'traitsScore3' => $traits3g[$traitsCol],673 'userNumber' => $userName,674 'timeStamp' => $this->_getTimeStamp(),675 );676 $this->_updateRecords($tableName = 'triune_wip_grades_class_card_traits', 677 $fieldName = array('studentNumber', 'sectionCode', 'traitsCode'), 678 $where = array($studentNumber, $sectionCode, $traitsCol), $traits1);679 }680 681 $this->db->trans_complete();682 683 684/*685grades3686letterEquivalet3687grades4688letterEquivalent4689gradesFinal690letterEquivalentFinal691actionTaken692weight*/693 $resultsGrades = $this->_getRecordsData($dataSelect2 = array('*'), 694 $tables = array('triune_wip_grades_class_card'), $fieldName = array('studentNumber', 'sectionCode', 'userNumber'), 695 $where = array($studentNumber, $sectionCode, $userName),696 $join = null, $joinType = null, $sortBy = null, $sortOrder = null, 697 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );698 699 $data['resultsGrades'] = $resultsGrades;700 $resultsTraits = $this->_getRecordsData($dataSelect2 = array('*'), 701 $tables = array('triune_wip_grades_class_card_traits'), $fieldName = array('studentNumber', 'sectionCode', 'userNumber'), 702 $where = array($studentNumber, $sectionCode, $userName),703 $join = null, $joinType = null, $sortBy = array('traitsCode'), $sortOrder = array('asc'), 704 $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );705 706 $data['resultsTraits'] = $resultsTraits;707 708 $this->load->library('Pdf'); 709 if($courseCode == '1005') {710 $data['lE'] = $lE;711 $this->load->view('EGIS/class-card-report-shs', $data);712 } else {713 $this->load->view('EGIS/class-card-report', $data);714 }715 } 716 717 718 public function allowGradesRequestEGIS() {719 $this->load->view('EGIS/allow-request');720 }721 722 public function unpostGradesEGIS() {723 $this->load->view('EGIS/unpost-grades');724 }725 726 public function rankingEGIS() {727 $this->load->view('EGIS/ranking-setup');728 }729 public function showRankingBySectionEGIS() {730 $sectionCode = $_POST["sectionCode"];731 $sectionCodeNS = $_POST["sectionCodeNS"];732 $data['sectionCode'] = $sectionCode;733 $data['sectionCodeNS'] = $sectionCodeNS;734 $userName = $this->_getUserName(1);735 $gradingPeriod = $_SESSION['gP'];736 $results = null;737 //$sectionCode = '1005ABM 1-ABM1';738 //$sectionCodeNS = '1005ABM1-ABM1';739 //$data['sectionCode'] = $sectionCode;740 //$data['sectionCodeNS'] = $sectionCodeNS;741 //CONDITION AND ACTION FOR DELETION742 $where = array($sectionCode, $userName);743 $fieldName = array('sectionCode', 'userNumber');744 $this->_deleteRecords('triune_wip_grades_ranking', $fieldName, $where);745 746 $selectFields = "triune_subject_elementary.subjectCode, triune_subject_elementary.subjectDescription, triune_subject_elementary.weight";747 $results = $this->_getRecordsData($dataSelect1 = array($selectFields), 748 $tables = array('triune_section_elementary', 'triune_subject_elementary'), $fieldName = array('triune_section_elementary.sectionCode'), $where = array($sectionCode), 749 $join = array('triune_section_elementary.subjectCode = triune_subject_elementary.subjectCode'), $joinType = array('inner'), 750 $sortBy = array('displaySequence'), $sortOrder = array('asc'), $limit = null, 751 $fieldNameLike = null, $like = null, 752 $whereSpecial = null, $groupBy = null );753 754 if(empty($results)) {755 $selectFields = "triune_subject_junior_high.subjectCode, triune_subject_junior_high.subjectDescription, triune_subject_junior_high.weight";756 $results = $this->_getRecordsData($dataSelect1 = array($selectFields), 757 $tables = array('triune_section_junior_high', 'triune_subject_junior_high'), $fieldName = array('triune_section_junior_high.sectionCode'), $where = array($sectionCode), 758 $join = array('triune_section_junior_high.subjectCode = triune_subject_junior_high.subjectCode'), $joinType = array('inner'), 759 $sortBy = array('displaySequence'), $sortOrder = array('asc'), $limit = null, 760 $fieldNameLike = null, $like = null, 761 $whereSpecial = null, $groupBy = null );762 763 if(empty($results)) {764 $selectFields = "triune_subject_senior_high.subjectCode, triune_subject_senior_high.subjectDescription, triune_subject_senior_high.weight";765 $results = $this->_getRecordsData($dataSelect1 = array($selectFields), 766 $tables = array('triune_section_senior_high', 'triune_subject_senior_high'), 767 $fieldName = array('triune_subject_senior_high.sem', 'triune_section_senior_high.sectionCode'), $where = array($_SESSION['sem'], $sectionCode, ), 768 $join = array('triune_section_senior_high.subjectCode = triune_subject_senior_high.subjectCode'), $joinType = array('inner'), 769 $sortBy = array('displaySequence'), $sortOrder = array('asc'), $limit = null, 770 $fieldNameLike = null, $like = null, 771 $whereSpecial = null, $groupBy = null );772 }773 774 775 }776 $weight = array();777 $this->db->trans_start();778 $subjCtr = 1;779 $weightCtr = 0;780 $totalWeight = 0;781 foreach($results as $rowHeader) {782 $subjField = 'subj' . $subjCtr;783 784 if($subjCtr == 1) {785 $insertData1 = null;786 $insertData1 = array(787 'studentNumber' => 'HEADER',788 'lastName' => 'SUBJECT',789 'sectionCode' => $sectionCode,790 $subjField => $rowHeader->subjectCode,791 'userNumber' => $userName,792 'timeStamp' => $this->_getTimeStamp(),793 ); 794 $insertedRecord1 =$this->_insertRecords($tableName = 'triune_wip_grades_ranking', $insertData1); 795 } else {796 $recordUpdate = array(797 $subjField => $rowHeader->subjectCode,798 );799 800 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 801 $fieldName = array('studentNumber'), 802 $where = array('HEADER'), $recordUpdate);803 804 } 805 $weight[$weightCtr] = $rowHeader->weight;806 $totalWeight = $totalWeight + $rowHeader->weight;807 $weightCtr++;808 $subjCtr++;809 }810 $data['subjCtr'] = $subjCtr;811 $data['weightCtr'] = $weightCtr; 812 $data['weight'] = $weight;813 $data['totalWeight'] = $totalWeight;814 815 $scoreCtr = 1; 816 $switch = 1;817 $totalScore = [];818 $totalWeightedAverage = [];819 $studentNo = [];820 $recordCount = null;821 822 823 if($gradingPeriod == '1') {824 $recordCount = $this->_getRecordsData($dataSelect1 = array('studentNumber'), 825 $tables = array('triune_grades_score_sheet_1_summary'), 826 $fieldName = array('triune_grades_score_sheet_1_summary.sy', 'triune_grades_score_sheet_1_summary.sectionCode'), 827 $where = array($_SESSION['sy'], $sectionCode),$join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, 828 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );829 } elseif($gradingPeriod == '2') {830 $recordCount = $this->_getRecordsData($dataSelect1 = array('studentNumber'), 831 $tables = array('triune_grades_score_sheet_2_summary'), 832 $fieldName = array('triune_grades_score_sheet_2_summary.sy', 'triune_grades_score_sheet_2_summary.sectionCode'), 833 $where = array($_SESSION['sy'], $sectionCode),$join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, 834 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );835 } elseif($gradingPeriod == '3') {836 $recordCount = $this->_getRecordsData($dataSelect1 = array('studentNumber'), 837 $tables = array('triune_grades_score_sheet_3_summary'), 838 $fieldName = array('triune_grades_score_sheet_3_summary.sy', 'triune_grades_score_sheet_3_summary.sectionCode'), 839 $where = array($_SESSION['sy'], $sectionCode),$join = null, $joinType = null, $sortBy = null, $sortOrder = null, $limit = null, 840 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );841 842 }843 $z = 0;844 foreach($recordCount as $r) {845 $totalScore[$z] = 0;846 $z++;847 } 848 foreach($results as $row) {849 $details = null;850 if($gradingPeriod == '1') {851 $selectDetail = "triune_students_k12.studentNumber, triune_students_k12.lastName, triune_students_k12.firstName, ";852 $selectDetail = $selectDetail . "triune_students_k12.middleName, triune_grades_score_sheet_1_summary.transmutedGrade, triune_grades_score_sheet_1_summary.subjectCode";853 $details = $this->_getRecordsData($dataSelect1 = array($selectDetail), 854 $tables = array('triune_grades_score_sheet_1_summary', 'triune_students_k12'), 855 $fieldName = array('triune_grades_score_sheet_1_summary.sectionCode', 'triune_grades_score_sheet_1_summary.subjectCode'), 856 $where = array($sectionCode, $row->subjectCode), 857 $join = array('triune_grades_score_sheet_1_summary.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 858 $sortBy = array('studentNumber'), $sortOrder = array('asc'), $limit = null, 859 $fieldNameLike = null, $like = null, 860 $whereSpecial = null, $groupBy = null );861 print_r($details);862 } elseif($gradingPeriod == '2') {863 $selectDetail = "triune_students_k12.studentNumber, triune_students_k12.lastName, triune_students_k12.firstName, ";864 $selectDetail = $selectDetail . "triune_students_k12.middleName, triune_grades_score_sheet_2_summary.transmutedGrade, triune_grades_score_sheet_2_summary.subjectCode";865 $details = $this->_getRecordsData($dataSelect1 = array($selectDetail), 866 $tables = array('triune_grades_score_sheet_2_summary', 'triune_students_k12'), 867 $fieldName = array('triune_grades_score_sheet_2_summary.sectionCode', 'triune_grades_score_sheet_2_summary.subjectCode'), 868 $where = array($sectionCode, $row->subjectCode), 869 $join = array('triune_grades_score_sheet_2_summary.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 870 $sortBy = array('studentNumber'), $sortOrder = array('asc'), $limit = null, 871 $fieldNameLike = null, $like = null, 872 $whereSpecial = null, $groupBy = null );873 } elseif($gradingPeriod == '3') {874 $selectDetail = "triune_students_k12.studentNumber, triune_students_k12.lastName, triune_students_k12.firstName, ";875 $selectDetail = $selectDetail . "triune_students_k12.middleName, triune_grades_score_sheet_3_summary.transmutedGrade, triune_grades_score_sheet_3_summary.subjectCode";876 $details = $this->_getRecordsData($dataSelect1 = array($selectDetail), 877 $tables = array('triune_grades_score_sheet_3_summary', 'triune_students_k12'), 878 $fieldName = array('triune_grades_score_sheet_3_summary.sectionCode', 'triune_grades_score_sheet_3_summary.subjectCode'), 879 $where = array($sectionCode, $row->subjectCode), 880 $join = array('triune_grades_score_sheet_3_summary.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 881 $sortBy = array('studentNumber'), $sortOrder = array('asc'), $limit = null, 882 $fieldNameLike = null, $like = null, 883 $whereSpecial = null, $groupBy = null );884 }885 $scoreField = 'subj' . $scoreCtr;886 $recCtr = 0;887 if(!empty($details)) {888 889 foreach($details as $det) {890 if($scoreCtr == 1 || $switch == 1) {891 $insertData1 = null;892 $insertData1 = array(893 'studentNumber' => $det->studentNumber,894 'lastName' => $det->lastName,895 'firstName' => $det->firstName,896 'middleName' => $det->middleName,897 'sectionCode' => $sectionCode,898 $scoreField => $det->transmutedGrade,899 'userNumber' => $userName,900 'timeStamp' => $this->_getTimeStamp(),901 ); 902 $insertedRecord1 =$this->_insertRecords($tableName = 'triune_wip_grades_ranking', $insertData1); 903 904 } else {905 906 $recordUpdate = array(907 $scoreField => $det->transmutedGrade,908 );909 910 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 911 $fieldName = array('studentNumber'), 912 $where = array($det->studentNumber), $recordUpdate);913 914 }915 //echo $row->weight . " " . $scoreCtr . " " . $row->subjectCode . " " . $det->lastName . " " . $det->studentNumber . " " . $scoreField . " " . $det->transmutedGrade . "<br>";916 917 $totalScore[$recCtr] = $totalScore[$recCtr] + ($det->transmutedGrade * $row->weight);918 //echo $totalScore[$recCtr] . "<br>";919 //echo $recCtr . ") " . $det->studentNumber . " >> " . " = " .$totalScore[$recCtr] . " / " . $totalWeight . " -->" . "<br>"; 920 //echo " -------------------------------------------<br>";921 $studentNo[$recCtr] = $det->studentNumber;922 $recCtr++;923 }924 $switch = 0;925 926 } else {927 //echo "-------------------------------------";928 //echo $scoreCtr . " " . $row->subjectCode . "<br>";929 }930 $scoreCtr++;931 }932 933 $totalItems = count($totalScore);934 //$data['t'] = $totalItems;935 for($i = 0; $i < $totalItems; $i++) {936 $totalWeightedAverage[$i] = ($totalScore[$i] / $totalWeight); 937 938 //echo $studentNo[$i] . " " . $totalScore[$i] . " ---> " . $totalWeight . " >>>" . $totalWeightedAverage[$i] . "<br>";939 $recordUpdate = array(940 'weightedAverage' => $totalWeightedAverage[$i],941 );942 943 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 944 $fieldName = array('studentNumber'), 945 $where = array($studentNo[$i]), $recordUpdate);946 }947 948 949 $this->db->trans_complete(); 950 951 $grades = $this->_getRecordsData($dataSelect2 = array('*'), 952 $tables = array('triune_wip_grades_ranking'), 953 $fieldName = array('sectionCode', 'userNumber'), $where = array($sectionCode, $userName), 954 $join = null, $joinType = null, $sortBy = array('weightedAverage'), $sortOrder = array('desc'), $limit = null, 955 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );956 957 $data['grades'] = (array) $grades;958 959 $data['t'] = count($data['grades']) - 1;960 961 $this->load->library('Pdf'); 962 $this->load->view('EGIS/ranking-by-section-report', $data);963 } 964 965 public function showRankingByYearLevelEGIS() {966 $yearLevel = $_POST["yearLevel"];967 //$yearLevel = 1;968 $data['yearLevel'] = $yearLevel;969 $userName = $this->_getUserName(1);970 $results = null;971 $gradingPeriod = $_SESSION['gP'];972 $yearLevelSH = 11;973 $courseCodeSH = '';974 //CONDITION AND ACTION FOR DELETION975 $where = array($yearLevel, $userName);976 $fieldName = array('yearLevel', 'userNumber');977 $this->_deleteRecords('triune_wip_grades_ranking', $fieldName, $where);978 979 $selectHead = "triune_subject_elementary.subjectCode, triune_subject_elementary.subjectDescription, triune_subject_elementary.weight";980 $resultsHead = $this->_getRecordsData($dataSelect1 = array($selectHead), 981 $tables = array('triune_section_elementary', 'triune_subject_elementary'), $fieldName = array('triune_section_elementary.yearLevel'), 982 $where = array($yearLevel), $join = array('triune_section_elementary.subjectCode = triune_subject_elementary.subjectCode'), 983 $joinType = array('inner'), $sortBy = array('displaySequence'), $sortOrder = array('asc'), $limit = null, 984 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );985 986 if(empty($resultsHead)) {987 $selectHead = "triune_subject_junior_high.subjectCode, triune_subject_junior_high.subjectDescription, triune_subject_junior_high.weight";988 $resultsHead = $this->_getRecordsData($dataSelect1 = array($selectHead), 989 $tables = array('triune_section_junior_high', 'triune_subject_junior_high'), $fieldName = array('triune_section_junior_high.yearLevel'), 990 $where = array($yearLevel), $join = array('triune_section_junior_high.subjectCode = triune_subject_junior_high.subjectCode'), 991 $joinType = array('inner'), $sortBy = array('displaySequence'), $sortOrder = array('asc'), $limit = null, 992 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );993 if(empty($resultsHead)) {994 995 if($yearLevel == 11) {996 $yearLevelSH = 1;997 $courseCodeSH = '1005ABM';998 } elseif($yearLevel == 12) {999 $yearLevelSH = 2;1000 $courseCodeSH = '1005ABM2';1001 } elseif($yearLevel == 21) {1002 $yearLevelSH = 1;1003 $courseCodeSH = '1005HUM';1004 } elseif($yearLevel == 22) {1005 $yearLevelSH = 2;1006 $courseCodeSH = '1005HUM2';1007 } elseif($yearLevel == 31) {1008 $yearLevelSH = 1;1009 $courseCodeSH = '1005STE';1010 } elseif($yearLevel == 32) {1011 $yearLevelSH = 2;1012 $courseCodeSH = '1005STE2';1013 }1014 1015 $selectHead = "triune_subject_senior_high.subjectCode, triune_subject_senior_high.subjectDescription, triune_subject_senior_high.weight";1016 $resultsHead = $this->_getRecordsData($dataSelect1 = array($selectHead), 1017 $tables = array('triune_section_senior_high', 'triune_subject_senior_high'), 1018 $fieldName = array('triune_subject_senior_high.sem', 'triune_subject_senior_high.courseCode', 'triune_section_senior_high.yearLevel'), 1019 $where = array($_SESSION['sem'], $courseCodeSH, $yearLevelSH), $join = array('triune_section_senior_high.subjectCode = triune_subject_senior_high.subjectCode'), 1020 $joinType = array('inner'), $sortBy = array('displaySequence'), $sortOrder = array('asc'), $limit = null, 1021 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );1022 }1023 }1024 1025 1026 1027 $selectFields = "triune_subject_elementary.subjectCode, triune_subject_elementary.subjectDescription, triune_subject_elementary.weight, ";1028 $selectFields = $selectFields . "triune_section_elementary.sectionCode";1029 $results = $this->_getRecordsData($dataSelect1 = array($selectFields), 1030 $tables = array('triune_section_elementary', 'triune_subject_elementary'), $fieldName = array('triune_section_elementary.yearLevel'), 1031 $where = array($yearLevel), $join = array('triune_section_elementary.subjectCode = triune_subject_elementary.subjectCode'), 1032 $joinType = array('inner'), $sortBy = array('triune_section_elementary.sectionCode', 'displaySequence'), $sortOrder = array('asc', 'asc'), $limit = null, 1033 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );1034 1035 if(empty($results)) {1036 $selectFields = "triune_subject_junior_high.subjectCode, triune_subject_junior_high.subjectDescription, triune_subject_junior_high.weight, ";1037 $selectFields = $selectFields . "triune_section_junior_high.sectionCode";1038 $results = $this->_getRecordsData($dataSelect1 = array($selectFields), 1039 $tables = array('triune_section_junior_high', 'triune_subject_junior_high'), $fieldName = array('triune_section_junior_high.yearLevel'), 1040 $where = array($yearLevel), $join = array('triune_section_junior_high.subjectCode = triune_subject_junior_high.subjectCode'), 1041 $joinType = array('inner'), $sortBy = array('triune_section_junior_high.sectionCode', 'displaySequence'), $sortOrder = array('asc', 'asc'), $limit = null, 1042 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );1043 if(empty($results)) {1044 1045 if($yearLevel == 11) {1046 $yearLevelSH = 1;1047 $courseCodeSH = '1005ABM';1048 //$data['yearLevel'] = '1005ABM';1049 } elseif($yearLevel == 12) {1050 $yearLevelSH = 2;1051 $courseCodeSH = '1005ABM2';1052 //$data['yearLevel'] = '1005ABM2';1053 } elseif($yearLevel == 21) {1054 $yearLevelSH = 1;1055 $courseCodeSH = '1005HUM';1056 //$data['yearLevel'] = '1005HUM';1057 } elseif($yearLevel == 22) {1058 $yearLevelSH = 2;1059 $courseCodeSH = '1005HUM2';1060 //$data['yearLevel'] = '1005HUM2';1061 } elseif($yearLevel == 31) {1062 $yearLevelSH = 1;1063 $courseCodeSH = '1005STE';1064 //$data['yearLevel'] = '1005STE';1065 } elseif($yearLevel == 32) {1066 $yearLevelSH = 2;1067 $courseCodeSH = '1005STE2';1068 //$data['yearLevel'] = '1005STE2';1069 }1070 1071 $selectFields = "triune_subject_senior_high.subjectCode, triune_subject_senior_high.subjectDescription, triune_subject_senior_high.weight, ";1072 $selectFields = $selectFields . "triune_section_senior_high.sectionCode";1073 $results = $this->_getRecordsData($dataSelect1 = array($selectFields), 1074 $tables = array('triune_section_senior_high', 'triune_subject_senior_high'), 1075 $fieldName = array('triune_subject_senior_high.sem', 'triune_subject_senior_high.courseCode', 'triune_section_senior_high.yearLevel'), 1076 $where = array($_SESSION['sem'], $courseCodeSH, $yearLevelSH), $join = array('triune_section_senior_high.subjectCode = triune_subject_senior_high.subjectCode'), 1077 $joinType = array('inner'), $sortBy = array('triune_section_senior_high.sectionCode', 'displaySequence'), $sortOrder = array('asc', 'asc'), $limit = null, 1078 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );1079 }1080 1081 1082 }1083 $weight = array();1084 $this->db->trans_start();1085 $subjCtr = 1;1086 $weightCtr = 0;1087 $totalWeight = 0;1088 foreach($resultsHead as $rowHeader) {1089 $subjField = 'subj' . $subjCtr;1090 //echo $rowHeader->subjectCode . "<br>";1091 if($subjCtr == 1) {1092 $insertData1 = null;1093 $insertData1 = array(1094 'studentNumber' => 'HEADER',1095 'lastName' => 'SUBJECT',1096 'yearLevel' => $yearLevel,1097 $subjField => $rowHeader->subjectCode,1098 'userNumber' => $userName,1099 'timeStamp' => $this->_getTimeStamp(),1100 ); 1101 $insertedRecord1 =$this->_insertRecords($tableName = 'triune_wip_grades_ranking', $insertData1); 1102 } else {1103 $recordUpdate = array(1104 $subjField => $rowHeader->subjectCode,1105 );1106 1107 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 1108 $fieldName = array('studentNumber'), 1109 $where = array('HEADER'), $recordUpdate);1110 1111 } 1112 $weight[$weightCtr] = $rowHeader->weight;1113 $totalWeight = $totalWeight + $rowHeader->weight;1114 $weightCtr++;1115 $subjCtr++;1116 }1117 $data['subjCtr'] = $subjCtr;1118 1119 //echo $subjCtr;1120 $data['weightCtr'] = $weightCtr; 1121 $data['weight'] = $weight;1122 $data['totalWeight'] = $totalWeight;1123 //echo $weightCtr; 1124 $scoreCtr = 1; 1125 $switch = 1;1126 $totalScore = [];1127 $totalWeightedAverage = [];1128 $studentNo = [];1129 $recordCount = null;1130 1131 if($gradingPeriod == '1') {1132 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_1.studentNumber'), 1133 $tables = array('triune_section_elementary', 'triune_grades_score_sheet_1'), $fieldName = array('triune_section_elementary.yearLevel'), 1134 $where = array($yearLevel), $join = array('triune_section_elementary.sectionCode = triune_grades_score_sheet_1.sectionCode'), 1135 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1136 $groupBy = null );1137 } elseif($gradingPeriod == '2') {1138 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_2.studentNumber'), 1139 $tables = array('triune_section_elementary', 'triune_grades_score_sheet_2'), $fieldName = array('triune_section_elementary.yearLevel'), 1140 $where = array($yearLevel), $join = array('triune_section_elementary.sectionCode = triune_grades_score_sheet_2.sectionCode'), 1141 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1142 $groupBy = null );1143 } elseif($gradingPeriod == '3') {1144 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_3.studentNumber'), 1145 $tables = array('triune_section_elementary', 'triune_grades_score_sheet_3'), $fieldName = array('triune_section_elementary.yearLevel'), 1146 $where = array($yearLevel), $join = array('triune_section_elementary.sectionCode = triune_grades_score_sheet_3.sectionCode'), 1147 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1148 $groupBy = null );1149 1150 }1151 if(empty($recordCount)) {1152 if($gradingPeriod == '1') {1153 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_1.studentNumber'), 1154 $tables = array('triune_section_junior_high', 'triune_grades_score_sheet_1'), $fieldName = array('triune_section_junior_high.yearLevel'), 1155 $where = array($yearLevel), $join = array('triune_section_junior_high.sectionCode = triune_grades_score_sheet_1.sectionCode'), 1156 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1157 $groupBy = null );1158 } elseif($gradingPeriod == '2') {1159 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_2.studentNumber'), 1160 $tables = array('triune_section_junior_high', 'triune_grades_score_sheet_2'), $fieldName = array('triune_section_junior_high.yearLevel'), 1161 $where = array($yearLevel), $join = array('triune_section_junior_high.sectionCode = triune_grades_score_sheet_2.sectionCode'), 1162 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1163 $groupBy = null );1164 } elseif($gradingPeriod == '3') {1165 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_3.studentNumber'), 1166 $tables = array('triune_section_junior_high', 'triune_grades_score_sheet_3'), $fieldName = array('triune_section_junior_high.yearLevel'), 1167 $where = array($yearLevel), $join = array('triune_section_junior_high.sectionCode = triune_grades_score_sheet_3.sectionCode'), 1168 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1169 $groupBy = null );1170 }1171 1172 if(empty($recordCount)) {1173 if($gradingPeriod == '1') {1174 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_1.studentNumber'), 1175 $tables = array('triune_section_senior_high', 'triune_grades_score_sheet_1'), 1176 $fieldName = array('triune_grades_score_sheet_1.sy', 'triune_section_senior_high.yearLevel'), 1177 $where = array($_SESSION['sy'], $yearLevelSH), $join = array('triune_section_senior_high.sectionCode = triune_grades_score_sheet_1.sectionCode'), 1178 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1179 $groupBy = null );1180 } elseif($gradingPeriod == '2') {1181 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_2.studentNumber'), 1182 $tables = array('triune_section_senior_high', 'triune_grades_score_sheet_2'), 1183 $fieldName = array('triune_grades_score_sheet_2.sy', 'triune_section_senior_high.yearLevel'), 1184 $where = array($_SESSION['sy'], $yearLevelSH), $join = array('triune_section_senior_high.sectionCode = triune_grades_score_sheet_2.sectionCode'), 1185 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1186 $groupBy = null );1187 } elseif($gradingPeriod == '3') {1188 $recordCount = $this->_getRecordsData($dataSelect1 = array('triune_grades_score_sheet_3.studentNumber'), 1189 $tables = array('triune_section_senior_high', 'triune_grades_score_sheet_3'), 1190 $fieldName = array('triune_grades_score_sheet_3.sy', 'triune_section_senior_high.yearLevel'), 1191 $where = array($_SESSION['sy'], $yearLevelSH), $join = array('triune_section_senior_high.sectionCode = triune_grades_score_sheet_3.sectionCode'), 1192 $joinType = array('inner'), $sortBy = null, $sortOrder = null, $limit = null, $fieldNameLike = null, $like = null, $whereSpecial = null, 1193 $groupBy = null );1194 }1195 }1196 } 1197 1198 $z = 0;1199 foreach($recordCount as $r) {1200 $totalScore[$z] = 0;1201 $z++;1202 } 1203 $sectionCodeNext = null;1204 1205 foreach($results as $row) {1206 //echo "---------<br>";1207 //echo $row->subjectCode . "<br>";1208 1209 $details = null;1210 1211 if($gradingPeriod == '1') {1212 $selectDetail = "triune_students_k12.studentNumber, triune_students_k12.lastName, triune_students_k12.firstName, triune_grades_score_sheet_1_summary.sectionCode, ";1213 $selectDetail = $selectDetail . "triune_students_k12.middleName, triune_grades_score_sheet_1_summary.transmutedGrade, triune_grades_score_sheet_1_summary.subjectCode";1214 $details = $this->_getRecordsData($dataSelect1 = array($selectDetail), 1215 $tables = array('triune_grades_score_sheet_1_summary', 'triune_students_k12'), 1216 $fieldName = array('triune_grades_score_sheet_1_summary.sectionCode', 'triune_grades_score_sheet_1_summary.subjectCode'), 1217 $where = array($row->sectionCode, $row->subjectCode), 1218 $join = array('triune_grades_score_sheet_1_summary.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 1219 $sortBy = array('studentNumber'), $sortOrder = array('asc'), $limit = null, 1220 $fieldNameLike = null, $like = null, 1221 $whereSpecial = null, $groupBy = null );1222 } elseif($gradingPeriod == '2') {1223 $selectDetail = "triune_students_k12.studentNumber, triune_students_k12.lastName, triune_students_k12.firstName, triune_grades_score_sheet_2_summary.sectionCode, ";1224 $selectDetail = $selectDetail . "triune_students_k12.middleName, triune_grades_score_sheet_2_summary.transmutedGrade, triune_grades_score_sheet_2_summary.subjectCode";1225 $details = $this->_getRecordsData($dataSelect1 = array($selectDetail), 1226 $tables = array('triune_grades_score_sheet_2_summary', 'triune_students_k12'), 1227 $fieldName = array('triune_grades_score_sheet_2_summary.sectionCode', 'triune_grades_score_sheet_2_summary.subjectCode'), 1228 $where = array($row->sectionCode, $row->subjectCode), 1229 $join = array('triune_grades_score_sheet_2_summary.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 1230 $sortBy = array('studentNumber'), $sortOrder = array('asc'), $limit = null, 1231 $fieldNameLike = null, $like = null, 1232 $whereSpecial = null, $groupBy = null );1233 } elseif($gradingPeriod == '3') {1234 $selectDetail = "triune_students_k12.studentNumber, triune_students_k12.lastName, triune_students_k12.firstName, triune_grades_score_sheet_3_summary.sectionCode, ";1235 $selectDetail = $selectDetail . "triune_students_k12.middleName, triune_grades_score_sheet_3_summary.transmutedGrade, triune_grades_score_sheet_3_summary.subjectCode";1236 $details = $this->_getRecordsData($dataSelect1 = array($selectDetail), 1237 $tables = array('triune_grades_score_sheet_3_summary', 'triune_students_k12'), 1238 $fieldName = array('triune_grades_score_sheet_3_summary.sectionCode', 'triune_grades_score_sheet_3_summary.subjectCode'), 1239 $where = array($row->sectionCode, $row->subjectCode), 1240 $join = array('triune_grades_score_sheet_3_summary.studentNumber = triune_students_k12.studentNumber'), $joinType = array('inner'), 1241 $sortBy = array('studentNumber'), $sortOrder = array('asc'), $limit = null, 1242 $fieldNameLike = null, $like = null, 1243 $whereSpecial = null, $groupBy = null );1244 }1245 $scoreField = 'subj' . $scoreCtr;1246 $recCtr = 0;1247 echo $row->sectionCode . " " . $row->subjectCode . " " . $recCtr ."<br>";1248 1249 1250 if(!empty($details)) {1251 1252 foreach($details as $det) {1253 if($scoreCtr == 1 || $switch == 1) {1254 $insertData1 = null;1255 $insertData1 = array(1256 'studentNumber' => $det->studentNumber,1257 'lastName' => $det->lastName,1258 'firstName' => $det->firstName,1259 'middleName' => $det->middleName,1260 'sectionCode' => $det->sectionCode,1261 'yearLevel' => $yearLevel,1262 $scoreField => $det->transmutedGrade,1263 'userNumber' => $userName,1264 'timeStamp' => $this->_getTimeStamp(),1265 ); 1266 $insertedRecord1 =$this->_insertRecords($tableName = 'triune_wip_grades_ranking', $insertData1); 1267 1268 } else {1269 1270 $recordUpdate = array(1271 $scoreField => $det->transmutedGrade,1272 );1273 1274 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 1275 $fieldName = array('studentNumber'), 1276 $where = array($det->studentNumber), $recordUpdate);1277 1278 }1279 //echo $row->weight . " " . $scoreCtr . " " . $row->subjectCode . " " . $det->lastName . " " . $det->studentNumber . " " . $scoreField . " " . $det->transmutedGrade . "<br>";1280 1281 $totalScore[$recCtr] = $totalScore[$recCtr] + ($det->transmutedGrade * $row->weight);1282 //echo $totalScore[$recCtr] . "<br>";1283 echo $recCtr . ") " . $scoreField . " -- " . $det->studentNumber . " >> " . $det->sectionCode . " = " .$totalScore[$recCtr] . " / " . $totalWeight . " -->" . "<br>"; 1284 //echo " -------------------------------------------<br>";1285 $studentNo[$recCtr] = $det->studentNumber;1286 $recCtr++;1287 1288 }1289 $switch = 0;1290 } else {1291 //echo "-------------------------------------";1292 //echo $scoreCtr . " " . $row->subjectCode . "<br>";1293 }1294 $peek = next($results); 1295 1296 if(isset($peek->sectionCode)) {1297 $sectionCodeNext = $peek->sectionCode;1298 }1299 1300 //echo $row->sectionCode . " === " . $sectionCodeNext . " " . $scoreCtr . "<br>";1301 if( ($sectionCodeNext != null) && (trim($sectionCodeNext) != trim($row->sectionCode))) {1302 //echo "OHAYOOO<br>";1303 $scoreCtr = 0;1304 $switch = 1;1305 for($i = 0; $i < (count($studentNo)); $i++) {1306 $totalWeightedAverage[$i] = ($totalScore[$i] / $totalWeight); 1307 1308 echo $studentNo[$i] . " " . $totalScore[$i] . " ---> " . $totalWeight . " >>>" . $totalWeightedAverage[$i] . "<br>";1309 $recordUpdate = array(1310 'weightedAverage' => $totalWeightedAverage[$i],1311 );1312 1313 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 1314 $fieldName = array('studentNumber'), 1315 $where = array($studentNo[$i]), $recordUpdate);1316 }1317 $studentNo = null;1318 $totalScore = null;1319 $totalWeightedAverage = null;1320 }1321 1322 $scoreCtr++;1323 1324 }1325 //echo "v " . $z . "--vvvvvvvvv--";1326 //$data['t'] = ($z - 1);1327 for($i = 0; $i < (count($studentNo)); $i++) {1328 $totalWeightedAverage[$i] = ($totalScore[$i] / $totalWeight); 1329 1330 echo $studentNo[$i] . " " . $totalScore[$i] . " ---> " . $totalWeight . " >>>" . $totalWeightedAverage[$i] . "<br>";1331 $recordUpdate = array(1332 'weightedAverage' => $totalWeightedAverage[$i],1333 );1334 1335 $this->_updateRecords($tableName = 'triune_wip_grades_ranking', 1336 $fieldName = array('studentNumber'), 1337 $where = array($studentNo[$i]), $recordUpdate);1338 }1339 1340 1341 $this->db->trans_complete(); 1342 1343 $grades = $this->_getRecordsData($dataSelect2 = array('*'), 1344 $tables = array('triune_wip_grades_ranking'), 1345 $fieldName = array('yearLevel', 'userNumber'), $where = array($yearLevel, $userName), 1346 $join = null, $joinType = null, $sortBy = array('weightedAverage'), $sortOrder = array('desc'), $limit = null, 1347 $fieldNameLike = null, $like = null, $whereSpecial = null, $groupBy = null );1348 //var_dump($grades);1349 $data['grades'] = (array) $grades;1350 $data['t'] = count($data['grades']) - 1;1351 1352 $data['yearLevelLabel'] = null;1353 if($yearLevel == 11) {1354 $data['yearLevelLabel'] = '1005ABM';1355 } elseif($yearLevel == 12) {1356 $data['yearLevelLabel'] = '1005ABM2';1357 } elseif($yearLevel == 21) {1358 $data['yearLevelLabel'] = '1005HUM';1359 } elseif($yearLevel == 22) {1360 $data['yearLevelLabel'] = '1005HUM2';...
results_data_generator.class.php
Source:results_data_generator.class.php
1<?php2/* For licensing terms, see /license.txt */3/**4 * ResultsDataGenerator Class5 * Class to select, sort and transform object data into array data,6 * used for the teacher's evaluation results view.7 *8 * @author Bert Steppé9 */10class ResultsDataGenerator11{12 // Sorting types constants13 const RDG_SORT_LASTNAME = 1;14 const RDG_SORT_FIRSTNAME = 2;15 const RDG_SORT_SCORE = 4;16 const RDG_SORT_MASK = 8;17 const RDG_SORT_ASC = 16;18 const RDG_SORT_DESC = 32;19 private $evaluation;20 private $results;21 private $is_course_ind;22 private $include_edit;23 /**24 * Constructor.25 */26 public function __construct(27 $evaluation,28 $results = [],29 $include_edit = false30 ) {31 $this->evaluation = $evaluation;32 $this->results = isset($results) ? $results : [];33 }34 /**35 * Get total number of results (rows).36 */37 public function get_total_results_count()38 {39 return count($this->results);40 }41 /**42 * Get actual array data.43 *44 * @param int $count45 *46 * @return array 2-dimensional array - each array contains the elements:47 * 0 ['id'] : user id48 * 1 ['result_id'] : result id49 * 2 ['lastname'] : user lastname50 * 3 ['firstname'] : user firstname51 * 4 ['score'] : student's score52 * 5 ['display'] : custom score display (only if custom scoring enabled)53 */54 public function get_data(55 $sorting = 0,56 $start = 0,57 $count = null,58 $ignore_score_color = false,59 $pdf = false60 ) {61 // do some checks on count, redefine if invalid value62 $number_decimals = api_get_setting('gradebook_number_decimals');63 if (!isset($count)) {64 $count = count($this->results) - $start;65 }66 if ($count < 0) {67 $count = 0;68 }69 $model = ExerciseLib::getCourseScoreModel();70 $scoreDisplay = ScoreDisplay::instance();71 // generate actual data array72 $table = [];73 foreach ($this->results as $result) {74 $user = [];75 $info = api_get_user_info($result->get_user_id());76 $user['id'] = $result->get_user_id();77 if ($pdf) {78 $user['username'] = $info['username'];79 }80 $user['result_id'] = $result->get_id();81 $user['lastname'] = $info['lastname'];82 $user['firstname'] = $info['firstname'];83 if ($pdf) {84 $user['score'] = $result->get_score();85 } else {86 $user['score'] = $this->get_score_display(87 $result->get_score(),88 true,89 $ignore_score_color90 );91 }92 $user['percentage_score'] = (int) $scoreDisplay->display_score(93 [$result->get_score(), $this->evaluation->get_max()],94 SCORE_PERCENT,95 SCORE_BOTH,96 true97 );98 if ($pdf && null == $number_decimals) {99 $user['scoreletter'] = $result->get_score();100 }101 if ($scoreDisplay->is_custom()) {102 $user['display'] = $this->get_score_display(103 $result->get_score(),104 false,105 $ignore_score_color106 );107 if (!empty($model)) {108 $user['display'] .= ' '.109 ExerciseLib::show_score(110 $result->get_score(),111 $this->evaluation->get_max()112 )113 ;114 }115 }116 $table[] = $user;117 }118 // sort array119 if ($sorting & self::RDG_SORT_LASTNAME) {120 usort($table, ['ResultsDataGenerator', 'sort_by_last_name']);121 } elseif ($sorting & self::RDG_SORT_FIRSTNAME) {122 usort($table, ['ResultsDataGenerator', 'sort_by_first_name']);123 } elseif ($sorting & self::RDG_SORT_SCORE) {124 usort($table, ['ResultsDataGenerator', 'sort_by_score']);125 } elseif ($sorting & self::RDG_SORT_MASK) {126 usort($table, ['ResultsDataGenerator', 'sort_by_mask']);127 }128 if ($sorting & self::RDG_SORT_DESC) {129 $table = array_reverse($table);130 }131 $return = array_slice($table, $start, $count);132 return $return;133 }134 // Sort functions - used internally135 /**136 * @param array $item1137 * @param array $item2138 *139 * @return int140 */141 public function sort_by_last_name($item1, $item2)142 {143 return api_strcmp($item1['lastname'], $item2['lastname']);144 }145 /**146 * @param array $item1147 * @param array $item2148 *149 * @return int150 */151 public function sort_by_first_name($item1, $item2)152 {153 return api_strcmp($item1['firstname'], $item2['firstname']);154 }155 /**156 * @param array $item1157 * @param array $item2158 *159 * @return int160 */161 public function sort_by_score($item1, $item2)162 {163 if ($item1['percentage_score'] == $item2['percentage_score']) {164 return 0;165 } else {166 return $item1['percentage_score'] < $item2['percentage_score'] ? -1 : 1;167 }168 }169 /**170 * @param array $item1171 * @param array $item2172 *173 * @return int174 */175 public function sort_by_mask($item1, $item2)176 {177 $score1 = (isset($item1['score']) ? [$item1['score'], $this->evaluation->get_max()] : null);178 $score2 = (isset($item2['score']) ? [$item2['score'], $this->evaluation->get_max()] : null);179 return ScoreDisplay::compare_scores_by_custom_display($score1, $score2);180 }181 /**182 * Re-formats the score to show percentage ("2/4 (50 %)") or letters ("A").183 *184 * @param float Current absolute score (max score is taken from $this->evaluation->get_max()185 * @param bool Whether we want the real score (2/4 (50 %)) or the transformation (A, B, C, etc)186 * @param bool Whether we want to ignore the score color187 * @param bool $realscore188 *189 * @return string The score as we want to show it...
Score.php
Source:Score.php
1<?php2/**3 * @file4 * Contains \Drupal\search\Plugin\views\sort\Score.5 */6namespace Drupal\search\Plugin\views\sort;7use Drupal\views\Plugin\views\sort\SortPluginBase;8/**9 * Sort handler for sorting by search score.10 *11 * @ingroup views_sort_handlers12 *13 * @ViewsSort("search_score")14 */15class Score extends SortPluginBase {16 /**17 * {@inheritdoc}18 */19 public function query() {20 // Check to see if the search filter/argument added 'score' to the table.21 // Our filter stores it as $handler->search_score -- and we also22 // need to check its relationship to make sure that we're using the same23 // one or obviously this won't work.24 foreach (array('filter', 'argument') as $type) {25 foreach ($this->view->{$type} as $handler) {26 if (isset($handler->search_score) && $handler->relationship == $this->relationship) {27 $this->query->addOrderBy(NULL, NULL, $this->options['order'], $handler->search_score);28 $this->tableAlias = $handler->tableAlias;29 return;30 }31 }32 }33 // Do nothing if there is no filter/argument in place. There is no way34 // to sort on scores.35 }36}...
sort
Using AI Code Generation
1$score = new Score();2$score->sort();3$score = new Score();4$score->sort();5$score = new Score();6$score->sort();7$score = new Score();8$score->sort();9$score = new Score();10$score->sort();11$score = new Score();12$score->sort();13$score = new Score();14$score->sort();15$score = new Score();16$score->sort();17$score = new Score();18$score->sort();19$score = new Score();20$score->sort();21$score = new Score();22$score->sort();23$score = new Score();24$score->sort();25$score = new Score();26$score->sort();27$score = new Score();28$score->sort();29$score = new Score();30$score->sort();31$score = new Score();32$score->sort();33$score = new Score();34$score->sort();35$score = new Score();36$score->sort();
sort
Using AI Code Generation
1$score = new Score();2$score->sort();3$score = new Score();4$score->sort();5include('score.php');6$score = new Score();7$score->sort();8include('score.php');9$score = new Score();10$score->sort();
sort
Using AI Code Generation
1require_once('score.php');2$score = new Score();3$score->setScore(10);4$score->setScore(20);5$score->setScore(30);6$score->setScore(40);7$score->setScore(50);8$score->setScore(60);9$score->setScore(70);10$score->setScore(80);11$score->setScore(90);12$score->setScore(100);13$score->sort();
sort
Using AI Code Generation
1$score = new Score();2$score->readScores();3$score->sortScores();4$score->printScores();5$score = new Score();6$score->readScores();7$score->sortScores();8$score->printScores();9$score = new Score();10$score->readScores();11$score->sortScores();12$score->printScores();13$score = new Score();14$score->readScores();15$score->sortScores();16$score->printScores();17$score = new Score();18$score->readScores();19$score->sortScores();20$score->printScores();21$score = new Score();22$score->readScores();23$score->sortScores();24$score->printScores();25$score = new Score();26$score->readScores();27$score->sortScores();28$score->printScores();29$score = new Score();30$score->readScores();31$score->sortScores();32$score->printScores();33$score = new Score();34$score->readScores();35$score->sortScores();36$score->printScores();37$score = new Score();38$score->readScores();39$score->sortScores();40$score->printScores();41$score = new Score();42$score->readScores();43$score->sortScores();44$score->printScores();45$score = new Score();46$score->readScores();47$score->sortScores();48$score->printScores();49$score = new Score();
sort
Using AI Code Generation
1$score = array();2$score[] = new score(1, "A", 100);3$score[] = new score(2, "B", 90);4$score[] = new score(3, "C", 80);5$score[] = new score(4, "D", 70);6$score[] = new score(5, "E", 60);7$score[] = new score(6, "F", 50);8$score[] = new score(7, "G", 40);9$score[] = new score(8, "H", 30);10$score[] = new score(9, "I", 20);11$score[] = new score(10, "J", 10);12usort($score, array("score", "compare"));13foreach($score as $s) {14";15}
sort
Using AI Code Generation
1$score = array();2$score[] = new Score(1, 1, 1, 1);3$score[] = new Score(2, 2, 2, 2);4$score[] = new Score(3, 3, 3, 3);5usort($score, array('Score', 'sort'));6print_r($score);7$score = array();8$score[] = new Score(1, 1, 1, 1);9$score[] = new Score(2, 2, 2, 2);10$score[] = new Score(3, 3, 3, 3);11usort($score, array('Score', 'sort'));12print_r($score);13$score = array();14$score[] = new Score(1, 1, 1, 1);15$score[] = new Score(2, 2, 2, 2);16$score[] = new Score(3, 3, 3, 3);17usort($score, array('Score', 'sort'));18print_r($score);19$score = array();20$score[] = new Score(1, 1, 1, 1);21$score[] = new Score(2, 2, 2, 2);22$score[] = new Score(3, 3, 3, 3);23usort($score, array('Score', 'sort'));24print_r($score);25$score = array();26$score[] = new Score(1, 1, 1, 1);27$score[] = new Score(2, 2, 2, 2);28$score[] = new Score(3, 3, 3, 3);29usort($score, array('Score', 'sort'));30print_r($score);
sort
Using AI Code Generation
1include("score.php");2$score = array(3new score(1, "John", 100),4new score(2, "Mary", 80),5new score(3, "Peter", 50),6new score(4, "John", 90),7new score(5, "Mary", 70),8new score(6, "Peter", 40),9new score(7, "John", 80),10new score(8, "Mary", 60),11new score(9, "Peter", 30),12new score(10, "John", 70),13new score(11, "Mary", 50),14new score(12, "Peter", 20),15new score(13, "John", 60),16new score(14, "Mary", 40),17new score(15, "Peter", 10),18);19usort($score, array("score", "compare"));20foreach($score as $s)21echo $s->toString() . "22";23Related posts: PHP array_diff_uassoc() Function PHP array_diff_ukey() Function PHP array_udiff() Function PHP array_udiff_assoc() Function PHP array_udiff_uassoc() Function PHP array_uintersect() Function PHP array_uintersect_assoc() Function PHP array_uintersect_uassoc() Function PHP array_walk() Function PHP array_walk_recursive() Function
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with sort on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!