Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 28 |
CRAP | |
0.00% |
0 / 890 |
ExternalAssessmentService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 28 |
32942.00 | |
0.00% |
0 / 890 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
addExternalAssessment | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
updateExternalAssessment | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
deleteExternalAssessment | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
getExternalAssessment | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
addExternalAssessmentStudent | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 15 |
|||
deleteExternalAssessmentStudentByAssessmentId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
getExternalAssessmentStudentByAssessmentId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getExternalAssessmentStudentByAssessmentIdList | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
validateAndSaveImportAndValidationStatus | |
0.00% |
0 / 1 |
240.00 | |
0.00% |
0 / 79 |
|||
getImportAndValidationStatus | |
0.00% |
0 / 1 |
156.00 | |
0.00% |
0 / 65 |
|||
getValidationStatus | |
0.00% |
0 / 1 |
342.00 | |
0.00% |
0 / 69 |
|||
upsertExternalComponentValidateImportStatus | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 21 |
|||
updateImportingConfig | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 23 |
|||
validateAndImportExternalComponet | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 42 |
|||
saveStudentExamMarkAndLog | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 17 |
|||
calculateSubjectMarkOfStudent | |
0.00% |
0 / 1 |
1056.00 | |
0.00% |
0 / 121 |
|||
calculateInnerRule | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 13 |
|||
getAssignmentMark | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 22 |
|||
getStudentExternalMarks | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 18 |
|||
updateImportingStatus | |
0.00% |
0 / 1 |
342.00 | |
0.00% |
0 / 64 |
|||
importExternalComponet | |
0.00% |
0 / 1 |
240.00 | |
0.00% |
0 / 77 |
|||
getAssignmentsOfBatch | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 25 |
|||
getExternalAssignments | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 34 |
|||
getStatusData | |
0.00% |
0 / 1 |
132.00 | |
0.00% |
0 / 86 |
|||
getImportAndValidateStatusData | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 32 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\base\util\SecurityUtils; | |
use com\linways\core\ams\professional\queue\AMSTaskQueue; | |
use com\linways\core\ams\professional\service\BaseService; | |
use com\linways\core\ams\professional\service\MarkService; | |
use com\linways\core\ams\professional\service\StaffService; | |
use com\linways\core\ams\professional\service\StudentService; | |
use com\linways\core\ams\professional\dto\ExternalAssessment; | |
use com\linways\core\ams\professional\constant\StatusConstants; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\mapper\ExternalAssessmentServiceMapper; | |
use com\linways\core\ams\professional\constant\examcontroller\CourseTypeConstants; | |
use com\linways\core\ams\professional\dto\examcontroller\exam\StudentExternalComponentImportLog; | |
class ExternalAssessmentService extends BaseService | |
{ | |
// /Condition 1 - Presence of a static member variable | |
private static $_instance = null; | |
// /Condition 2 - Locked down the constructor | |
private function __construct() | |
{ | |
$this->mapper = ExternalAssessmentServiceMapper::getInstance()->getMapper(); | |
} | |
// Prevent any oustide instantiation of this class | |
// /Condition 3 - Prevent any object or instance of that class to be cloned | |
private function __clone() | |
{} | |
// Prevent any copy of this object | |
// /Condition 4 - Have a single globally accessible static method | |
public static function getInstance() | |
{ | |
if (! is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
self::$_instance = new self(); | |
return self::$_instance; | |
} | |
/** | |
* add external assessment | |
* @param ExternalAssessment $extrnalAssessment | |
* @throws ProfessionalException | |
*/ | |
public function addExternalAssessment(ExternalAssessment $externalAssessment) | |
{ | |
$externalAssessment = $this->realEscapeObject($externalAssessment); | |
$sql="INSERT INTO external_assessment (title, date, maxMark, subject, createdBy, createdDate, updatedBy, updatedDate) VALUES ('$externalAssessment->title', '$externalAssessment->date', '$externalAssessment->maxMark', '$externalAssessment->subject', '$externalAssessment->createdBy', utc_timestamp(), '$externalAssessment->updatedBy', utc_timestamp())"; | |
try { | |
$this->executeQuery($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* update external assessment | |
* @param ExternalAssessment $externalAssessment | |
* @throws ProfessionalException | |
*/ | |
public function updateExternalAssessment(ExternalAssessment $externalAssessment) | |
{ | |
$externalAssessment = $this->realEscapeObject($externalAssessment); | |
$sql="UPDATE external_assessment SET title='$externalAssessment->title', date='$externalAssessment->date', maxMark='$externalAssessment->maxMark', subject='$externalAssessment->subject', updatedBy='$externalAssessment->updatedBy', updatedDate=utc_timestamp() WHERE id=$externalAssessment->id"; | |
try { | |
$this->executeQuery($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* delete external assessment by id | |
* @param int $id | |
* @throws ProfessionalException | |
*/ | |
public function deleteExternalAssessment($id) | |
{ | |
$id = $this->realEscapeString($id); | |
$sql="DELETE FROM external_assessment WHERE id=$id"; | |
try { | |
$this->executeQuery($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* get all external assessment | |
* @throws ProfessionalException | |
* @return object|array|\com\linways\base\util\$objectList[] | |
*/ | |
public function getExternalAssessment() | |
{ | |
$sql="SELECT * FROM external_assessment"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function addExternalAssessmentStudent($externalAssessmentStudentList) | |
{ | |
$externalAssessmentStudentList = $this->realEscapeArray($externalAssessmentStudentList); | |
$sql="INSERT INTO `external_assessment_student` (`external_assessment_id`, `studentId`, `markObtained`, `percentage`, `createdBy`, `createdDate`, `updatedBy`, `updatedDate`) VALUES "; | |
$values=[]; | |
foreach ($externalAssessmentStudentList as $assessment) | |
{ | |
$values[]="($assessment->external_assessment_id, $assessment->studentId, $assessment->markObtained, $assessment->percentage, $assessment->createdBy, utc_timestamp(), $assessment->updatedBy, utc_timestamp())"; | |
} | |
$sql .=implode(', ', $values); | |
try { | |
$this->executeQuery($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function deleteExternalAssessmentStudentByAssessmentId($assessmentId){ | |
$sql ="DELETE from external_assessment_student where external_assessment_id=$assessmentId"; | |
try { | |
return $this->executeQuery($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function getExternalAssessmentStudentByAssessmentId($assessmentId) | |
{ | |
$sql ="select sa.studentID, sa.studentName, sa.admissionNo, sa.studentPhone, sa.parentPhone, eas.markObtained as mark, eas.percentage, eas.isSmsSend, ea.title, ea.maxMark, ea.subject from external_assessment_student eas inner join external_assessment ea ON ea.id=eas.external_assessment_id INNER JOIN studentaccount sa On sa.studentID=eas.studentId where eas.external_assessment_id=$assessmentId"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function getExternalAssessmentStudentByAssessmentIdList($assessmentIdList) | |
{ | |
$sql ="select sa.studentID, sa.studentName, sa.admissionNo, sa.studentPhone, sa.parentPhone, eas.markObtained as mark, eas.percentage, eas.isSmsSend, ea.title, ea.maxMark, eas.external_assessment_id, ea.subject from external_assessment_student eas inner join external_assessment ea ON ea.id=eas.external_assessment_id INNER JOIN studentaccount sa On sa.studentID=eas.studentId where eas.external_assessment_id in (".implode(', ', $assessmentIdList).") order by sa.studentID, eas.external_assessment_id"; | |
try { | |
return $this->executeQueryForList($sql,$this->mapper[ExternalAssessmentServiceMapper::GET_EXTERNAL_ASSESSMENT_MARKS]); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* get import status of external components. | |
* | |
* @param ImportExternalComponentRequest $importRequest | |
* @throws ProfessionalException | |
* @return boolean | |
* @author anoop | |
*/ | |
public function validateAndSaveImportAndValidationStatus($importRequest) { | |
try { | |
$subjects = $this->getStatusData($importRequest); | |
$changedStatus = []; | |
global $COLLEGE_CODE; | |
// subject validation status | |
foreach ($subjects as $subject) { | |
$subject->code = $COLLEGE_CODE == "SJCC" ? $subject->syllabusCode : $subject->subjectCode; | |
$isStatusChanged = false; | |
$subject->validationStatus = json_decode($subject->validationStatus); | |
$subject->importStatus = json_decode($subject->importStatus); | |
$subject->importConfig = json_decode($subject->importConfig); | |
if (empty($subject->validationStatus) || (!empty($subject->validationStatus) && $subject->validationStatus->isDirty)) { | |
if ($subject->excludeSubjectFromTotal) { | |
$subject->validationStatus->isValid = true; | |
$subject->validationStatus->reasons = ["Validated"]; | |
$subject->validationStatus->isDirty = false; | |
} | |
else { | |
$subject->validationStatus = $this->getValidationStatus($subject); | |
$subject->validationStatus->isDirty = false; | |
} | |
$isStatusChanged = true; | |
} | |
else{ | |
$subject->validationStatus = $this->getValidationStatus($subject); | |
$isStatusChanged = true; | |
} | |
if ($subject->importStatus->status == StatusConstants::READY) { | |
$subject->importStatus->status = "NOT IMPORTED"; | |
} | |
if (empty($subject->importStatus)) { | |
$subject->importStatus->status = "NOT IMPORTED"; | |
$subject->importStatus->reasons = []; | |
$subject->importStatus->isFailedStatus = true; | |
if ($subject->validationStatus->isValid) { | |
$subject->importStatus->status = StatusConstants::READY; | |
$subject->importStatus->isFailedStatus = false; | |
} | |
$isStatusChanged = true; | |
} | |
else if ($subject->importStatus->isDirty) { | |
if ($subject->validationStatus->isValid) { | |
$subject->importStatus->status = StatusConstants::READY; | |
$subject->importStatus->isFailedStatus = false; | |
}else { | |
$subject->importStatus->status = "RE IMPORT"; | |
$subject->importStatus->reasons = ["Changes dectected"]; | |
$subject->importStatus->isFailedStatus = true; | |
} | |
$isStatusChanged = true; | |
} | |
if ($isStatusChanged) { | |
$changedStatusObj = null; | |
$changedStatusObj->batchId = $subject->batchId; | |
$changedStatusObj->semId = $subject->semId; | |
$changedStatusObj->subjectId = $subject->subjectId; | |
$changedStatusObj->validationStatus = json_encode($subject->validationStatus); | |
$changedStatusObj->importStatus = json_encode($subject->importStatus); | |
$changedStatusObj->staffId = $importRequest->staffId; | |
$changedStatus[] = clone $changedStatusObj; | |
} | |
$subject->validationStatusFailed = !$subject->validationStatus->isValid; | |
$subject->importStatusFailed = $subject->importStatus->isFailedStatus; | |
$subject->importStatusValue = $subject->importStatus->status; | |
$batches[$subject->batchId]->subjects[$subject->subjectId] = $subject; | |
$batches[$subject->batchId]->semId = $subject->semId; | |
$batches[$subject->batchId]->batchId = $subject->batchId; | |
$batches[$subject->batchId]->batchName = $subject->batchName; | |
$batches[$subject->batchId]->batchDesc = $subject->batchDesc; | |
} | |
if (!empty($changedStatus)) { | |
$this->upsertExternalComponentValidateImportStatus($changedStatus); | |
} | |
$batches = $this->getImportAndValidationStatus($importRequest); | |
return $batches; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* get import status of external components. | |
* | |
* @param ImportExternalComponentRequest $importRequest | |
* @throws ProfessionalException | |
* @return boolean | |
* @author anoop | |
*/ | |
public function getImportAndValidationStatus($importRequest) { | |
try{ | |
$subjects = $this->getStatusData($importRequest); | |
$changedStatus = []; | |
global $COLLEGE_CODE; | |
// subject validation status | |
foreach ($subjects as $subject) { | |
$subject->code = $COLLEGE_CODE == "SJCC" ? $subject->syllabusCode : $subject->subjectCode; | |
$subject->validationStatus = json_decode($subject->validationStatus); | |
$subject->importStatus = json_decode($subject->importStatus); | |
$subject->importConfig = json_decode($subject->importConfig); | |
if (empty($subject->validationStatus)) { | |
if ($subject->excludeSubjectFromTotal) { | |
$subject->validationStatus->isValid = true; | |
$subject->validationStatus->reasons = ["Validated"]; | |
$subject->validationStatus->isDirty = false; | |
} | |
else { | |
$subject->validationStatus->isValid = false; | |
$subject->validationStatus->reasons = ["Not validated"]; | |
$subject->validationStatus->isDirty = false; | |
} | |
} | |
else if ($subject->validationStatus->isDirty) { | |
$subject->validationStatus->isValid = false; | |
$subject->validationStatus->reasons = ["Not validated"]; | |
} | |
if (empty($subject->importStatus)) { | |
$subject->importStatus->status = "NOT IMPORTED"; | |
$subject->importStatus->reasons = []; | |
$subject->importStatus->isFailedStatus = true; | |
if ($subject->validationStatus->isValid) { | |
$subject->importStatus->status = StatusConstants::READY; | |
$subject->importStatus->isFailedStatus = false; | |
} | |
} | |
else if ($subject->importStatus->isDirty) { | |
if ($subject->validationStatus->isValid) { | |
$subject->importStatus->status = StatusConstants::READY; | |
$subject->importStatus->isFailedStatus = false; | |
}else { | |
$subject->importStatus->status = "RE IMPORT"; | |
$subject->importStatus->reasons = ["Changes dectected"]; | |
$subject->importStatus->isFailedStatus = true; | |
} | |
} | |
if (!empty($subject->importStatus->failedStudents)) { | |
$studentsFailed = StudentService::getInstance()->getStudentDetailsByIds($subject->importStatus->failedStudents); | |
$regNoString = implode(", ", array_column($studentsFailed, "regNo")); | |
$subject->importStatus->reasons[] = "Mark not entered for students $regNoString"; | |
$subject->importStatus->isFailedStatus = true; | |
} | |
$subject->validationStatusFailed = !$subject->validationStatus->isValid; | |
$subject->importStatusFailed = $subject->importStatus->isFailedStatus; | |
$subject->importStatusValue = $subject->importStatus->status; | |
$batches[$subject->batchId]->subjects[$subject->subjectId] = $subject; | |
$batches[$subject->batchId]->semId = $subject->semId; | |
$batches[$subject->batchId]->batchId = $subject->batchId; | |
$batches[$subject->batchId]->batchName = $subject->batchName; | |
$batches[$subject->batchId]->batchDesc = $subject->batchDesc; | |
} | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $batches; | |
} | |
private function getValidationStatus($subject){ | |
try { | |
$batchId = $subject->batchId; | |
$semId = $subject->semId; | |
$subjectId = $subject->subjectId; | |
$assignmentIds = $subject->importConfig->{"ASSIGNMENT"}->assignmentIds; | |
$markList = []; | |
$assignmentIdString = is_array($assignmentIds) ? implode(",", $assignmentIds) : $assignmentIds; | |
if ($batchId && $semId && $subjectId && $assignmentIdString) { | |
$sql = "SELECT | |
ba.assignmentID AS assignmentId, | |
COUNT(am.markID) AS studentCount, | |
ba.question, | |
CONCAT(s.subjectName,' assignment-',ba.assiNu) AS assignmentName, | |
ba.description | |
FROM | |
batch_assignment ba | |
INNER JOIN subjects s ON | |
s.subjectID = ba.subjectID | |
LEFT JOIN assignment_marks am ON | |
ba.assignmentID = am.assignmentID | |
WHERE | |
ba.batchID = $batchId | |
AND ba.semID = $semId | |
AND ba.subjectID = $subjectId | |
AND ba.assignmentID IN($assignmentIdString) | |
GROUP BY ba.assignmentID"; | |
$markList = $this->executeQueryForList($sql); | |
} | |
if($subject->examId){ | |
$isUg = $subject->courseType == CourseTypeConstants::UG ? true : false; | |
if ($isUg) { | |
$sql = "SELECT ee.mark as externalMark FROM exammarks_external ee WHERE ee.examID = $subject->examId"; | |
} | |
else{ | |
$sql = "SELECT ee.mark as externalMark FROM externalexammarks_finalized ee WHERE ee.examID = $subject->examId"; | |
} | |
$externalMarkDetails = $this->executeQueryForList($sql); | |
} | |
$validationStatus->isValid = true; | |
if (empty($markList) || !reset($markList)->studentCount) { | |
$validationStatus->isValid = false; | |
$validationStatus->reasons = ["Assignment not Defined"]; | |
} | |
else{ | |
foreach ($markList as $markObj) { | |
if ($markObj->studentCount < 1) { | |
$validationStatus->isValid = false; | |
$markNotEnteredAssignments[] = $markObj->assignmentName; | |
} | |
} | |
$validationStatus->reasons = !empty($markNotEnteredAssignments) ? ["Assignment mark not Enetered for ".implode(",",$markNotEnteredAssignments)] : []; | |
} | |
if (empty($subject->examId)) { | |
$validationStatus->isValid = false; | |
$validationStatus->reasons[] = "Exam not defined"; | |
} | |
else if (count($externalMarkDetails) < 1) { | |
$validationStatus->isValid = false; | |
$validationStatus->reasons[] = "Exam mark not entered for $subject->examName"; | |
} | |
if ($validationStatus->isValid) { | |
$validationStatus->reasons = ["Validated"]; | |
} | |
return $validationStatus; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* insert or update external component validation and import status | |
* | |
* @param Array $changedStatus | |
* @return void | |
*/ | |
private function upsertExternalComponentValidateImportStatus($changedStatus){ | |
$values = []; | |
$valueString = ""; | |
foreach ($changedStatus as $subject) { | |
$id = SecurityUtils::getRandomString(); | |
$values[] = "('$id',$subject->semId,$subject->batchId,$subject->subjectId,'$subject->validationStatus','$subject->importStatus',$subject->staffId)"; | |
} | |
$valueString = implode(",", $values); | |
try { | |
$sql = "INSERT INTO | |
ec_external_component_import (id, sem_id, batch_id, subject_id, validation_status, import_status, created_by) | |
VALUES $valueString | |
ON DUPLICATE KEY UPDATE | |
updated_by = VALUES(created_by), | |
validation_status = VALUES(validation_status), | |
import_status = VALUES(import_status)"; | |
$this->executeQuery($sql); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function updateImportingConfig($subjects, $request){ | |
$subjects = $this->realEscapeArray($subjects); | |
$request = $this->realEscapeObject($request); | |
$values = []; | |
$valueString = ""; | |
foreach ($subjects as $subject) { | |
$id = SecurityUtils::getRandomString(); | |
$subject->importConfig = json_encode($subject->importConfig); | |
$values[] = "('$id',$request->semId,$request->batchId,$subject->subjectId,'$subject->importConfig',$request->staffId)"; | |
} | |
$valueString = implode(",", $values); | |
try { | |
$sql = "INSERT INTO | |
ec_external_component_import (id, sem_id, batch_id, subject_id, import_config, created_by) | |
VALUES $valueString | |
ON DUPLICATE KEY UPDATE | |
updated_by = VALUES(created_by), | |
import_config = VALUES(import_config)"; | |
$this->executeQuery($sql); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function validateAndImportExternalComponet($request){ | |
$request = $this->realEscapeObject($request); | |
$validatedBatch = reset(ExternalAssessmentService::getInstance()->validateAndSaveImportAndValidationStatus($request)); | |
try { | |
$taskQueRequest = new \stdClass(); | |
$taskQueRequest->request = $request; | |
$taskQueRequest->validatedBatch = $validatedBatch; | |
// $taskQueRequest->exams = $exams; | |
foreach ($validatedBatch->subjects as $subjectId => $subject) { | |
if ($subject->importStatus->status == StatusConstants::PROCESSING) { | |
continue; | |
} | |
$importStatus = "NOT IMPORTED"; | |
try { | |
if (!$subject->validationStatus->isValid) { | |
$this->updateImportingStatus($subject, $request, $importStatus, 0, 0, true); | |
continue; | |
} | |
$this->updateImportingStatus($subject, $request, $importStatus, 0, 0, true); | |
$studentDetails = StudentService::getInstance()->getStudentDetailsByBatchSemIdAndSubbatchId($request->batchId,$request->semId,($subject->subBatchId?$subject->subBatchId:0),'rollNo'); | |
$studentChunks = array_chunk($studentDetails, 20, true); | |
foreach ($studentChunks as $students) { | |
$taskQueRequest->studentDetails = $students; | |
$taskQueRequest->totalStudents = count($studentDetails); | |
$taskQueRequest->totalChunks = count($studentChunks); | |
$taskQueRequest->subject = $subject; | |
$importStatus = StatusConstants::PROCESSING; | |
$taskQueue = new AMSTaskQueue(); | |
$params = ['className' => 'com\linways\core\ams\professional\service\ExternalAssessmentService', | |
'methodName' => 'importExternalComponet', | |
'methodParams' => [$taskQueRequest]]; | |
$taskQueue->enqueue('EXECUTE SERVICE', $params); | |
} | |
} | |
catch(\Exception $e) { | |
$importStatus = StatusConstants::FAILED; | |
} | |
$this->updateImportingStatus($subject, $request, $importStatus); | |
} | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Update or add new exam mark | |
* | |
*/ | |
public function saveStudentExamMarkAndLog($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
try { | |
$sql = "INSERT INTO externalexammarks_finalized (examID, studentID, mark) VALUES ('$request->examId','$request->studentId',$request->mark) ON DUPLICATE KEY UPDATE mark = VALUES(mark)"; | |
$this->executeQuery($sql); | |
$sql = "INSERT INTO exammarks_external (examID, studentID, mark, adminID) VALUES ('$request->examId','$request->studentId',$request->mark,'$request->staffId') ON DUPLICATE KEY UPDATE mark = VALUES(mark)"; | |
$this->executeQuery($sql); | |
$id = SecurityUtils::getRandomString(); | |
$log = json_encode($request->log); | |
$sql = "INSERT INTO ec_student_mark_edit_log (id,exam_id,student_id,log,created_by,created_date) | |
VALUES ('$id',$request->examId,'$request->studentId','[$log]','$request->staffId',now()) ON DUPLICATE KEY UPDATE `log` = JSON_MERGE(`log`,'$log'), updated_by = VALUES(created_by)"; | |
$this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return true; | |
} | |
private function calculateSubjectMarkOfStudent($subject, $batchId, $semId, $studentId) | |
{ | |
$subject = $this->realEscapeObject($subject); | |
$batchId = $this->realEscapeString($batchId); | |
$semId = $this->realEscapeString($semId); | |
$studentId = $this->realEscapeString($studentId); | |
$examId = $subject->examId; | |
$markDetails = null; | |
try { | |
foreach ($subject->importConfig as $code => $config) { | |
if ($code == "ASSIGNMENT") { | |
if ($subject->excludeSubjectFromTotal) { | |
$markDetails->assignmentObtainedMark = $config->mark; | |
$markDetails->markObtained["ASSIGNMENT"] = $config->mark; | |
$markDetails->maxMark["ASSIGNMENT"] = $config->mark; | |
$markDetails->assignmentIds = []; | |
} | |
else { | |
$assignmentMarks = $this->getAssignmentMark ($batchId, $semId, $subject->subjectId, $studentId); | |
foreach ($assignmentMarks as $mark) { | |
if (!empty($config->innerRule)) { | |
$innerRuleArrayKey = $config->innerRule->{$mark->assignmentId}; | |
if (!empty($innerRuleArrayKey)) { | |
$innerRule = $config->innerRule->{$mark->assignmentId}; | |
if ($innerRule->operator == "FRACTION") { | |
if ($mark->maxMark) { | |
$markDetails->assignmentMark[$mark->assignmentId]->markObtained = ($mark->assignmentMark / $mark->maxMark) * $config->mark; | |
} | |
else{ | |
$markDetails->assignmentMark[$mark->assignmentId]->markObtained = 0; | |
} | |
} | |
else if ($innerRule->operator == "SUM") { | |
$markDetails->assignmentMark[$mark->assignmentId]->markObtained = $mark->assignmentMark ? $mark->assignmentMark : 0; | |
$markDetails->assignmentMark[$mark->assignmentId]->maxMark = $mark->maxMark; | |
} | |
else{ | |
$markDetails->assignmentMark[$mark->assignmentId]->markObtained = 0; | |
} | |
} | |
} | |
else{ | |
$markDetails->assignmentMark[$mark->assignmentId]->markObtained = $mark->assignmentMark ? $mark->assignmentMark : 0; | |
$markDetails->assignmentMark[$mark->assignmentId]->maxMark = $mark->maxMark; | |
} | |
} | |
if ($config->operator == "FRACTION") { | |
$markDetails->assignmentIds = array_keys($markDetails->assignmentMark); | |
$markDetails->assignmentObtainedMark = array_sum(array_column($markDetails->assignmentMark, "markObtained")); | |
$markDetails->maxMark["ASSIGNMENT"] = array_sum(array_column($markDetails->assignmentMark, "maxMark")); | |
$markDetails->markObtained["ASSIGNMENT"] = $markDetails->maxMark["ASSIGNMENT"] ? (($markDetails->assignmentObtainedMark / $markDetails->maxMark["ASSIGNMENT"]) * $config->mark) : 0; | |
} | |
else if ($config->operator == "SUM") { | |
$markDetails->assignmentIds = array_keys($markDetails->assignmentMark); | |
$markDetails->assignmentObtainedMark = array_sum(array_column($markDetails->assignmentMark, "markObtained")); | |
$markDetails->markObtained["ASSIGNMENT"] = array_sum(array_column($markDetails->assignmentMark, "markObtained")); | |
$markDetails->maxMark["ASSIGNMENT"] = array_sum(array_column($markDetails->assignmentMark, "maxMark")); | |
} | |
} | |
} | |
if ($code == "EXTERNAL_EXAM") { | |
$isUg = $subject->courseType == CourseTypeConstants::UG ? true : false; | |
$externalMarkDetails = $this->getStudentExternalMarks($subject->examId,$studentId,$isUg); | |
if ($externalMarkDetails->externalMark === null) { | |
// return null if external mark not entered. | |
return null; | |
} | |
$externalMarkDetailsLogRequest->examId = $subject->examId; | |
$externalMarkDetailsLogRequest->studentId = $studentId; | |
$externalMarkDetailsLogs = json_decode(MarkService::getInstance()->getStudentExamMarkEditLog($externalMarkDetailsLogRequest)->log); | |
$externalMarkDetailsLog = reset(array_filter($externalMarkDetailsLogs, function ($log) | |
{ | |
if ($log->markType == "IMPORTED_MARK" && $log->oldMark === $log->externalExamMark) { | |
if($log->oldMark && $log->externalExamMark) return true; | |
else if($log->oldMark === 0 && $log->externalExamMark === 0) return true; | |
else return false; | |
} | |
else return false; | |
})); | |
$externalMarkDetails->externalMark = $externalMarkDetails->externalMark !== null ? $externalMarkDetails->externalMark : null; | |
$studentMarkDetails->oldMark = $externalMarkDetails->externalMark; | |
if (!empty($externalMarkDetailsLog)) { | |
// set changed external mark from log if log has external exam mark | |
$externalMarkDetails->externalMark = $externalMarkDetailsLog->externalExamMark; | |
} | |
if ($subject->excludeSubjectFromTotal) { | |
$markDetails->maxMark["EXTERNAL_EXAM"] = $config->mark; | |
$markDetails->markObtained["EXTERNAL_EXAM"] = $config->mark; | |
$markDetails->externalExamMark = $externalMarkDetails->externalMark; | |
} | |
else { | |
if ($config->operator == "FRACTION") { | |
$markDetails->externalExamMark = $externalMarkDetails->externalMark; | |
$markDetails->maxMark["EXTERNAL_EXAM"] = $subject->examTotalMarks; | |
$markDetails->markObtained["EXTERNAL_EXAM"] = $subject->examTotalMarks ? (($externalMarkDetails->externalMark / $subject->examTotalMarks) * $config->mark) : 0; | |
} | |
else if ($config->operator == "SUM") { | |
$markDetails->externalExamMark = $externalMarkDetails->externalMark; | |
$markDetails->maxMark["EXTERNAL_EXAM"] = $config->mark; | |
$markDetails->markObtained["EXTERNAL_EXAM"] = $externalMarkDetails->externalMark; | |
} | |
} | |
} | |
} | |
$studentMarkDetails->markObtained = round(array_sum($markDetails->markObtained), 2); | |
$studentMarkDetails->externalExamMark = $markDetails->externalExamMark !== null ? $markDetails->externalExamMark : ""; | |
$studentMarkDetails->assignmentObtainedMark = $markDetails->assignmentObtainedMark; | |
$studentMarkDetails->assignmentIds = $markDetails->assignmentIds; | |
unset($semId); | |
unset($config); | |
unset($batchId); | |
unset($subject); | |
unset($studentId); | |
unset($innerRule); | |
unset($markDetails); | |
unset($assignmentMarks); | |
unset($innerRuleArrayKey); | |
unset($externalMarkDetails); | |
unset($externalMarkDetailsLog); | |
unset($externalMarkDetailsLogRequest); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $studentMarkDetails; | |
} | |
private function calculateInnerRule($operator, $values){ | |
if ($operator == "FRACTION") { | |
if ($values->val2) { | |
// (val1 obatainedMark / val2 totalMaxMark) * val3 convertMaxMark | |
return ($values->val1 / $values->val2) * $values->val3; | |
} | |
else{ | |
return 0; | |
} | |
} | |
elseif ($operator == "SUM") { | |
return $values->val1 ? $values->val1 : 0; | |
} | |
return 0; | |
} | |
private function getAssignmentMark($batchId, $semId, $subjectId, $studentId){ | |
try { | |
$sql = "SELECT | |
ba.assignmentID AS assignmentId, | |
am.studentID AS studentId, | |
am.marksObtained AS assignmentMark, | |
ba.max_mark AS maxMark | |
FROM | |
batch_assignment ba | |
LEFT JOIN assignment_marks am ON | |
ba.assignmentID = am.assignmentID | |
WHERE | |
ba.batchID = $batchId | |
AND ba.semID = $semId | |
AND am.studentID = $studentId | |
AND ba.subjectID = $subjectId"; | |
$markList = $this->executeQueryForList($sql); | |
return $markList; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
private function getStudentExternalMarks($examId,$studentId,$isUg) | |
{ | |
$sql = ''; | |
$examId = $this->realEscapeString($examId); | |
$studentId = $this->realEscapeString($studentId); | |
$studentExternalMarkDetails = null; | |
try { | |
if ($isUg) { | |
$sql = "SELECT ee.mark as externalMark FROM exammarks_external ee WHERE ee.examID = $examId AND ee.studentID = $studentId"; | |
} | |
else{ | |
$sql = "SELECT ee.mark as externalMark FROM externalexammarks_finalized ee WHERE ee.examID = $examId AND ee.studentID = $studentId"; | |
} | |
$studentExternalMarkDetails = $this->executeQueryForObject($sql); | |
}catch( \ Exception $e){ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $studentExternalMarkDetails; | |
} | |
public function updateImportingStatus($subject, $request, $importStatus, $importedStudentCount = null, $processedChucks = null, $isReset = false){ | |
$subject = $this->realEscapeObject($subject); | |
$request = $this->realEscapeObject($request); | |
$importStatus = $this->realEscapeString($importStatus); | |
$importedStudentCount = $importedStudentCount === null ? null : $this->realEscapeString($importedStudentCount); | |
$processedChucks = $processedChucks === null ? null : $this->realEscapeString($processedChucks); | |
if ($importedStudentCount !== null) { | |
$importStatusObj->studentCount = $importedStudentCount; | |
} | |
else { | |
$currentImportStatus = $this->getImportAndValidateStatusData($request->batchId,$request->semId,$subject->subjectId); | |
$importStatusObj->studentCount = $currentImportStatus->importStatus->studentCount ? $currentImportStatus->importStatus->studentCount : 0; | |
} | |
if ($processedChucks !== null) { | |
$importStatusObj->processedChucks = $processedChucks; | |
} | |
else { | |
$currentImportStatus = $currentImportStatus ? $currentImportStatus : $this->getImportAndValidateStatusData($request->batchId,$request->semId,$subject->subjectId); | |
$importStatusObj->processedChucks = $currentImportStatus->importStatus->processedChucks ? $currentImportStatus->importStatus->processedChucks : 0; | |
} | |
if (!empty($subject->failedStudents)) { | |
$importStatusObj->failedStudents = array_values($subject->failedStudents); | |
} | |
else { | |
$currentImportStatus = $currentImportStatus ? $currentImportStatus : $this->getImportAndValidateStatusData($request->batchId,$request->semId,$subject->subjectId); | |
$importStatusObj->failedStudents = !empty($currentImportStatus->importStatus->failedStudents) ? $currentImportStatus->importStatus->failedStudents : []; | |
} | |
if($isReset){ | |
$importStatusObj->failedStudents = []; | |
} | |
if (StatusConstants::FAILED == $importStatus){ | |
$importStatusObj->status = StatusConstants::FAILED; | |
$importStatusObj->isFailedStatus = true; | |
} | |
if (StatusConstants::SUCCESS == $importStatus){ | |
$importStatusObj->status = StatusConstants::SUCCESS; | |
$importStatusObj->isFailedStatus = false; | |
} | |
if (StatusConstants::PARTIALLY_COMPLETED == $importStatus){ | |
$importStatusObj->status = StatusConstants::PARTIALLY_COMPLETED; | |
$importStatusObj->isFailedStatus = false; | |
} | |
if (StatusConstants::PROCESSING == $importStatus){ | |
$importStatusObj->status = StatusConstants::PROCESSING; | |
$importStatusObj->isFailedStatus = false; | |
} | |
if ("NOT IMPORTED" == $importStatus){ | |
$importStatusObj->status = "NOT IMPORTED"; | |
$importStatusObj->isFailedStatus = true; | |
} | |
$id = SecurityUtils::getRandomString(); | |
$subject->importStatus = json_encode($importStatusObj); | |
try { | |
$sql = "INSERT INTO | |
ec_external_component_import (id, sem_id, batch_id, subject_id, import_status, created_by) | |
VALUES ('$id',$request->semId,$request->batchId,$subject->subjectId,'$subject->importStatus',$request->staffId) | |
ON DUPLICATE KEY UPDATE | |
updated_by = VALUES(created_by), | |
import_status = VALUES(import_status)"; | |
$this->executeQuery($sql); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException("STATUS_UPDATE_ERROR",$e->getMessage()); | |
} | |
} | |
public function importExternalComponet($taskQueRequest){ | |
try { | |
$request = $taskQueRequest->request; | |
$validatedBatch = $taskQueRequest->validatedBatch; | |
// $exams = $taskQueRequest->exams; | |
$studentDetails = $taskQueRequest->studentDetails; | |
$subject = $taskQueRequest->subject; | |
// $examsArrayKey = array_search($subject->subjectId, array_column($exams, 'subjectId')); | |
// $subject->examId = $exams[$examsArrayKey]->examId; | |
$isUg = $subject->courseType == CourseTypeConstants::UG ? true : false; | |
$importStatus = StatusConstants::PROCESSING; | |
$currentImportStatus = $this->getImportAndValidateStatusData($request->batchId,$request->semId,$subject->subjectId); | |
$processedStudentCount = $currentImportStatus->importStatus->studentCount ? $currentImportStatus->importStatus->studentCount : 0; | |
$processedChucks = $currentImportStatus->importStatus->processedChucks ? $currentImportStatus->importStatus->processedChucks : 0; | |
$failedStudents = $currentImportStatus->importStatus->failedStudents ? $currentImportStatus->importStatus->failedStudents : []; | |
foreach ($studentDetails as $student) { | |
echo PHP_EOL . "========================Importing======================" . PHP_EOL ; | |
echo "Batch: $request->batchId ||| Subject:$subject->subjectId ||| Student:$student->studentID"; | |
echo PHP_EOL . "=======================================================" . PHP_EOL ; | |
$student->studentId = $student->studentID; | |
$studentCalculatedMark = $this->calculateSubjectMarkOfStudent($subject, $request->batchId, $request->semId, $student->studentId); | |
if (empty($studentCalculatedMark)) { | |
$failedStudents[$student->studentId] = $student->studentId; | |
continue; | |
} | |
$logRequest = new \stdClass(); | |
$logRequest->subjectId = $subject->subjectId; | |
$logRequest->examId = $subject->examId; | |
$logRequest->mark = $studentCalculatedMark->markObtained; | |
$logRequest->studentId = $student->studentId; | |
$logRequest->staffId = $request->staffId; | |
$log = new StudentExternalComponentImportLog(); | |
$log->newMark = $studentCalculatedMark->markObtained; | |
$log->oldMark = $studentCalculatedMark->oldMark; | |
$log->externalExamMark = $studentCalculatedMark->externalExamMark; | |
$log->assignmentMark = $studentCalculatedMark->assignmentObtainedMark; | |
$log->assignmentIds = $studentCalculatedMark->assignmentIds; | |
$log->remarks = "Mark obtained from external components"; | |
$log->markType = "IMPORTED_MARK"; | |
$log->actionTakenTime = date("d-m-Y h:m A"); | |
$log->updatedStaffId = $request->staffId; | |
$log->updatedStaffType = $request->staffType; | |
$logRequest->log = $log; | |
$this->saveStudentExamMarkAndLog ( $logRequest ); | |
$importStatus = StatusConstants::PARTIALLY_COMPLETED; | |
$processedStudentCount++; | |
} | |
// unset($studentCalculatedMark); | |
// unset($logRequest); | |
// unset($log); | |
$processedChucks++; | |
if ($taskQueRequest->totalStudents == $processedStudentCount) { | |
$importStatus = StatusConstants::SUCCESS; | |
} | |
else{ | |
if ($taskQueRequest->totalChunks == $processedChucks) { | |
$importStatus = $processedStudentCount ? StatusConstants::PARTIALLY_COMPLETED : StatusConstants::FAILED; | |
} | |
else { | |
$importStatus = StatusConstants::PROCESSING; | |
} | |
} | |
$subject->failedStudents = $failedStudents; | |
$this->updateImportingStatus($subject, $request, $importStatus, $processedStudentCount, $processedChucks); | |
} | |
catch(\Exception $e) { | |
if ($e->getCode() != "STATUS_UPDATE_ERROR") { | |
$processedChucks++; | |
} | |
if ($taskQueRequest->totalStudents == $processedStudentCount) { | |
$importStatus = StatusConstants::SUCCESS; | |
} | |
else{ | |
if ($taskQueRequest->totalChunks == $processedChucks) { | |
$importStatus = $processedStudentCount ? StatusConstants::PARTIALLY_COMPLETED : StatusConstants::FAILED; | |
} | |
else { | |
$importStatus = StatusConstants::PROCESSING; | |
} | |
} | |
$subject->failedStudents = $failedStudents; | |
$this->updateImportingStatus($subject, $request, $importStatus, $processedStudentCount, $processedChucks); | |
} | |
// unset($subject); | |
// unset($request); | |
// unset($importStatus); | |
// unset($validatedBatch); | |
// unset($studentDetails); | |
// unset($taskQueRequest); | |
} | |
public function getAssignmentsOfBatch($batchId, $semId){ | |
try { | |
$sql = "SELECT | |
ba.assignmentID AS id, | |
ba.assiNu AS assiNu, | |
CONCAT(s.subjectName,' assignment-',ba.assiNu) AS name, | |
ba.max_mark AS maxMark, | |
s.subjectID AS subjectId, | |
s.subjectName, | |
s.subjectDesc, | |
s.syllabusName | |
FROM | |
batch_assignment ba | |
INNER JOIN subjects s ON | |
s.subjectID = ba.subjectID | |
WHERE | |
ba.batchID = $batchId | |
AND ba.semID = $semId | |
AND externalAssiNu <> 0"; | |
$assignments = $this->executeQueryForList($sql); | |
return $assignments; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function getExternalAssignments($request){ | |
$request = $this->realEscapeObject($request); | |
$condition = ""; | |
if (!empty($request->batchId)) { | |
$batchIdString = is_array($request->batchId) ? implode(",",$request->batchId) : $request->batchId; | |
$condition .= " AND ba.batchID IN ($batchIdString) "; | |
} | |
if (!empty($request->semId)) { | |
$semIdString = is_array($request->semId) ? implode(",",$request->semId) : $request->semId; | |
$condition .= " AND ba.semID IN ($semIdString) "; | |
} | |
try { | |
$sql = "SELECT | |
ba.assignmentID AS id, | |
ba.assiNu AS assiNu, | |
CONCAT(s.subjectName,' assignment-',ba.assiNu) AS name, | |
ba.max_mark AS maxMark, | |
s.subjectID AS subjectId, | |
s.subjectName, | |
s.subjectDesc, | |
s.syllabusName | |
FROM | |
batch_assignment ba | |
INNER JOIN subjects s ON | |
s.subjectID = ba.subjectID | |
WHERE | |
externalAssiNu <> 0 | |
$condition"; | |
$assignments = $this->executeQueryForList($sql); | |
return $assignments; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
private function getStatusData($importRequest){ | |
$importRequest = $this->realEscapeObject($importRequest); | |
$sql =""; | |
$sqlCondition =""; | |
try { | |
if (empty($importRequest->batchId) || empty($importRequest->semId) || empty($importRequest->staffId)) { | |
throw new ProfessionalException(ProfessionalException::INVALID_PARAMETER,"Invalid request given for getiing status!"); | |
} | |
if ($importRequest->subjectId) { | |
$subjectIdString = is_array($importRequest->subjectId) ? implode(",",$importRequest->subjectId) : $importRequest->subjectId; | |
$sqlCondition .= " AND s.subjectID IN ($subjectIdString)"; | |
} | |
if ($importRequest->examRegId) { | |
$examRegIdString = is_array($importRequest->examRegId) ? implode(",",$importRequest->examRegId) : $importRequest->examRegId; | |
$sqlCondition .= " AND erb.examregID IN ($examRegIdString)"; | |
} | |
$batchIdString = is_array($importRequest->batchId) ? implode(",",$importRequest->batchId) : $importRequest->batchId; | |
$semIdString = is_array($importRequest->semId) ? implode(",",$importRequest->semId) : $importRequest->semId; | |
$sql = "SELECT DISTINCT | |
s.subjectID AS subjectId, | |
s.subjectName AS subjectCode, | |
s.syllabusName AS syllabusCode, | |
s.subjectDesc AS subjectName, | |
b.batchID AS batchId, | |
b.batchName, | |
b.batchDesc, | |
sbsr.semID AS semId, | |
eci.validation_status AS validationStatus, | |
eci.import_status AS importStatus, | |
eci.import_config AS importConfig, | |
esc.excludeSubjectFromTotal, | |
ct.course_Type AS courseType, | |
e.examID AS examId, | |
e.examTotalMarks, | |
e.examName, | |
e.examregID, | |
ssbs.subbatchID AS subBatchId | |
FROM | |
subjects s | |
INNER JOIN sbs_relation sbsr ON | |
sbsr.subjectID = s.subjectID | |
INNER JOIN batches b ON | |
b.batchID = sbsr.batchID | |
INNER JOIN exam_subjectcredit esc ON | |
esc.subjectID = s.subjectID | |
AND esc.subjectID = sbsr.subjectID | |
AND esc.semID = sbsr.semID | |
AND esc.batchID = b.batchID | |
AND esc.batchID = sbsr.batchID | |
INNER JOIN course_type ct ON | |
ct.courseTypeID = b.courseTypeID | |
INNER JOIN exam_registration_batches erb ON | |
b.batchID = erb.batchID | |
AND esc.batchID = erb.batchID | |
AND sbsr.batchID = erb.batchID | |
AND sbsr.semID = erb.semID | |
AND esc.semID = erb.semID | |
LEFT JOIN exam e ON | |
e.subjectID = s.subjectID | |
AND e.subjectID = sbsr.subjectID | |
AND e.subjectID = esc.subjectID | |
AND e.semID = sbsr.semID | |
AND e.semID = esc.semID | |
AND e.semID = erb.semID | |
AND e.batchID = b.batchID | |
AND e.batchID = sbsr.batchID | |
AND e.batchID = esc.batchID | |
AND e.batchID = erb.batchID | |
AND e.examregID = erb.examregID | |
LEFT JOIN ec_external_component_import eci ON | |
eci.subject_id = s.subjectID | |
AND eci.batch_id = b.batchID | |
AND eci.batch_id = sbsr.batchID | |
AND eci.sem_id = sbsr.semID | |
LEFT JOIN subbatch_sbs ssbs ON | |
ssbs.sbsID = sbsr.sbsID | |
WHERE | |
sbsr.batchID IN ($batchIdString) | |
AND sbsr.semID IN ($semIdString) | |
$sqlCondition"; | |
$subjects = $this->executeQueryForList($sql); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $subjects; | |
} | |
private function getImportAndValidateStatusData($batchId, $semId, $subjectId){ | |
$batchId = $this->realEscapeString($batchId); | |
$semId = $this->realEscapeString($semId); | |
$subjectId = $this->realEscapeString($subjectId); | |
$sql =""; | |
try { | |
if (empty($batchId) || empty($semId) || empty($subjectId)) { | |
throw new ProfessionalException(ProfessionalException::INVALID_PARAMETER,"Invalid request given for getiing status!"); | |
} | |
$sql = "SELECT | |
id, | |
sem_id AS semId, | |
batch_id AS batchId, | |
subject_id AS subjectId, | |
import_config AS importConfig, | |
validation_status AS validationStatus, | |
import_status AS importStatus | |
FROM | |
ec_external_component_import | |
WHERE | |
sem_id = $semId | |
AND batch_id = $batchId | |
AND subject_id = $subjectId"; | |
$statusDetails = $this->executeQueryForObject($sql); | |
$statusDetails->importConfig = json_decode($statusDetails->importConfig); | |
$statusDetails->validationStatus = json_decode($statusDetails->validationStatus); | |
$statusDetails->importStatus = json_decode($statusDetails->importStatus); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $statusDetails; | |
} | |
} | |