Merge branch 'develop' of https://git.minedu.gov.gr/itminedu/e-epal into sch_sso

necessary updates
parents 7159785a 05d807dd
......@@ -71,11 +71,11 @@ class ApplicationSubmit extends ControllerBase {
'epaluser_id' => $epalUser->id(),
'name' => $applicationForm[0][name],
'studentsurname' => $applicationForm[0][studentsurname],
//'birthdate' => $applicationForm[0][birthdate],
//'fatherfirstname' => $applicationForm[0][fatherfirstname],
//'fathersurname' => $applicationForm[0][fathersurname],
//'motherfirstname' => $applicationForm[0][motherfirstname],
//'mothersurname' => $applicationForm[0][mothersurname],
'birthdate' => $applicationForm[0][studentbirthdate],
'fatherfirstname' => $applicationForm[0][fatherfirstname],
'fathersurname' => $applicationForm[0][fathersurname],
'motherfirstname' => $applicationForm[0][motherfirstname],
'mothersurname' => $applicationForm[0][mothersurname],
'studentamka' => $applicationForm[0][studentamka],
'regionaddress' => $applicationForm[0][regionaddress],
'regionarea' => $applicationForm[0][regionarea],
......@@ -85,6 +85,7 @@ class ApplicationSubmit extends ControllerBase {
'currentclass' => $applicationForm[0][currentclass],
//'currentepal' => $applicationForm[0][currentepal],
//'currentsector' => $applicationForm[0][currentsector],
'points' => $applicationForm[0][points],
'relationtostudent' => $applicationForm[0][relationtostudent],
'telnum' => $applicationForm[0][telnum]
);
......
......@@ -13,11 +13,17 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
//use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\TypedData\Plugin\DataType\TimeStamp;
use Drupal\Core\Language\LanguageManagerInterface;
class Distribution extends ControllerBase {
......@@ -26,19 +32,28 @@ class Distribution extends ControllerBase {
protected $entityTypeManager;
protected $logger;
protected $connection;
protected $language;
protected $currentuser;
protected $pendingStudents = array();
protected $choice_id = 1;
protected $globalCounterId = 1;
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
QueryFactory $entity_query,
Connection $connection,
LoggerChannelFactoryInterface $loggerChannel)
{
$this->entityTypeManager = $entityTypeManager;
$this->entity_query = $entity_query;
$connection = Database::getConnection();
$this->connection = $connection;
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$this->language = $language;
$currentuser = \Drupal::currentUser()->id();
$this->currentuser = $currentuser;
$this->logger = $loggerChannel->get('epal');
}
......@@ -55,6 +70,9 @@ class Distribution extends ControllerBase {
public function createDistribution(Request $request) {
$numDistributions = 3;
$sizeOfBlock = 100000;
/*
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
......@@ -63,101 +81,113 @@ class Distribution extends ControllerBase {
}
*/
$limitUp_class = $this->retrieveCapacityLimitUp("Α");
//print_r("<br> ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ: " . $limitUp_class);
//$limitUp_classSector = $this->retrieveCapacityLimitUp("Β");
//$limitUp_classCourse = $this->retrieveCapacityLimitUp("Γ");
//clearDistributionResults();
$sizeOfBlock = 200;
$numDistributions = 3;
$transaction = $this->connection->startTransaction();
try {
//$choice_id = 1;
while ($this->choice_id <= $numDistributions) {
//initialize/empty epal_student_class if there are already data in it!
$this->connection->delete('epal_student_class')->execute();
print_r("<br>ΠΕΡΑΣΜΑ: " . $this->choice_id);
$limitUp_class = $this->retrieveCapacityLimitUp("Α");
print_r("<br> ΑΝΩΤΑΤΟ ΟΡΙΟ ΜΑΘΗΤΩΝ: " . $limitUp_class);
$epalStudents_storage = $this->entityTypeManager->getStorage('epal_student');
while ($this->choice_id <= $numDistributions) {
print_r("<br>ΠΕΡΑΣΜΑ: " . $this->choice_id);
//υπολογισμός πλήθους non-finalized αιτήσεων για να καθοριστεί ο αριθμός των fetches που θα κάνουμε με συγκεκριμένο sizeOfBlock
if ($this->choice_id === 1) {
$idsStud = $epalStudents_storage->getQuery()
->execute();
$numData = sizeof($idsStud);
print_r("<br> numData: " . $numData);
$epalStudents_storage->resetCache($idsStud);
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id'));
$numData = $sCon->countQuery()->execute()->fetchField();
print_r("<br>numData: " . $numData);
}
$j = 1;
$num = 1;
if ($this->choice_id === 1) {
while ($num <= $numData) {
print_r("<br>FETCH: " . $j);
$idsStud = $epalStudents_storage->getQuery()
->condition('id', 1+ $sizeOfBlock*($j-1), '>=')
->condition('id', $j*$sizeOfBlock, '<=')
->execute();
$epalStudents = $epalStudents_storage->loadMultiple($idsStud);
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'name', 'currentclass', 'currentepal', 'points'))
->condition('eStudent.id', 1+ $sizeOfBlock*($j-1), '>=')
->condition('eStudent.id', $j*$sizeOfBlock, '<=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$this->locateStudent($this->choice_id, $epalStudents);
$num = $num + sizeof($idsStud);
$num = $num + sizeof($epalStudents);
$j = $j + 1;
$epalStudents_storage->resetCache($idsStud);
}
}
else {
$idsStud = $epalStudents_storage->getQuery()
->condition('id', $this->pendingStudents,"IN")
->execute();
$epalStudents = $epalStudents_storage->loadMultiple($idsStud);
$this->locateStudent($this->choice_id, $epalStudents);
if (sizeof($this->pendingStudents) != 0) {
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'name', 'currentclass', 'currentepal', 'points'))
->condition('eStudent.id', $this->pendingStudents, 'IN');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
//foreach ($epalStudents as $x)
// print_r("<br> TEST:" . $x->id . " ");
$this->locateStudent($this->choice_id, $epalStudents);
}
else { //αν δεν υπάρχουν εκκρεμότητες, μην συνεχίζεις με άλλο πέρασμα
break;
}
}
//Για κάθε σχολείο βρες τα τμήματα
//Για κάθε τμήμα βρες αν χωράνε και διευθέτησε (checkCapacityAndArrange)
//checkCapacityAndArrange (school_id, class_id, sectorORcourse_id, limitUp, schoolCapacity)
$eepalSchools_storage = $this->entityTypeManager->getStorage('eepal_school');
$idsSch = $eepalSchools_storage->getQuery() //προσαρμοσμένο για τα demo data --> να αλλάξει
->condition('id', '246', '<=')
->condition('id', '147', '>=')
->execute();
$eepalSchools = $eepalSchools_storage->loadMultiple($idsSch);
$eepalSchools_storage->resetCache();
$sCon = $this->connection->select('eepal_school_field_data', 'eSchool')
->fields('eSchool', array('id', 'capacity_class_a'));
//->condition('eSchool.id', 151, '>=')
//->condition('eSchool.id', 153, '<='); //προσαρμοσμένο για τα demo data --> να αλλάξει
$eepalSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($eepalSchools as $eepalSchool) {
$this->checkCapacityAndArrange($eepalSchool->id->value, "1", "-1", $limitUp_class, $eepalSchool->capacity_class_a->value);
$this->checkCapacityAndArrange($eepalSchool->id, "1", "-1", $limitUp_class, $eepalSchool->capacity_class_a);
$eepalSectorsInEpal_storage = $this->entityTypeManager->getStorage('eepal_sectors_in_epal');
$eepalSectorsInEpal = $eepalSectorsInEpal_storage->loadByProperties(array('epal_id' => $eepalSchool->id->value) );
$sCon = $this->connection->select('eepal_sectors_in_epal_field_data', 'eSchool')
->fields('eSchool', array('epal_id', 'sector_id', 'capacity_class_sector'))
->condition('eSchool.epal_id', $eepalSchool->id, '=');
$eepalSectorsInEpal = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($eepalSectorsInEpal as $eepalSecInEp) {
//print_r("<br>Sectors " . $eepalSecInEp->sector_id->getString());
$this->checkCapacityAndArrange($eepalSchool->id->value, "2", $eepalSecInEp->sector_id->getString(), $limitUp_class, $eepalSecInEp->capacity_class_sector->value);
$this->checkCapacityAndArrange($eepalSchool->id, "2", $eepalSecInEp->sector_id, $limitUp_class, $eepalSecInEp->capacity_class_sector);
}
$eepalSpecialtiesInEpal_storage = $this->entityTypeManager->getStorage('eepal_specialties_in_epal');
$eepalSpecialtiesInEpal = $eepalSpecialtiesInEpal_storage->loadByProperties(array('epal_id' => $eepalSchool->id->value) );
$sCon = $this->connection->select('eepal_specialties_in_epal_field_data', 'eSchool')
->fields('eSchool', array('epal_id', 'specialty_id', 'capacity_class_specialty'))
->condition('eSchool.epal_id', $eepalSchool->id, '=');
$eepalSpecialtiesInEpal = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($eepalSpecialtiesInEpal as $eepalSpecialInEp) {
//print_r("<br>Specialties " . $eepalSpecialInEp->specialty_id->getString());
$this->checkCapacityAndArrange($eepalSchool->id->value, "3", $eepalSpecialInEp->specialty_id->getString(), $limitUp_class, $eepalSpecialInEp->capacity_class_specialty->value);
$this->checkCapacityAndArrange($eepalSchool->id, "3", $eepalSpecialInEp->specialty_id, $limitUp_class, $eepalSpecialInEp->capacity_class_specialty);
}
$eepalSectorsInEpal_storage->resetCache();
$eepalSpecialtiesInEpal_storage->resetCache();
} //end for each school/department
$this->choice_id++;
} //end while
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
"message" => t("An unexpected problem occured")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
return $this->respondWithStatus([
"message" => t("Distribution has made successfully")
], Response::HTTP_OK);
......@@ -169,56 +199,76 @@ class Distribution extends ControllerBase {
$epal_dist_id = -1;
$specialization_id = -1;
try {
$transaction = $this->connection->startTransaction();
$epalSchoolsChosen_storage = $this->entityTypeManager->getStorage('epal_student_epal_chosen');
$epalSectorChosen_storage = $this->entityTypeManager->getStorage('epal_student_sector_field');
$epalCourseChosen_storage = $this->entityTypeManager->getStorage('epal_student_course_field');
$epalStudentClass_storage = $this->entityTypeManager->getStorage('epal_student_class');
try {
foreach ($epalStudents as $epalStudent) {
print_r("<br>ΚΑΤΑΝΟΜΗ ΜΑΘΗΤΩΝ ΝΟ: " . $choice_id);
$epalSchoolsChosen = $epalSchoolsChosen_storage->loadByProperties(array('student_id' => $epalStudent->id->value , 'choice_no' => $choice_id) );
print_r("<br>ΜΑΘΗΤΗΣ: " . $epalStudent->id);
$clCon = $this->connection->select('epal_student_epal_chosen', 'epals')
->fields('epals', array('student_id', 'epal_id', 'choice_no'))
->condition('epals.student_id', $epalStudent->id , '=')
->condition('epals.choice_no', $choice_id , '=');
$epalSchoolsChosen = $clCon->execute()->fetchAll(\PDO::FETCH_OBJ);
if (sizeof($epalSchoolsChosen) !== 0) {
$epalSchoolChos = reset($epalSchoolsChosen);
print_r(" SCHOOL_ID:" . $epalSchoolChos->epal_id->getString() . " STUDENT_ID " . $epalStudent->id->getString());
$epal_dist_id = $epalSchoolChos->epal_id->getString();
if ($epalStudent->currentclass->value === "2") {
$epalSectorChosen = $epalSectorChosen_storage->loadByProperties(array('student_id' => $epalStudent->id->value));
print_r(" SCHOOL_ID:" . $epalSchoolChos->epal_id . " STUDENT_ID " . $epalStudent->id);
$epal_dist_id = $epalSchoolChos->epal_id;
if ($epalStudent->currentclass === "2") {
$clCon = $this->connection->select('epal_student_sector_field', 'sectors')
->fields('sectors', array('student_id', 'sectorfield_id'))
->condition('sectors.student_id', $epalStudent->id , '=');
$epalSectorChosen = $clCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalSecChos = reset($epalSectorChosen);
//print_r(" SECTOR_ID:" . $epalSecChos->sectorfield_id->getString() . " ");
}
elseif ($epalStudent->currentclass->value === "3") {
$epalCourseChosen = $epalCourseChosen_storage->loadByProperties(array('student_id' => $epalStudent->id->value));
elseif ($epalStudent->currentclass === "3") {
$clCon = $this->connection->select('epal_student_course_field', 'courses')
->fields('courses', array('student_id', 'coursefield_id'))
->condition('courses.student_id', $epalStudent->id , '=');
$epalCourseChosen = $clCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalCourChos = reset($epalCourseChosen);
//print_r(" COURSE_ID:" . $epalCourChos->coursefield_id->getString() . " ");
}
if ($epalStudent->currentclass->value === "2")
$specialization_id = $epalSecChos->sectorfield_id->getString();
elseif ($epalStudent->currentclass->value === "3")
$specialization_id = $epalCourChos->coursefield_id->getString();
if ($epalStudent->currentclass === "2")
$specialization_id = $epalSecChos->sectorfield_id;
elseif ($epalStudent->currentclass === "3")
$specialization_id = $epalCourChos->coursefield_id;
else
$specialization_id = -1;
$studentClass = array('student_id'=> $epalStudent->id->value, 'epal_id'=> $epal_dist_id, 'currentclass' => $epalStudent->currentclass->value,
'currentepal' => $epalStudent->currentepal->getString(), 'specialization_id' => $specialization_id,
'distribution_id' => $choice_id, 'points' => $epalStudent->points->value);
$studentClass_object = $epalStudentClass_storage->create($studentClass);
$epalStudentClass_storage->save($studentClass_object);
//$currentTime = \Drupal\Core\TypedData\Plugin\DataType\TimeStamp::getDateTime();
$timestamp = strtotime(date("Y-m-d"));
$this->connection->insert('epal_student_class')->fields(
array('id' => $this->globalCounterId++,
'uuid' => \Drupal::service('uuid')->generate(),
'langcode' => $this->language,
'user_id' => $this->currentuser,
'student_id'=> $epalStudent->id,
'epal_id'=> $epal_dist_id,
'currentclass' => $epalStudent->currentclass,
'currentepal' => $epalStudent->currentepal,
'specialization_id' => $specialization_id,
'points' => $epalStudent->points,
'distribution_id' => $choice_id,
'status' => 1,
'created' => $timestamp,
'changed' => $timestamp,)
)->execute();
} //end if
} //foreach
$epalSchoolsChosen_storage->resetCache();
$epalStudentClass_storage->resetCache();
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during locateStudent Method of Distribution")
], Response::HTTP_INTERNAL_SERVER_ERROR);
......@@ -232,63 +282,104 @@ class Distribution extends ControllerBase {
public function retrieveCapacityLimitUp($className) {
$epalClassLimits_storage = $this->entityTypeManager->getStorage('epal_class_limits');
$epalClassLimits = $epalClassLimits_storage->loadByProperties(array('name' => $className));
$epalClassLimit = reset($epalClassLimits);
$limit_up = $epalClassLimit->limit_up->value;
$epalClassLimits_storage->resetCache();
return $limit_up;
$transaction = $this->connection->startTransaction();
try {
$clCon = $this->connection->select('epal_class_limits', 'classLimits')
->fields('classLimits', array('limit_up'))
->condition('classLimits.name', $className, '=');
$results = $clCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$row = reset($results);
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during retrieveCapacityLimitUp Method of Distribution")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
return $row->limit_up;
}
public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup, $capacity) {
$epalStudentClass_storage = $this->entityTypeManager->getStorage('epal_student_class');
$epalStudentClass = $epalStudentClass_storage->loadByProperties(array('epal_id' => $epalId, 'currentclass' => $classId, 'specialization_id' => $secCourId ));
print_r("<br> ΣΧΟΛΕΙΟ: " . $epalId . " ΤΑΞΗ: " . $classId . " ΤΟΜΕΑΣ/ΕΙΔΙΚΟΤΗΤΑ: " . $secCourId . " ΧΩΡΗΤΙΚΟΤΗΤΑ: " . sizeof($epalStudentClass));
$limit = $limitup * $capacity;
if (sizeof($epalStudentClass) > $limit) {
print_r("<br>ΥΠΕΡΧΕΙΛΙΣΗ!");
foreach ($epalStudentClass as $epalStudCl) {
//Υπολογισμός μορίων του μαθητή και (πιθανή) αποθήκευσή τους
//$points = $this->calculatePoints();
//$epalStudCl->set('points', $points, true)->save();
$transaction = $this->connection->startTransaction();
try {
$clCon = $this->connection->select('epal_student_class', 'studentClass')
->fields('studentClass', array('epal_id', 'student_id', 'points', 'currentepal', 'currentclass', 'specialization_id'))
->condition('studentClass.epal_id', $epalId, '=')
->condition('studentClass.currentclass', $classId, '=')
->condition('studentClass.specialization_id', $secCourId, '=');
$epalStudentClass = $clCon->execute()->fetchAll(\PDO::FETCH_OBJ);
print_r("<br> ΣΧΟΛΕΙΟ: " . $epalId . " ΤΑΞΗ: " . $classId . " ΤΟΜΕΑΣ/ΕΙΔΙΚΟΤΗΤΑ: " . $secCourId . " ΧΩΡΗΤΙΚΟΤΗΤΑ: " . sizeof($epalStudentClass));
//ΕΠΙΠΛΕΟΝ ΕΠΙΠΕΔΟ ΑΣΦΑΛΕΙΑΣ: αν δεν υπάρχει ο συγκεκριμένος τομέας/ειδικότητα στο σχολείο
//ο μαθητής που τοποθετήθηκε με την locateStudent να διαγραφεί
//Σημείωση: κανονικά κάτι τέτοιο δεν μπορεί να συμβεί από το front-end (δηλ. μαθητής να δηλώσει τομέα/ειδικότητα που δεν προσφέρεται..)
//ΑΝ ΜΠΕΙ ΠΡΕΠΕΙ ΝΑ ΕΝΣΩΜΑΤΩΘΕΙ ΣΤΗΝ LOCATESTUDENT..
/*
if (sizeof($epalStudentClass) === 0) {
//print_r("<br>ΜΠΗΚΑ! ");
foreach ($epalStudentClass as $epalStudCl) {
//print_r("<br>ΜΠΗΚΑ! ΜΑΘΗΤΗΣ: " . $epalStudCl->student_id);
$query = $this->connection->delete('epal_student_class')
->condition('student_id', $epalStudCl->student_id)
->execute();
}
}
*/
//ΤΕΛΟΣ
$limit = $limitup * $capacity;
if (sizeof($epalStudentClass) > $limit) {
print_r("<br>ΥΠΕΡΧΕΙΛΙΣΗ!");
foreach ($epalStudentClass as $epalStudCl) {
//Υπολογισμός μορίων του μαθητή και (πιθανή) αποθήκευσή τους
//ΣΗΜΕΙΩΣΗ: Ο υπoλογισμός γίνεται στο front-end
//$points = $this->calculatePoints();
/*
$query = $this->connection->update('epal_student');
$query->fields([
'points' =>$points,
]);
$query->condition('id',$epalStudCl->student_id);
$query->execute();
*/
}
$this->makeSelectionOfStudents($epalStudentClass,$limit);
}
$this->makeSelectionOfStudents($epalStudentClass,$limit);
}
else { //αφαίρεσε όσους μαθητές βρίσκονται στον πίνακα εκκρεμοτήτων
foreach ($epalStudentClass as $epalStudCl) {
if ($this->choice_id !== 1)
////διέγραψε τον μαθητή από τον πίνακα εκκρεμοτήτων (αν βρίσκεται εκεί)
$this->removeFromPendingStudents($epalStudCl->student_id->getString());
else { //αφαίρεσε όσους μαθητές βρίσκονται στον πίνακα εκκρεμοτήτων
foreach ($epalStudentClass as $epalStudCl) {
if ($this->choice_id !== 1)
////διέγραψε τον μαθητή από τον πίνακα εκκρεμοτήτων (αν βρίσκεται εκεί)
$this->removeFromPendingStudents($epalStudCl->student_id);
}
}
}
$epalStudentClass_storage->resetCache();
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during checkCapacityAndArrange Method of Distribution")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
return $this->respondWithStatus([
"message" => t("checkCapacityAndArrange Method of Distribution has made successfully")
], Response::HTTP_OK);
}
public function setFinalized($student, $status ) {
//δεν χρησιμοποιείται
/*
$epalStudents_storage = $this->entityTypeManager->getStorage('epal_student');
//foreach ($studentClass as $studCl) {
$epalStudents = $epalStudents_storage->loadByProperties(array('id' => $student->student_id->getString()) );
$epalStudent = reset($epalStudents);
print_r("<br> SET FINALIZED TO:" .$status . " STUDENT_ID:" . $student->student_id->getString() );
$epalStudent->set('finalized', $status, true)->save();
*/
}
public function removeFromPendingStudents($val) {
if(($key = array_search($val, $this->pendingStudents)) !== false) {
unset($this->pendingStudents[$key]);
......@@ -303,18 +394,18 @@ class Distribution extends ControllerBase {
//αυτοδίκαια έχουν προτεραιότητα όσοι ήδη φοιτούσαν στο σχολείο
foreach($students as $student) {
$student->student_id->getString();
print_r("<br>STUDENT_ID:" . $student->student_id->getString());
$student->student_id;
print_r("<br>STUDENT_ID:" . $student->student_id);
}
//εύρεση αριθμού μαθητών που ήδη φοιτούσαν στο σχολείο
$cnt = 0;
foreach($students as $student) {
if ($student->currentepal->getString() === $student->epal_id->getString()) {
if ($student->currentepal === $student->epal_id) {
$cnt++;
if ($this->choice_id !== 1)
////διέγραψε τον μαθητή από τον πίνακα εκκρεμοτήτων (αν βρίσκεται εκεί)
$this->removeFromPendingStudents($student->student_id->getString());
$this->removeFromPendingStudents($student->student_id);
}
}
print_r("<br>#ΕΓΓΡΑΦΩΝ ΠΟΥ ΟΙ ΜΑΘΗΤΕΣ ΦΟΙΤΟΥΣΑΝ ΗΔΗ:" . $cnt);
......@@ -325,29 +416,42 @@ class Distribution extends ControllerBase {
$points_arr = [];
foreach($students as $student) {
if ($student->currentepal->getString() !== $student->epal_id->getString())
$points_arr[] = $student->points->value;
if ($student->currentepal !== $student->epal_id)
$points_arr[] = $student->points;
}
//for ($i=0; $i < sizeof($points_arr); $i++)
// print_r("<br>MORIA:" . $points_arr[$i]);
rsort($points_arr);
for ($i=0; $i < sizeof($points_arr); $i++)
print_r("<br>ΜΟΡΙΑ ΜΕΤΑ ΤΗΝ ΤΑΞΙΝΟΜΙΣΗ: " . $points_arr[$i]);
print_r("<br>ΟΡΙΟ ΜΟΡΙΩΝ: " . $points_arr[$newlimit-1]);
$transaction = $this->connection->startTransaction();
foreach($students as $student) {
if ($student->currentepal->getString() !== $student->epal_id->getString()) {
if ($student->points->value < $points_arr[$newlimit-1]) {
print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id->getString());
if ($student->currentepal !== $student->epal_id) {
if ($student->points < $points_arr[$newlimit-1]) {
print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id);
//βάλε τον μαθητή στον πίνακα εκκρεμοτήτων και διέγραψέ τον από τον προσωρινό πίνακα αποτελεσμάτων
array_push($this->pendingStudents, $student->student_id->getString() );
$student->delete();
array_push($this->pendingStudents, $student->student_id);
try {
$this->connection->delete('epal_student_class')
->condition('student_id', $student->student_id)
->execute();
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during DELETE proccess in makeSelectionOfStudents Method of Distribution")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
else {
if ($this->choice_id !== 1)
//διέγραψε τον μαθητή από τον πίνακα εκκρεμοτήτων (αν βρίσκεται εκεί)
$this->removeFromPendingStudents($student->student_id->getString());
$this->removeFromPendingStudents($student->student_id);
}
}
}
......
......@@ -12,6 +12,8 @@ dependencies:
- rest
- serialization
- user
_core:
default_config_hash: 2NbNzaqbe_smf6WW5GA6xdNaOyLrqo5IfrwynZngc0k
id: criterialist
label: criteriaList
module: views
......@@ -213,6 +215,71 @@ display:
multi_type: separator
separator: ', '
field_api_classes: false
category:
id: category
table: epal_criteria
field: category
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: epal_criteria
entity_field: category
plugin_id: field
mutual_disabled_id:
id: mutual_disabled_id
table: epal_criteria
......@@ -279,6 +346,74 @@ display:
entity_type: epal_criteria
entity_field: mutual_disabled_id
plugin_id: field
moria:
id: moria
table: epal_criteria
field: moria
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none