Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 25 |
CRAP | |
0.00% |
0 / 319 |
PatternCourseService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 25 |
4422.00 | |
0.00% |
0 / 319 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
getPatternCourses | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 14 |
|||
getPatternCoursesAndType | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
savePatternCoursesTypes | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 26 |
|||
getPatterncourseById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getAllPatternCourses | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getPatterncourseByType | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getCourseTypes | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
getEntrancePatterncourseByType | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getAllCoursePatterns | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getCoursePatternByPatternId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getPatternDeptCoursesWithSubsideryCourse | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getPatternDeptCoursesWithSubsideryCourseById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 16 |
|||
getAllCampusTypes | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getPatternCoursesByDepartmentIdAndCourseType | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 20 |
|||
getPatternCourseDetailsById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getPatternCourseDetailsByRequest | |
0.00% |
0 / 1 |
132.00 | |
0.00% |
0 / 62 |
|||
getCourses | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 18 |
|||
getPatternCourseCodeByStudentId | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 13 |
|||
getPatternCourseByStudentId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getPatterncourseBybatchId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getPatternCourseCodeBysubjectHandleDept | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getCoursePatternsByCourseType | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\dto\Department; | |
use com\linways\core\ams\professional\constant\ExamType; | |
use com\linways\core\ams\professional\mapper\PatternCourseServiceMapper; | |
use com\linways\core\ams\professional\mapper\StudentServiceMapper; | |
use com\linways\core\ams\professional\request\GetCoursesRequest; | |
use TheSeer\Tokenizer\Exception; | |
class PatternCourseService extends BaseService | |
{ | |
private static $_instance = null; | |
private $mapper = []; | |
// /Condition 2 - Locked down the constructor | |
private function __construct() | |
{ | |
$this->mapper = StudentServiceMapper::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; | |
} | |
/** | |
* get pattern course names | |
* | |
*/ | |
function getPatternCourses($deptId) | |
{ | |
$patternCourseName = null; | |
$sql = "SELECT pdc.patterncourseID, pdc.patterncourseName, pdc.patterncourseCode, pdc.patternAbbreviation, | |
d.deptName, d.departmentDesc | |
FROM pattern_deptcourses pdc | |
INNER JOIN department d ON (pdc.deptID = d.deptID) | |
WHERE pdc.deptID = '$deptId' "; | |
try { | |
$patternCourseName = $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $patternCourseName; | |
} | |
/** | |
* get pattern course and types | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
* @author Aswin | |
*/ | |
function getPatternCoursesAndType() | |
{ | |
$query = "SELECT pd.patterncourseID,pd.patterncourseName,pd.patterncourseCode,at.name,sc.subsiderycoursename | |
FROM pattern_deptcourses pd | |
LEFT JOIN subsiderycourse sc ON pd.patterncourseID = sc.pattern_deptcourses_id | |
LEFT JOIN admission_campus_type at ON pd.patterncourseID = at.patterncourseID;"; | |
try { | |
$response = $this->executeQueryForList($query); | |
return $response; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* save patterncourses and type | |
* @param $type | |
* @param $patterncourseIDs | |
* @return object|array|\com\linways\base\util\$objectList[]|string | |
* @throws ProfessionalException | |
* @author Aswin | |
*/ | |
function savePatternCoursesTypes($type, $patterncourseIDs) | |
{ | |
$type = $this->realEscapeString($type); | |
$patterncourseIDs = $this->realEscapeString($patterncourseIDs); | |
$query1 = "DELETE FROM admission_campus_type WHERE patterncourseID IN ($patterncourseIDs) OR name ='" . $type . "'"; | |
try { | |
$response = $this->executeQueryForList($query1); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
$query = "INSERT INTO admission_campus_type (name,patterncourseID) VALUES "; | |
$patterncourseID = explode(",", $patterncourseIDs); | |
foreach ($patterncourseID as $p_ID) { | |
$query .= "('$type',$p_ID),"; | |
} | |
$query = rtrim($query, ","); | |
if (substr($query, -1) == ")") { | |
try { | |
$response = $this->executeQueryForList($query, true); | |
return $response; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} else { | |
return "success"; | |
} | |
} | |
/** | |
* get pattern course by Id | |
* @param unknown $patterncourseID | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
* @author Aswin | |
*/ | |
function getPatterncourseById($patterncourseID) | |
{ | |
$patterncourseID = $this->realEscapeString($patterncourseID); | |
$query = "SELECT pd.patterncourseID,pd.patterncourseName,pd.patterncourseCode,cp.typeName,cp.course_type, cpn.patternName FROM pattern_deptcourses pd INNER JOIN course_pattern cpn ON pd.patternID=cpn.patternID INNER JOIN course_type cp ON cpn.courseTypeID=cp.courseTypeID WHERE pd.patterncourseID = " . $patterncourseID . ""; | |
try { | |
$response = $this->executeQueryForObject($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* Method for getting all pattern courses | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
* @author Ranjith Balachandran | |
*/ | |
public function getAllPatternCourses() | |
{ | |
$sql = ''; | |
$patternCourses = []; | |
try { | |
$sql = "SELECT * FROM pattern_deptcourses"; | |
$patternCourses = $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $patternCourses; | |
} | |
function getPatterncourseByType($typeID) | |
{ | |
$typeID = $this->realEscapeString($typeID); | |
$query = "SELECT t1.patterncourseID, t1.patterncourseName, t2.patternName, t1.patterncourseCode,sc.subsiderycoursename,at.name as admission_campus_type, t2.patternDesc from pattern_deptcourses t1 LEFT JOIN subsiderycourse sc ON t1.patterncourseID = sc.pattern_deptcourses_id left join admission_campus_type at on t1.patterncourseID = at.patterncourseID, course_pattern t2 where t2.patternID=t1.patternID and t2.courseTypeID = " . $typeID . ""; | |
try { | |
$response = $this->executeQueryForList($query); | |
return $response; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
function getCourseTypes() | |
{ | |
$query = "SELECT courseTypeID, typeName FROM course_type ORDER BY courseTypeID ASC"; | |
try { | |
$response = $this->executeQueryForList($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* get course names having entrance | |
* @param unknown $typeID | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
* @author Aswin | |
*/ | |
function getEntrancePatterncourseByType($typeID) | |
{ | |
$typeID = $this->realEscapeString($typeID); | |
$query = "SELECT t1.patterncourseID, t1.patterncourseName, t2.patternName, t1.patterncourseCode,sc.subsiderycoursename,at.name as admission_campus_type from pattern_deptcourses t1 LEFT JOIN subsiderycourse sc ON t1.patterncourseID = sc.pattern_deptcourses_id left join admission_campus_type at on t1.patterncourseID = at.patterncourseID, course_pattern t2,admission_entrance_patternCourses aep where t2.patternID=t1.patternID and t1.patterncourseID=aep.patterncourseID and t2.courseTypeID ='$typeID'"; | |
try { | |
$response = $this->executeQueryForList($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* Get all course patterns | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getAllCoursePatterns() | |
{ | |
$sql = "SELECT patternID, patternName, patternDesc, courseTypeID FROM course_pattern"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get all course patterns | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getCoursePatternByPatternId($patternID) | |
{ | |
$sql = "SELECT patternID, patternName, patternDesc, courseTypeID FROM course_pattern WHERE patternID ='$patternID'"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Method for getting pattern dept courses with subsidery courses | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getPatternDeptCoursesWithSubsideryCourse() | |
{ | |
$sql = "SELECT pdc.patterncourseID AS patternCourseId, pdc.patterncourseName AS patternCourseName ,pdc.patternAbbreviation, sc.id AS subsideryCourseId, sc.subsiderycoursename AS subsideryCourseName FROM pattern_deptcourses pdc LEFT JOIN subsiderycourse sc ON pdc.patterncourseID = sc.pattern_deptcourses_id"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get pattern pattern dept courses with subsidery courses by | |
* patternCourseId | |
* @param int $patterncourseId | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getPatternDeptCoursesWithSubsideryCourseById($patterncourseId) | |
{ | |
$sql = "SELECT pdc.patterncourseID AS patternCourseId, | |
pdc.patterncourseName AS patternCourseName, | |
pdc.patterncourseCode AS patternCourseCode, | |
sc.id AS subsideryCourseId, | |
sc.subsiderycoursename AS subsideryCourseName, | |
pdc.extraSettings, | |
pdc.patternAbbreviation | |
FROM pattern_deptcourses pdc | |
LEFT JOIN subsiderycourse sc ON pdc.patterncourseID = sc.pattern_deptcourses_id where pdc.patterncourseID = $patterncourseId "; | |
try { | |
return $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get all campus types | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getAllCampusTypes() | |
{ | |
$sql = "select id, name, descrption from campus_type"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* @param $departmentId | |
* @param $courseTypeId | |
* @return Object | |
* @throws ProfessionalException | |
*/ | |
public function getPatternCoursesByDepartmentIdAndCourseType($courseTypeId = null, $departmentId = null) | |
{ | |
$departmentId = $this->realEscapeString($departmentId); | |
$courseTypeId = $this->realEscapeString($courseTypeId); | |
$sql = "SELECT DISTINCT pd.patterncourseID as id,pd.patterncourseName as name | |
FROM pattern_deptcourses pd | |
INNER JOIN department d ON d.deptID = pd.deptID | |
INNER JOIN course_pattern cp on pd.patternID = cp.patternID | |
WHERE 1=1 "; | |
if (!empty($courseTypeId)) { | |
$sql .= " AND cp.courseTypeID = $courseTypeId"; | |
} | |
if (!empty($departmentId)) { | |
$sql .= " AND d.deptID =$departmentId "; | |
} | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get Pattern course details by pattern courseId | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getPatternCourseDetailsById($patternCourseId) | |
{ | |
$sql = "SELECT patterncourseID, patterncourseName, patterncourseCode, patternAbbreviation FROM pattern_deptcourses WHERE patterncourseID = $patternCourseId"; | |
try { | |
return $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get Pattern course details by request for examcontroller common filter | |
* @return array | |
* @throws ProfessionalException | |
*/ | |
public function getPatternCourseDetailsByRequest($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$deptId = $request->deptId; | |
$courseId = $request->courseId; | |
$examRegId = $request->examRegId; | |
$examType = $request->examType; | |
$batch = $request->batch; | |
$joinTables = ""; | |
$whereConditions = ""; | |
if ($examType || $examRegId) { | |
if ($examType == ExamType::REGULAR) { | |
$examTypeBatchTable = "exam_registration_batches"; | |
$examTypeBatchTableColumn = "examregID"; | |
} else if ($examType == ExamType::SUPPLY) { | |
$examTypeBatchTable = "supply_improve_batches"; | |
$examTypeBatchTableColumn = "exam_supplementary_id"; | |
} | |
if ($examType != ExamType::INTERNAL) { | |
// should remove after Internal exam registraion batches table creation | |
$joinTables .= " INNER JOIN | |
$examTypeBatchTable erb ON erb.batchID = b.batchID"; | |
if ($examRegId) { | |
$whereConditions .= " AND erb.$examTypeBatchTableColumn IN ($examRegId)"; | |
} | |
} | |
} | |
if ($courseId) { | |
$joinTables .= " INNER JOIN | |
course_pattern c ON c.patternID = pdc.patternID | |
"; | |
$whereConditions .= " AND b.patternID IN ($courseId) | |
"; | |
} | |
if ($batch) { | |
$whereConditions .= " AND b.batchID IN ($batch) | |
"; | |
} | |
if ($deptId) { | |
$whereConditions .= " AND b.deptID IN ($deptId) | |
"; | |
} | |
$sql = "SELECT DISTINCT | |
pdc.patterncourseID, | |
pdc.patterncourseName, | |
pdc.patterncourseCode, | |
pdc.patternAbbreviation, | |
sc.subsiderycoursename | |
FROM | |
pattern_deptcourses pdc | |
INNER JOIN | |
batches b ON pdc.patterncourseID = b.patterncourseID LEFT JOIN subsiderycourse sc ON sc.pattern_deptcourses_id = pdc.patterncourseID | |
$joinTables | |
WHERE | |
b.batchName <> 'failed' | |
$whereConditions | |
ORDER BY pdc.patterncourseName ASC"; | |
try { | |
$patternCourse = $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $patternCourse; | |
} | |
/** | |
* Used in advanced search filters. so modification of this service affect advanced student search | |
* @param GetCoursesRequest $request | |
* @return Object | |
* @throws ProfessionalException | |
*/ | |
public function getCourses(GetCoursesRequest $request) | |
{ | |
$sql = "SELECT patternID as id,patterncourseName as name,patterncourseCode as code | |
FROM pattern_deptcourses WHERE 1=1 "; | |
if (!empty($request->departmentId)) { | |
$sql .= " AND deptID = $request->departmentId "; | |
} | |
if (!empty($request->courseId)) { | |
$sql .= " AND patterncourseID =$request->courseId "; | |
} | |
if (!empty($request->patternId)) { | |
$sql .= " AND patternID = $request->patternId "; | |
} | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* @param $studentId | |
* @param null $abbr | |
* @return object|null | |
* @throws ProfessionalException | |
* @author Vishnu M | |
*/ | |
public function getPatternCourseCodeByStudentId($studentId, $abbr = null) | |
{ | |
$studentId = $this->realEscapeString($studentId); | |
$sql = null; | |
try { | |
$sql = "SELECT pdc.patterncourseCode AS code, pdc.patternAbbreviation AS abbr FROM studentaccount sa INNER JOIN batches b ON (sa.batchID = b.batchID) INNER JOIN pattern_deptcourses pdc ON (b.patterncourseID = pdc.patterncourseID) WHERE sa.studentID = '$studentId' "; | |
if ($abbr) | |
return $this->executeQueryForObject($sql)->abbr; | |
else | |
return $this->executeQueryForObject($sql)->code; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* | |
* @param $studentId | |
* @return object|null | |
* @throws ProfessionalException | |
* @author George Jose | |
*/ | |
public function getPatternCourseByStudentId($studentId) | |
{ | |
$studentId = $this->realEscapeString($studentId); | |
$sql = null; | |
try { | |
$sql = "SELECT pdc.patterncourseCode, pdc.patterncourseName FROM studentaccount sa INNER JOIN batches b ON (sa.batchID = b.batchID) INNER JOIN pattern_deptcourses pdc ON (b.patterncourseID = pdc.patterncourseID) WHERE sa.studentID = '$studentId' "; | |
return $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* get pattern course by BatchID | |
* @param unknown $batchID | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
* @author Aswin | |
*/ | |
function getPatterncourseBybatchId($batchId) | |
{ | |
$batchId = $this->realEscapeString($batchId); | |
$query = "SELECT t2.patterncourseName FROM pattern_deptcourses t2 INNER JOIN batches t1 ON t1.patterncourseID = t2.patterncourseID WHERE t1.batchID = $batchId"; | |
try { | |
$response = $this->executeQueryForObject($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $response->patterncourseName; | |
} | |
/** | |
* get pattern course code by subject handle dept | |
* @param $subjectId | |
* @param $courseTypeId | |
* | |
*/ | |
function getPatternCourseCodeBysubjectHandleDept($subjectId, $courseTypeId, $batchId) | |
{ | |
$patternCourse = null; | |
$sql = "SELECT pd.patterncourseCode from subjects s INNER JOIN department dept ON (s.hdl_deptID = dept.deptID ) INNER JOIN pattern_deptcourses pd ON (pd.deptID = dept.deptID ) INNER JOIN course_pattern cp ON (cp.patternID = pd.patternID ) INNER JOIN batches b ON b.patterncourseID = pd.patterncourseID AND b.patternID = pd.patternID AND b.patternID = cp.patternID WHERE b.batchID = $batchId AND s.subjectID = $subjectId AND cp.courseTypeID = $courseTypeId"; | |
try { | |
$patternCourse = $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $patternCourse; | |
} | |
/** | |
* Get course patterns | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getCoursePatternsByCourseType($courseTypeId) | |
{ | |
$sql = "SELECT patternID as id, patternName as name, patternDesc, courseTypeID FROM course_pattern WHERE courseTypeID IN ($courseTypeId)"; | |
try { | |
return $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
} | |