Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 196 |
ProjectThesisService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
1560.00 | |
0.00% |
0 / 196 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
getStudentsForProjectThesis | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 27 |
|||
getAllStudentDetailsByProjectThesis | |
0.00% |
0 / 1 |
506.00 | |
0.00% |
0 / 97 |
|||
getStudentAppliedDetails | |
0.00% |
0 / 1 |
132.00 | |
0.00% |
0 / 69 |
<?php | |
namespace com\linways\ec\core\service; | |
use com\linways\base\util\MakeSingletonTrait; | |
use com\linways\base\util\SecurityUtils; | |
use com\linways\ec\core\constant\StatusConstants; | |
use com\linways\ec\core\exception\ExamControllerException; | |
use com\linways\ec\core\dto\FeeType; | |
use com\linways\ec\core\logging\Events; | |
use com\linways\ec\core\logging\entities\Staff; | |
use com\linways\core\ams\professional\logging\AMSLogger; | |
use com\linways\ec\core\service\CommonExamService; | |
use com\linways\base\util\TwigRenderer; | |
use com\linways\core\ams\professional\util\PdfUtil; | |
use com\linways\core\ams\professional\service\StaffService; | |
use com\linways\core\ams\professional\request\api\GetAllFacultiesRequest; | |
use com\linways\ec\core\request\SearchRuleRequest; | |
use com\linways\ec\core\service\RuleService; | |
class ProjectThesisService extends BaseService | |
{ | |
use MakeSingletonTrait; | |
private function __construct() | |
{ | |
$this->logger = AMSLogger::getLogger('exam-controller-log'); | |
} | |
/** | |
* search All Student Details TA | |
* @param $request | |
* @return studentDetails | |
*/ | |
public function getStudentsForProjectThesis($request){ | |
try{ | |
$responseData = new \stdClass; | |
$studentDetails = $this->getAllStudentDetailsByProjectThesis($request); | |
$studentDetails = (array)$studentDetails; | |
if($request->isReportUploadedStudentsOnly){ | |
$students = []; | |
foreach($studentDetails as $student){ | |
$requestForCertificate = new \stdClass(); | |
$requestForCertificate->groupId = $student->groupId; | |
$requestForCertificate->studentId = $student->studentId; | |
$requestForCertificate->type = 'PROJECT_THESIS'; | |
$student->uploadedCertificates = CertificateUploadService::getInstance()->getCertificateUpload($requestForCertificate); | |
if(!empty($student->uploadedCertificates)){ | |
$students[] = $student; | |
} | |
} | |
$responseData->students = $students; | |
} | |
else{ | |
$responseData->students = $studentDetails; | |
} | |
return $responseData; | |
} | |
catch(\Exception $e) { | |
throw new ExamControllerException ($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* get All Student Details By ExamRegistration | |
* @param $request | |
* @return studentDetails | |
*/ | |
public function getAllStudentDetailsByProjectThesis($request){ | |
$request = $this->realEscapeObject($request); | |
try{ | |
$searchRuleRequest = new SearchRuleRequest; | |
$searchRuleRequest->name = "PROJECT_THESIS"; | |
$ruleObj = reset(RuleService::getInstance()->searchRule($searchRuleRequest))->rule; | |
if(!empty ($ruleObj->applicableCourseTypeIds)){ | |
$request->courseTypeId = $ruleObj->applicableCourseTypeIds; | |
} | |
$whereQuery = ""; | |
$limitQuery = ""; | |
$joinQueary = ""; | |
$sortBy = " ORDER BY spa.properties->>'$.registerNumber' ASC "; | |
if(($request->isFetchAppliedStudentsOnly)){ | |
$joinQueary .= " INNER JOIN ec_student_additional_details esad ON | |
esad.student_id = sa.studentID AND esad.program_id = p.id AND esad.type = 'PROJECT_THESIS' "; | |
} | |
else{ | |
$joinQueary .= " LEFT JOIN ec_student_additional_details esad ON | |
esad.student_id = sa.studentID AND esad.program_id = p.id AND esad.type = 'PROJECT_THESIS' "; | |
} | |
if(!empty($request->studentId)){ | |
$whereQuery .= " AND sa.studentID = '$request->studentId'"; | |
} | |
if(!empty($request->guideId)){ | |
$whereQuery .= " AND esad.properties->>'$.guideId' = '$request->guideId'"; | |
} | |
if(!empty($request->verificationStatus)){ | |
$whereQuery .= " AND esad.properties->>'$.verificationStatus' = '$request->verificationStatus'"; | |
} | |
if(!empty($request->registerNo)){ | |
$whereQuery .= " AND spa.properties->>'$.registerNumber' = '$request->registerNo'"; | |
} | |
if(!empty($request->groupId)){ | |
$groupIdString = is_array($request->groupId) ? "'" . implode("','",$request->groupId) . "'" : "'".$request->groupId."'"; | |
$whereQuery .= " AND g.id IN ( $groupIdString )"; | |
} | |
if(!empty($request->courseTypeId)){ | |
$courseTypeIdString = is_array($request->courseTypeId) ? "'" . implode("','",$request->courseTypeId) . "'" : "'".$request->courseTypeId."'"; | |
$whereQuery .= " AND p.course_type_id IN ( $courseTypeIdString )"; | |
} | |
$query = "SELECT DISTINCT | |
sa.studentID as studentId, | |
sa.studentName as name, | |
sa.studentEmail as email, | |
sa.studentPhone as phone, | |
spa.properties->>'$.registerNumber' AS registerNo, | |
p.id AS programId, | |
g.id AS groupId, | |
g.name AS groupName, | |
d.deptName as deptCode, | |
d.departmentDesc as deptName, | |
esad.properties as projectThesisProperties | |
FROM | |
`groups` g | |
INNER JOIN group_members gm ON | |
gm.groups_id = g.id | |
INNER JOIN program p ON | |
p.id = g.properties->>'$.programId' | |
INNER JOIN student_program_account spa ON | |
spa.id = gm.members->>'$.studentId' AND | |
spa.current_program_id = p.id AND | |
spa.current_batch_id = g.id AND | |
spa.properties->>'$.academicStatus' IN ('ACTIVE','COMPLETED') | |
INNER JOIN studentaccount sa ON | |
sa.studentID = spa.student_id | |
INNER JOIN department d ON | |
d.deptID = g.properties ->> '$.departmentId' | |
$joinQueary | |
WHERE | |
g.`type` = 'BATCH' "; | |
$studentDetails = $this->executeQueryForList($query.$whereQuery.$sortBy.$limitQuery); | |
} | |
catch(\Exception $e) { | |
throw new ExamControllerException ($e->getCode(),$e->getMessage()); | |
} | |
array_walk($studentDetails,function($student){ | |
$student->isSelected = false; | |
$student->guide = ""; | |
$student->verificationStartDate = ""; | |
$student->verificationEndDate = ""; | |
$student->projectThesisProperties = $student->projectThesisProperties ? json_decode($student->projectThesisProperties) : new \stdClass; | |
if($student->projectThesisProperties){ | |
$student->verificationStartDate = $student->projectThesisProperties->verificationStartDate ? date("Y-m-d", strtotime($student->projectThesisProperties->verificationStartDate)) : ''; | |
$student->verificationEndDate = $student->projectThesisProperties->verificationEndDate ? date("Y-m-d", strtotime($student->projectThesisProperties->verificationEndDate)) : ''; | |
$student->verificationEndDate = $student->projectThesisProperties->verificationEndDate ? date("Y-m-d", strtotime($student->projectThesisProperties->verificationEndDate)) : ''; | |
$student->guide = $student->projectThesisProperties->guideId ? $student->projectThesisProperties->guideId : ''; | |
$student->vivaFaculty = $student->projectThesisProperties->vivaFacultyId ? $student->projectThesisProperties->vivaFacultyId : []; | |
$student->verificationStatus = $student->projectThesisProperties->verificationStatus ? $student->projectThesisProperties->verificationStatus : ''; | |
if( $student->guide){ | |
$getAllFacultiesRequest = new GetAllFacultiesRequest; | |
$getAllFacultiesRequest->id = $student->guide; | |
$currentStaffDetails = reset(StaffService::getInstance()->getAllFacultiesForApi($getAllFacultiesRequest)); | |
} | |
$student->guideName = $currentStaffDetails ? $currentStaffDetails->name : ''; | |
} | |
}); | |
return $studentDetails; | |
} | |
/** | |
* search All Student applied Details PT | |
* @param $request | |
* @return studentDetails | |
*/ | |
public function getStudentAppliedDetails($request){ | |
try{ | |
$responseData = new \stdClass; | |
$studentDetails = $this->getAllStudentDetailsByProjectThesis($request); | |
$appliedDetails = (array)$studentDetails; | |
foreach($appliedDetails as $student){ | |
$student->errorMsg = ""; | |
$student->allowUpload = true; | |
$student->alreadyUploaded = false; | |
if(empty($student->projectThesisProperties)){ | |
$student->errorMsg = "Uploads not yet started!"; | |
$student->allowUpload = false; | |
} | |
else{ | |
if(strtotime($student->projectThesisProperties->verificationStartDate) > strtotime(date("Y-m-d"))){ | |
$verificationStartDate = date("d-m-Y",strtotime($student->projectThesisProperties->verificationStartDate)); | |
$student->errorMsg = "Upload will be open from ".$verificationStartDate; | |
$student->allowUpload = false; | |
} | |
else{ | |
$requestForCertificate = new \stdClass(); | |
$requestForCertificate->groupId = $student->groupId; | |
$requestForCertificate->studentId = $student->studentId; | |
$requestForCertificate->type = 'PROJECT_THESIS'; | |
$student->uploadedCertificates = CertificateUploadService::getInstance()->getCertificateUpload($requestForCertificate); | |
if(!empty($student->uploadedCertificates)){ | |
$student->alreadyUploaded = true; | |
} | |
if($student->projectThesisProperties->verificationStatus){ | |
switch ($student->projectThesisProperties->verificationStatus) { | |
case 'APPROVED': | |
$student->allowUpload = false; | |
$student->status = "Verified"; | |
$student->statusClass = "text-success"; | |
break; | |
case 'REJECTED': | |
$student->allowUpload = true; | |
$student->status = "Rejected, Upload Again"; | |
$student->statusClass = "text-danger"; | |
break; | |
case 'UPLOADED': | |
$student->allowUpload = true; | |
$student->status = "Pending"; | |
$student->statusClass = "text-info"; | |
break; | |
default: | |
$student->allowUpload = true; | |
$student->status = "Not Submitted"; | |
$student->statusClass = "text-info"; | |
break; | |
} | |
} | |
else{ | |
$student->allowUpload = true; | |
$student->status = "Not Submitted"; | |
$student->statusClass = "text-info"; | |
} | |
} | |
if(strtotime($student->projectThesisProperties->verificationEndDate) < strtotime(date("Y-m-d"))){ | |
$student->errorMsg = "Cannot upload Date exceeded!"; | |
$student->allowUpload = false; | |
} | |
} | |
} | |
return $appliedDetails; | |
} | |
catch(\Exception $e) { | |
throw new ExamControllerException ($e->getCode(),$e->getMessage()); | |
} | |
} | |
} |