Merge branch 'component_updates' into 'develop'

updated Distribution Controller with second Period distribution

See merge request !180
parents 90c9f607 698e4e7b
......@@ -172,7 +172,8 @@ class Distribution extends ControllerBase {
//print_r("<br>FETCH: " . $j);
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'name', 'currentclass', 'currentepal', 'points'))
//->fields('eStudent', array('id', 'name', 'currentclass', 'currentepal', 'points'))
->fields('eStudent', array('id', 'currentclass', 'currentepal', 'second_period'))
->condition('eStudent.id', 1+ $sizeOfBlock*($j-1), '>=')
->condition('eStudent.id', $j*$sizeOfBlock, '<=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
......@@ -190,7 +191,8 @@ class Distribution extends ControllerBase {
if (sizeof($this->pendingStudents) != 0) {
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'name', 'currentclass', 'currentepal', 'points'))
//->fields('eStudent', array('id', 'name', 'currentclass', 'currentepal', 'points'))
->fields('eStudent', array('id', 'currentclass', 'currentepal', 'second_period'))
->condition('eStudent.id', $this->pendingStudents, 'IN');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
......@@ -361,6 +363,7 @@ class Distribution extends ControllerBase {
//'points' => $epalStudent->points,
'distribution_id' => $choice_id,
'finalized' => 1,
'second_period' => $epalStudent->second_period,
'status' => 1,
'created' => $timestamp,
'changed' => $timestamp,)
......@@ -580,25 +583,12 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
}
} //endif new limit
else { //$newlimit > 0
//NEW CODE LINES
if ($this->choice_id !== 1)
$this->removeFromPendingStudents($student->student_id);
}
//END NEW CODE LINES
} //endif currentepal
} //end foreach
//NEW CODE LINES
/*
else {
foreach($students as $student)
if ($student->currentepal !== $student->epal_id)
if ($this->choice_id !== 1)
$this->removeFromPendingStudents($student->student_id);
}
*/
//END NEW CODE LINES
return SUCCESS;
......@@ -702,8 +692,6 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
}
} //end if ΕΣΠΕΡΙΝΟ
} //end for each school/department
return SUCCESS;
......@@ -854,30 +842,48 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
], Response::HTTP_FORBIDDEN);
}
try {
if ( $this->initializeResultsInSecondPeriod() === ERROR_DB)
return $this->respondWithStatus([
"message" => t("Unexpected Error in initializeResultsInSecondPeriod function")
], Response::HTTP_INTERNAL_SERVER_ERROR);
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'currentclass', 'currentepal'))
->fields('eStudent', array('id', 'currentclass', 'currentepal', 'second_period'))
->condition('eStudent.second_period', 1 , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
//$this->globalCounterId = 10000;
//τοποθέτηση όλων των μαθητών Β' περιόδου στην πρώτη τους προτίμηση'
$this->globalCounterId = $this->retrieveLastStudentId() + 1;
if ($this->locateStudent(1, $epalStudents) === ERROR_DB)
return $this->respondWithStatus([
"message" => t("Unexpected Error in locateStudent function")
"message" => t("Unexpected Error in locateStudent function after calling locateSecondPeriodStudents method"),
"numOfDeletions" => $num
], Response::HTTP_INTERNAL_SERVER_ERROR);
if ($this->findSmallClasses() === ERROR_DB)
//επαναϋπολογισμός όλων των ολιγομελών τμημάτων (Προσοχή: αφορά ΟΛΟΥΣ τους μαθητές - κανονικής και Β΄ περιόδου)
//αρχικοποίηση flag finalize σε 1 για όλους
if ($this->setFinalize() === ERROR_DB)
return $this->respondWithStatus([
"message" => t("Unexpected Error in findSmallClasses function AFTER locateSecondPeriodStudents!")
"message" => t("Unexpected Error in setFinalize function AFTER locateSecondPeriodStudents!")
], Response::HTTP_INTERNAL_SERVER_ERROR);
//αν αποτύχει, δεν γίνεται rollback. --> Λύση: διαγρα΄φή των όποιων αποτελεσμάτων ;;
//εύρεση ολιγομελών και καταχώρηση μαθητών σε αυτά με κατάλληλη ένδειξη (finalize=0)
if ($this->findSmallClasses() === ERROR_DB) {
//αν αποτύχει, δεν γίνεται rollback. --> Λύση: διαγρα΄φή των όποιων αποτελεσμάτων
if ($this->initializeResultsInSecondPeriod() === ERROR_DB)
return $this->respondWithStatus([
"message" => t("Unexpected Error in initializeResults function AFTER findSmallClasses call Function")
], Response::HTTP_INTERNAL_SERVER_ERROR);
return $this->respondWithStatus([
"message" => t("Unexpected Error in findSmallClasses function AFTER locateSecondPeriodStudents!")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
......@@ -902,10 +908,45 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
}
}
private function setFinalize() {
try {
$query = $this->connection->update('epal_student_class');
$query->fields([
'finalized' => 1,
]);
$query->execute();
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return ERROR_DB;
}
return SUCCESS;
}
private function initializeResultsInSecondPeriod() {
//initialize/empty epal_student_class if there are already data in it!
try {
//$this->connection->delete('epal_student_class')->execute();
$con = $this->connection->prepare("delete from epal_student_class where second_period = 1 ");
$con->execute();
//$num = $con->rowCount();
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return ERROR_DB;
}
return SUCCESS;
}
private function retrieveLastStudentId() {
$sCon = $this->connection->select('epal_student', 'eStudent')
......
......@@ -95,19 +95,35 @@ class ReportsCreator extends ControllerBase {
], Response::HTTP_FORBIDDEN);
}
//υπολογισμός αριθμού δηλώσεων
$list = array();
//υπολογισμός αριθμού αιτήσεων
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id'));
$numApplications = $sCon->countQuery()->execute()->fetchField();
array_push($list,(object) array('name' => "Αριθμός Αιτήσεων (συνολικά)", 'numStudents' => $numApplications));
//υπολογισμός αριθμού αιτήσεων ανά τάξη
for ($i = 1; $i <= 4; $i++) {
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id'))
->condition('eStudent.currentclass', strval($i) , '=');
$numApplications = $sCon->countQuery()->execute()->fetchField();
array_push($list,(object) array('name' => "Αριθμός Αιτήσεων για " . $i . "η Τάξη", 'numStudents' => $numApplications));
}
//υπολογισμός αριθμού αιτήσεων για δεύτερη περίοδο
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id'))
->condition('eStudent.second_period', 1 , '=');
$numApplications = $sCon->countQuery()->execute()->fetchField();
array_push($list,(object) array('name' => "Αριθμός Αιτήσεων B' περιόδου", 'numStudents' => $numApplications));
//υπολογισμός αριθμού χρηστών
$sCon = $this->connection->select('epal_users', 'eUser')
->fields('eUser', array('id'));
$numUsers = $sCon->countQuery()->execute()->fetchField();
$list = array();
array_push($list,(object) array('name' => "Αριθμός Αιτήσεων", 'numStudents' => $numApplications));
array_push($list,(object) array('name' => "Αριθμός Εγγεγραμένων Χρηστών", 'numStudents' => $numUsers));
array_push($list,(object) array('name' => "Αριθμός Εγγεγραμένων Χρηστών με ρόλο Αιτούντα", 'numStudents' => $numUsers));
return $this->respondWithStatus(
......
......@@ -20,6 +20,8 @@ import { API_ENDPOINT } from '../../app.settings';
class = "loading" *ngIf="successSending == -2" >
</div>
<div style="min-height: 400px;">
<div id="emaiSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
......@@ -59,6 +61,8 @@ import { API_ENDPOINT } from '../../app.settings';
</button>
</div>
</div>
`
})
......
......@@ -27,7 +27,9 @@ import { API_ENDPOINT } from '../../app.settings';
//encapsulation: ViewEncapsulation.None,
template: `
<div>
<div style="min-height: 500px; ">
<h5> >Επιλογή Αναφοράς<br><br></h5>
......
......@@ -29,6 +29,7 @@ import { API_ENDPOINT } from '../../app.settings';
class = "loading" *ngIf=" distStatus === 'STARTED'" >
</div>
<div style="min-height: 400px;">
<div id="distributionNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
......@@ -78,7 +79,7 @@ import { API_ENDPOINT } from '../../app.settings';
<div class="col-md-6">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="runDistribution()" [disabled] = "!capacityDisabled" >
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="runDistribution()" [disabled] = "!capacityDisabled || secondPeriodEnabled" >
Εκτέλεση Κατανομής Μαθητών<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......@@ -92,6 +93,8 @@ import { API_ENDPOINT } from '../../app.settings';
</div>
</div>
`
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment