Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 205 |
ExamResultService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
2352.00 | |
0.00% |
0 / 205 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
__clone | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
checkExamResultAvailabilityForToday | |
0.00% |
0 / 1 |
132.00 | |
0.00% |
0 / 35 |
|||
getStudentExamMarkListSerialNumber | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 22 |
|||
getStudentPDCSerialNumber | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 26 |
|||
saveExamResultRestrictionToSubjects | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 45 |
|||
getExamBatchesForSubjectCategoryExamResults | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 15 |
|||
getRestrictedSubjectCategoryExamResultSubjects | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 14 |
|||
getOeExamsByRequest | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 19 |
|||
getOeExamsStudentsByRequest | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 24 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
// use com\linways\core\ams\professional\dto\Subject; | |
class ExamResultService extends BaseService | |
{ | |
// private $batchService = BatchService::getInstance(); | |
// /Condition 1 - Presence of a static member variable | |
private static $_instance = null; | |
private $mapper = []; | |
// /Condition 2 - Locked down the constructor | |
private function __construct() {} | |
// 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; | |
} | |
public function checkExamResultAvailabilityForToday ( $examType = null, $examregId = null) { | |
$examregId = $this->realEscapeString($examregId); | |
$examType = $this->realEscapeString($examType); | |
$today = date("Y-m-d"); | |
if ( $examType == 1 || $examType == null ) { | |
$condition = ''; | |
if ( $examregId ) { | |
$condition = " AND examregID = ".$examregId.""; | |
} | |
$sql = "SELECT webpublishID FROM exam_publish_website WHERE '".$today."' between publishFromDate AND publishToDate ".$condition.""; | |
try { | |
$webPublish = $this->executeQueryForObject($sql); | |
if ( !empty ( $webPublish ) ) { | |
return true; | |
} | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
if ( $examType == 2 || $examType == null ) { | |
$condition = ''; | |
if ( $examregId ) { | |
$condition = " AND id = ".$examregId.""; | |
} | |
$sql = "SELECT id FROM exam_supplementary WHERE '".$today."' between publishFromDate AND publishToDate ".$condition.""; | |
try { | |
$webPublish = $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
if ( !empty ( $webPublish ) ) { | |
return true; | |
} | |
} | |
return false; | |
} | |
public function getStudentExamMarkListSerialNumber($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$slNoExist = null; | |
if ($request->examRegId && $request->studentId) { | |
$slNoExistSql = "SELECT markListSerialNo FROM exam_reg_studentchallan WHERE examregID = '$request->examRegId' AND studentID = '$request->studentId'"; | |
$maxSlNoSql = "SELECT max(markListSerialNo) as markListSerialNo FROM exam_reg_studentchallan"; | |
try { | |
$slNoExist = $this->executeQueryForObject($slNoExistSql); | |
if($slNoExist->markListSerialNo){ | |
return $slNoExist; | |
}else{ | |
$slNo = (int)$this->executeQueryForObject($maxSlNoSql)->markListSerialNo + 1; | |
$sql = "UPDATE exam_reg_studentchallan SET markListSerialNo = '$slNo' WHERE examregID = '$request->examRegId' AND studentID = '$request->studentId'"; | |
$this->executeQueryForObject($sql); | |
$slNoExist = $this->executeQueryForObject($slNoExistSql); | |
} | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
return $slNoExist; | |
} | |
public function getStudentPDCSerialNumber($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$slNoExist = null; | |
$request->createdBy = $_SESSION['adminID']; | |
if ($request->studentId) { | |
$slNoExistSql = "SELECT serialNumber FROM studentProvisionalCertificateDetails WHERE studentId = '$request->studentId'"; | |
$maxSlNoSql = "SELECT max(serialNumber) as serialNumber FROM studentProvisionalCertificateDetails"; | |
try { | |
$slNoExist = $this->executeQueryForObject($slNoExistSql); | |
if ($slNoExist->serialNumber) { | |
return $slNoExist; | |
} else { | |
$slNo = (int)$this->executeQueryForObject($maxSlNoSql)->serialNumber + 1; | |
if ($request->startingFrom) { | |
$slNo = ($slNo > $request->startingFrom) ? $slNo : $request->startingFrom; | |
} | |
$sql = "INSERT INTO studentProvisionalCertificateDetails(studentId,serialNumber,created_by) VALUES ($request->studentId,$slNo,$request->createdBy)"; | |
$this->executeQueryForObject($sql); | |
$slNoExist = $this->executeQueryForObject($slNoExistSql); | |
} | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
return $slNoExist; | |
} | |
/** | |
* @param $request | |
* @throws ProfessionalException | |
*/ | |
public function saveExamResultRestrictionToSubjects($request) | |
{ | |
$sql1 = ""; | |
$request = $this->realEscapeObject($request); | |
$examregId = $request->examregId; | |
$examTypeId = $request->examTypeId; | |
$batchId = $request->batchId; | |
$semId = $request->semId; | |
$subjectDetails = $request->subjectDetails; | |
if ($subjectDetails) { | |
$subjectDetails = json_encode($subjectDetails); | |
} else { | |
$subjectDetails = "[]"; | |
} | |
$user = $_SESSION['adminID']; | |
$examregId = $request->examregId ? $request->examregId : NULL; | |
$examTypeVar = "examregID"; | |
$sql = " SELECT * from restricted_subject_category_exam_result WHERE examTypeID = '$examTypeId' and $examTypeVar = '$examregId' and batchID= '$batchId' and semID = '$semId'"; | |
$result = $this->executeQueryForList($sql); | |
if ($result) { | |
$sql1 = " UPDATE restricted_subject_category_exam_result | |
SET subjectDetails= '$subjectDetails', | |
updated_by = '$user' | |
WHERE examTypeID = '$examTypeId' | |
and $examTypeVar = '$examregId' | |
and batchID= '$batchId' | |
and semID = '$semId'"; | |
} else { | |
$sql1 = " INSERT into restricted_subject_category_exam_result(batchID,examTypeID,semID, $examTypeVar, subjectDetails, created_by) | |
VALUES ('$batchId', | |
'$examTypeId', | |
'$semId', | |
'$examregId', | |
'$subjectDetails', | |
'$user')"; | |
} | |
if ($sql1) { | |
try { | |
return $this->executeQuery($sql1); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} else { | |
return null; | |
} | |
} | |
/** | |
* @param $request | |
* @throws ProfessionalException | |
*/ | |
public function getExamBatchesForSubjectCategoryExamResults($request) | |
{ | |
$condition = ""; | |
$request = $this->realEscapeObject($request); | |
$sql1 = "SELECT DISTINCT bt.batchName, ex.batchID, ex.examregID,rsc.subjectDetails | |
FROM exam ex | |
inner join batches bt on(bt.batchID = ex.batchID) | |
left join restricted_subject_category_exam_result rsc on (ex.examregID = rsc.examregID and ex.batchID=rsc.batchID and ex.semID = rsc.semID and ex.examTypeID = rsc.examTypeID) | |
where ex.examTypeID = '$request->examTypeId' AND ex.semID = '$request->semId' AND bt.batchStartYear ='$request->batchYear' AND bt.courseTypeID= '$request->courseTypeId' order by bt.batchName"; | |
try { | |
$result = $this->executeQueryForList($sql1); | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* @param $request | |
* @throws ProfessionalException | |
*/ | |
public function getRestrictedSubjectCategoryExamResultSubjects($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$result = ""; | |
try { | |
if ($request->examRegId && $request->batchId && $request->semId) { | |
$sql = "SELECT subjectDetails from restricted_subject_category_exam_result | |
WHERE examregID = '$request->examRegId' AND batchID = '$request->batchId' AND semID = '$request->semId'"; | |
$result = $this->executeQueryForObject($sql); | |
} | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* @param $request | |
* @throws ProfessionalException | |
*/ | |
public function getOeExamsByRequest($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$result = []; | |
$examRegField = "examRegId"; | |
if($request->isSupply){ | |
$examRegField = "supplyExamRegId"; | |
} | |
try { | |
if ($request->examRegId && $request->subjectId) { | |
$sql = "SELECT oe.id from oe_exams oe | |
WHERE JSON_CONTAINS(oe.identifying_context, '{\"$examRegField\":\"$request->examRegId\",\"subjectId\":\"$request->subjectId\"}') | |
AND type ='EXAM_CONTROLLER' AND (oe.properties ->> '$.isMockExam' != 'true' OR oe.properties ->> '$.isMockExam' is null)"; | |
$result = $this->executeQueryForList($sql); | |
} | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* @param $request | |
* @throws ProfessionalException | |
*/ | |
public function getOeExamsStudentsByRequest($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$condition = ""; | |
$result = []; | |
$oeExamIdString = "'" . implode("','", $request->oeExamIds) . "'" ; | |
if($request->studentId){ | |
$condition .= " AND oec.oe_users_id IN ($request->studentId)"; | |
} | |
try { | |
if ($request->oeExamIds) { | |
$sql = "SELECT oec.oe_users_id as studentId,sa.regNo,sa.studentName,efn.false_number as falseNumber,efn.alpha_numeric_code as alphaNumericCode,oec.oe_exams_id as oeExamId,oe.identifying_context->>\"$.examId\" AS examId from oe_exam_marks_confirm oec | |
INNER JOIN oe_exams oe On oe.id = oec.oe_exams_id | |
INNER JOIN studentaccount sa ON sa.studentID = oec.oe_users_id | |
LEFT JOIN examcontroller_false_number efn ON efn.examID = oe.identifying_context->>\"$.examId\" AND efn.studentID = oec.oe_users_id | |
where oec.oe_exams_id in($oeExamIdString) | |
$condition | |
group by oec.oe_users_id order by oec.oe_exams_id,sa.regNo"; | |
$result = $this->executeQueryForList($sql); | |
} | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
} | |
?> |