Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 138 |
EndSemesterExamOnlineService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
272.00 | |
0.00% |
0 / 138 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
getStudentExamRegistrations | |
0.00% |
0 / 1 |
182.00 | |
0.00% |
0 / 95 |
|||
setRedirectStudentToOnlineExamDetails | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 41 |
<?php | |
namespace com\linways\ec\core\service; | |
use com\linways\base\util\MakeSingletonTrait; | |
use com\linways\ec\core\exception\ExamControllerException; | |
use com\linways\core\ams\professional\service\CommonService; | |
use com\linways\ec\core\service\CommonExamService; | |
use com\linways\ec\core\mapper\EndSemesterExamOnlineServiceMapper; | |
class EndSemesterExamOnlineService extends BaseService | |
{ | |
use MakeSingletonTrait; | |
private function __construct() { | |
$this->mapper = EndSemesterExamOnlineServiceMapper::getInstance()->getMapper(); | |
} | |
/** | |
* get Student Exam Registrations | |
* @param $searchRequest | |
* @throws ExamControllerException | |
*/ | |
public function getStudentExamRegistrations($searchRequest){ | |
$searchRequest = $this->realEscapeObject($searchRequest); | |
try{ | |
$orderBy = " ORDER BY eer.name, vas.code "; | |
$whereQuery = ""; | |
if(!empty($searchRequest->studentId)) { | |
$whereQuery .= " AND s.studentID = '".$searchRequest->studentId."'"; | |
} else if($GLOBALS['userType'] == 'STUDENT') { | |
$whereQuery .= " AND s.studentID = '".$GLOBALS['userId']."'"; | |
} | |
if(!empty($searchRequest->examRegistrationId)) { | |
$examRegistrationIdString = is_array($searchRequest->examRegistrationId) ? "'" . implode("','",$searchRequest->examRegistrationId) . "'" : "'".$searchRequest->examRegistrationId."'"; | |
$whereQuery .= " AND eer.id IN ( $examRegistrationIdString )"; | |
} | |
if(!empty($searchRequest->examRegistrationType)) { | |
$examRegistrationTypeString = is_array($searchRequest->examRegistrationType) ? "'" . implode("','",$searchRequest->examRegistrationType) . "'" : "'".$searchRequest->examRegistrationType."'"; | |
$whereQuery .= " AND eer.type IN ( $examRegistrationTypeString )"; | |
} else { | |
$whereQuery .= " AND eer.type IN ('REGULAR','SUPPLEMENTARY')"; | |
} | |
$query = " SELECT | |
eer.id AS examRegistrationId, | |
eer.name AS examRegistrationName, | |
eer.type AS examRegistrationType, | |
eerb.properties->>'$.academicTermId' AS academicTermId, | |
vas.id AS subjectId, | |
vas.code AS subjectCode, | |
vas.name AS subjectName, | |
s.studentName, | |
spa.properties->>'$.rollNumber' AS rollNo, | |
spa.properties->>'$.registerNumber' AS regNo, | |
oe.assessment_id AS assessmentId, | |
oe.properties AS examProperties | |
FROM | |
ec_exam_registration eer | |
INNER JOIN ec_exam_registration_batch eerb On | |
eerb.ec_exam_registration_id = eer.id | |
INNER JOIN ec_exam_registration_subject eers On | |
eers.ec_exam_registration_batch_id = eerb.id | |
INNER JOIN ec_student_assessment_registration esar On | |
esar.am_assessment_id = eers.am_assessment_id | |
INNER JOIN cm_academic_paper_subjects caps On | |
caps.id = eers.cm_academic_paper_subjects_id | |
INNER JOIN v4_ams_subject vas On | |
vas.id = caps.ams_subject_id | |
INNER JOIN studentaccount s ON | |
s.studentID = esar.student_id | |
INNER JOIN student_program_account spa ON | |
spa.student_id = s.studentID | |
INNER JOIN oe_exams oe ON | |
oe.assessment_id = eers.am_assessment_id | |
AND oe.is_deleted = 0 | |
WHERE | |
spa.academic_status IN ('ACTIVE','COMPLETED') | |
AND eer.trashed IS NULL | |
AND eer.properties->>'$.publish' = '1' | |
AND (eer.properties ->> '$.isSpecialExam' != '1' OR eer.properties ->> '$.isSpecialExam' IS NULL ) | |
AND esar.properties->>'$.registrationStatus' = 'REGISTERED' | |
AND oe.type = 'EXAM_CONTROLLER' | |
AND oe.identifying_context->>'$.type' = 'ONLINE_EXAM' | |
"; | |
$studentExamRegistrations = $this->executeQueryForList($query.$whereQuery.$orderBy, $this->mapper[EndSemesterExamOnlineServiceMapper::GET_STUDENT_EXAM_REGISTRATIONS]); | |
$currentTime = time(); | |
foreach ($studentExamRegistrations as $examRegistration) { | |
$examRegistration->isExpand = false; | |
foreach ($examRegistration->subjects as $subject) { | |
$examProperties = $subject->examProperties; | |
$examStartTime = strtotime($examProperties->startTime); | |
$examEndTime = strtotime($examProperties->endTime); | |
if ($currentTime < $examStartTime) { | |
$subject->examStatus = 'UPCOMING'; | |
unset($subject->examProperties); | |
unset($subject->assessmentId); | |
} else if ($currentTime >= $examStartTime && $currentTime < $examEndTime) { | |
$subject->examStatus = 'ONGOING'; | |
} else { | |
$subject->examStatus = 'FINISHED'; | |
unset($subject->examProperties); | |
unset($subject->assessmentId); | |
} | |
$subject->examDate = date("d-m-Y", $examStartTime); | |
$subject->examStartTime = date("h:i A", $examStartTime); | |
$subject->examEndTime = date("h:i A", $examEndTime); | |
unset($examProperties); | |
unset($examStartTime); | |
unset($examEndTime); | |
} | |
} | |
} catch(\Exception $e) { | |
throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
} | |
$result = new \stdClass(); | |
$result->examRegCount = count($studentExamRegistrations); | |
$result->examRegistrations = $studentExamRegistrations; | |
return $result; | |
} | |
/** | |
* set Redirect Student To Online Exam Details | |
* @param $searchRequest | |
* @throws ExamControllerException | |
*/ | |
public function setRedirectStudentToOnlineExamDetails($searchRequest){ | |
$searchRequest = $this->realEscapeObject($searchRequest); | |
try{ | |
$_SESSION['oe_userId'] = $GLOBALS['userId']; | |
$_SESSION['oe_userName'] = 'Student Name'; | |
$_SESSION['EXAM_CONTROLLER_USER_TYPE'] = $GLOBALS['userType']; | |
$_SESSION['oe_userType'] = $GLOBALS['userType']; | |
$s3Folder = CommonService::getInstance()->getSettings("ONLINE_EXAM", "ATTACHMENT_FOLDER"); | |
$s3BucketName = getenv('S3_BUCKET_NAME'); | |
$awsAccessKey = getenv('AWS_ACCESS_KEY'); | |
$s3MaxFileSize = getenv('S3_MAX_FILE_SIZE'); | |
$signRequestEndpoint = "https://" . $_SERVER['SERVER_NAME'] . "/libcommon/s3/endpoint-cors.php"; | |
$collegeCode = $GLOBALS['COLLEGE_CODE']; | |
$context = [ | |
's3' => [ | |
'bucketName' => $s3BucketName, | |
'awsAccessKey' => $awsAccessKey, | |
'maxFileSize' => $s3MaxFileSize, | |
'folder' => $s3Folder, | |
'signRequestEndpoint' => $signRequestEndpoint | |
], | |
'collegeCode' => $collegeCode | |
]; | |
$identifyingContext = new \stdClass(); | |
$identifyingContext->userId = $_SESSION['oe_userId']; | |
$identifyingContext->assessmentId = $searchRequest->assessmentId; | |
$oeData = new \stdClass(); | |
$oeData->context = $context; | |
$oeData->identifyingContext = $identifyingContext; | |
$oeData->type = 'EXAM_CONTROLLER'; | |
$oeData->userType = 'STUDENT'; | |
$oeData->userName = $_SESSION['oe_userName']; | |
$oeData->backLink = ""; | |
$result = new \stdClass(); | |
$result->context = $context; | |
$result->identifyingContext = $identifyingContext; | |
$result->oeData = $oeData; | |
return $result; | |
} catch(\Exception $e) { | |
throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
} | |
} | |
} |