Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 113 |
StudentHourWiseNotesService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
306.00 | |
0.00% |
0 / 113 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
getStudentHourNotesBySbsId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 29 |
|||
getStudentHourNotesById | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 34 |
|||
getDistinctStudentListBySbsId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 19 |
|||
approveStudentNotes | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 10 |
|||
disapproveStudentNotes | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 10 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use Exception; | |
use com\linways\core\ams\professional\request\GetPreSignedUrlRequest; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\service\ResourceService; | |
class StudentHourWiseNotesService extends BaseService | |
{ | |
/** | |
* Presence of a static member variable | |
* | |
* @var null | |
*/ | |
private static $_instance = null; | |
/** | |
* Mapper variable | |
* @var array | |
*/ | |
private $mapper = []; | |
/** | |
* Initialise mapper, logger, hooks here | |
* | |
* | |
*/ | |
private function __construct() | |
{ | |
} | |
/** | |
* Prevent any object or instance of that class to be cloned | |
*/ | |
private function __clone() | |
{ | |
} | |
/** | |
* Have a single globally accessible static method | |
* | |
* @return CentralizedTimingService|null | |
*/ | |
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; | |
} | |
/** | |
* method to get Student hour notes by sbsID | |
* @param Int $sbsID,$date | |
* @return result | |
* @throws ProfessionalException | |
*/ | |
public function getStudentHourNotesBySbsId($sbsID,$fromDate,$toDate) | |
{ | |
$sql = "SELECT | |
shwn.id as noteID, | |
shwn.studentID, | |
shwn.date, | |
shwn.hour, | |
shwn.sbsID, | |
shwn.note, | |
shwn.isApproved, | |
shwn.approvedDate, | |
shwn.resourceId, | |
sa.studentName | |
FROM | |
student_hour_wise_notes shwn | |
INNER JOIN | |
studentaccount sa ON sa.studentID = shwn.studentID | |
WHERE | |
sbsID = $sbsID | |
AND | |
shwn.date BETWEEN '$fromDate' AND '$toDate' | |
ORDER BY sa.studentName | |
"; | |
try { | |
$result = $this->executeQueryForList($sql); | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* method to get Student hour notes by ID | |
* @param Int $Id | |
* @return result | |
* @throws ProfessionalException | |
*/ | |
public function getStudentHourNotesById($Id) | |
{ | |
$sql = "SELECT | |
shwn.id as noteID, | |
shwn.studentID, | |
shwn.date, | |
shwn.hour, | |
shwn.sbsID, | |
shwn.note, | |
shwn.isApproved, | |
shwn.approvedDate, | |
shwn.resourceId, | |
sa.studentName | |
FROM | |
student_hour_wise_notes shwn | |
INNER JOIN | |
studentaccount sa ON sa.studentID = shwn.studentID | |
WHERE | |
shwn.id = '$Id' | |
ORDER BY sa.studentName | |
"; | |
try { | |
$result = $this->executeQueryForList($sql); | |
if($result[0]->resourceId != null){ | |
$getRequest = new GetPreSignedUrlRequest(); | |
$getRequest->resourceId = $result[0]->resourceId; | |
$getRequest->accessKey = getenv("AWS_ACCESS_KEY"); | |
$getRequest->secretKey = getenv("AWS_CLIENT_SECRET_KEY"); | |
$result[0]->url = ResourceService::getInstance()->getPreSignedUrlByResourceId($getRequest); | |
} | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* method to get disinct Student list by sbsID | |
* @param Int $sbsID,$date | |
* @return result | |
* @throws ProfessionalException | |
*/ | |
public function getDistinctStudentListBySbsId($sbsID) | |
{ | |
$sql = "SELECT | |
distinct(shwn.studentID), | |
sa.studentName | |
FROM | |
student_hour_wise_notes shwn | |
INNER JOIN | |
studentaccount sa ON sa.studentID = shwn.studentID | |
WHERE | |
sbsID = $sbsID | |
ORDER BY sa.studentName | |
"; | |
try { | |
$result = $this->executeQueryForList($sql); | |
return $result; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* to approve student notes by faculty | |
* @param Int $noteIds | |
* @return result | |
* @throws ProfessionalException | |
*/ | |
public function approveStudentNotes($noteIds) | |
{ | |
foreach($noteIds as $noteId){ | |
$sql ="UPDATE student_hour_wise_notes SET isApproved = 1, approvedDate = now() where id='$noteId' "; | |
try { | |
$this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
} | |
/** | |
* to disapprove student notes by faculty | |
* @param Int $noteIds | |
* @return result | |
* @throws ProfessionalException | |
*/ | |
public function disapproveStudentNotes($noteIds) | |
{ | |
foreach($noteIds as $noteId){ | |
$sql ="UPDATE student_hour_wise_notes SET isApproved = 0 where id='$noteId' "; | |
try { | |
$this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
} | |
} | |