Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 40 |
CRAP | |
0.00% |
0 / 577 |
| CourseFileElementService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 40 |
17292.00 | |
0.00% |
0 / 577 |
| __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 / 5 |
|||
| getAllCourseElementTypes | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| createElement | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| updateElement | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getAllCustomCourseElements | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 15 |
|||
| createContent | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| updateContent | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 11 |
|||
| fetchContentsByElementId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| getAllDepartmentAsAttributes | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 31 |
|||
| removeMapContent | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| InsertMapContent | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getAllProgramAsAttributes | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 30 |
|||
| getAllSubjectsAsAttributes | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 31 |
|||
| getAllBatchAsAttributes | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 31 |
|||
| deleteContent | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| deleteCustomElement | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| fetchCustomElementObjectivesForSubject | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 17 |
|||
| fetchCustomElementObjectivesForDepartment | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 35 |
|||
| fetchCustomElementObjectivesForProgram | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 17 |
|||
| fetchCustomElementObjectivesForBatch | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 17 |
|||
| fetchCustomElementObjectivesForCommon | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 17 |
|||
| getCourseFileConstants | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| getCourseDiaryConstants | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| updateCourseFileConstants | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| updateCourseDiaryConstants | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| updateCourseFileConstantsProperties | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| updateCourseDiaryConstantsProperties | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getCourseFileConstantPropertiesByName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getCourseDiaryConstantPropertiesByName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getCourseDiaryConstantsForRender | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getCourseFileConstantsForRender | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| updateOrder | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 22 |
|||
| updateCourseDiaryOrder | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 13 |
|||
| editCourseFileSettingsOrder | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 29 |
|||
| getCourseFileConstantsCustom | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 27 |
|||
| resetCourseFileCustomOrder | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 19 |
|||
| getCourseFileWeekDate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| updateShow | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\constant\courseFileAndDiary\CourseFileAndDiary; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use stdClass; | |
| class CourseFileElementService extends BaseService | |
| { | |
| private static $_instance = null; | |
| // /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; | |
| } | |
| /** | |
| * @return Array | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllCourseElementTypes() | |
| { | |
| $sql = "SELECT id, name from course_file_element_types"; | |
| try { | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @throws ProfessionalException | |
| */ | |
| public function createElement($request) | |
| { | |
| $sql = "INSERT INTO `course_file_elements` (`name`, `element_type_id`, `permission`, `created_by`) | |
| VALUES ('$request->elementName', '$request->elementType', '$request->updatedPermissions', '$request->adminId') "; | |
| try { | |
| return $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @throws ProfessionalException | |
| */ | |
| public function updateElement($request) | |
| { | |
| $sql = "UPDATE course_file_elements | |
| SET name = '$request->elementName', element_type_id = '$request->elementType', | |
| permission = '$request->updatedPermissions' ,created_by= '$request->adminId' | |
| WHERE id= '$request->elementId'"; | |
| try { | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Array | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllCustomCourseElements() | |
| { | |
| $sql = "SELECT cfe.id, cfe.name, cfe.element_type_id as elementTypeId,permission, | |
| cfet.name as elementType | |
| from course_file_elements cfe inner join course_file_element_types cfet | |
| on cfet.id = cfe.element_type_id"; | |
| try { | |
| $customElements = $this->executeQueryForList($sql); | |
| foreach($customElements as $element){ | |
| $element->permission = json_decode($element->permission); | |
| } | |
| return $customElements; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object|Array | |
| * @throws ProfessionalException | |
| */ | |
| public function createContent($request) | |
| { | |
| $sql = "INSERT INTO course_file_element_content (`title`, `content`, `course_file_element_id`, `course_file_element_type_id`, `created_by`, `created_at`, `updated_by`, `updated_at`) | |
| VALUES ('$request->title', '$request->content', '$request->courseFileElementId', '$request->courseFileElementTypeId', '$request->adminId', now(), '$request->adminId', now()) "; | |
| try { | |
| return $this->executeQuery($sql,true); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object|Array | |
| * @throws ProfessionalException | |
| */ | |
| public function updateContent($request) | |
| { | |
| $staffId = $request->adminId?$request->adminId:$request->staffId; | |
| $sql = "UPDATE course_file_element_content | |
| SET title= '$request->title', content = '$request->content', updated_by = '$staffId', updated_at = NOW() | |
| WHERE id = '$request->contentId'"; | |
| try { | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object|Array | |
| * @throws ProfessionalException | |
| */ | |
| public function fetchContentsByElementId($elemendId) | |
| { | |
| $sql = "SELECT cfec.id ,cfec.title,cfec.content, cfec.course_file_element_id as courseFileElementId,cfec.course_file_element_type_id as elementTypeId, | |
| cfec.attribute_id as attributeId, cfet.name as elementTypeName | |
| FROM course_file_element_content cfec inner join course_file_element_types cfet | |
| on cfet.id = cfec.course_file_element_type_id | |
| WHERE cfec.course_file_element_id = $elemendId"; | |
| try { | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllDepartmentAsAttributes($request) | |
| { | |
| $joinCond = "";$limit = "";$cond =''; | |
| if($request->id){ | |
| $joinCond .= " AND cfecm.course_file_content_id = '$request->id'"; | |
| } | |
| if($request->searchText){ | |
| $cond .= " AND d.deptName like '%$request->searchText%' OR d.departmentDesc like '%$request->searchText%' "; | |
| } | |
| if($request->currentPage && $request->recordsPerPage){ | |
| $startFrom = ($request->currentPage -1) * $request->recordsPerPage; | |
| $limit .=" limit ".$startFrom." , ".$request->recordsPerPage; | |
| } | |
| // $cond =" AND d.deptID NOT IN(SELECT cfecm.attribute_id from course_file_element_content_map cfecm | |
| // inner join course_file_element_content cfec on cfec.id = cfecm.course_file_content_id | |
| // inner join course_file_element_types cfet on cfet.id = cfec.course_file_element_type_id | |
| // where cfet.name = 'DEPARTMENT' AND cfecm.course_file_content_id <> '$request->id') "; | |
| $sql = "SELECT d.deptID as atrId, concat(d.deptName,'-',d.departmentDesc) as atrName, cfecm.id as contentMapId from department d | |
| left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = d.deptID $joinCond | |
| where deptShow = 1 $cond | |
| order by d.deptName ASC $limit"; | |
| $sqlCount = "SELECT count(d.deptID) as count from department d | |
| left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = d.deptID $joinCond | |
| where deptShow = 1 $cond | |
| order by d.deptName ASC"; | |
| try { | |
| $response = new stdClass(); | |
| $response->result = $this->executeQueryForList($sql); | |
| $response->totalRecordsCount = $this->executeQueryForObject($sqlCount)->count; | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @throws ProfessionalException | |
| */ | |
| public function removeMapContent($request) | |
| { | |
| $sql = "DELETE from course_file_element_content_map where id = $request->contentMapId"; | |
| try { | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @throws ProfessionalException | |
| */ | |
| public function InsertMapContent($request) | |
| { | |
| $sql = "INSERT INTO course_file_element_content_map(`course_file_content_id`, `attribute_id`, `created_by`, `created_at`) | |
| VALUES ('$request->contentId', '$request->attrId', '$request->adminId', now()) "; | |
| try { | |
| return $this->executeQuery($sql,true); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllProgramAsAttributes($request) | |
| { | |
| $joinCond = "";$limit = "";$cond = ''; | |
| if($request->id){ | |
| $joinCond .= " AND cfecm.course_file_content_id = '$request->id' "; | |
| } | |
| if($request->searchText){ | |
| $cond .= " AND cp.patternName like '%$request->searchText%' "; | |
| } | |
| if($request->currentPage && $request->recordsPerPage){ | |
| $startFrom = ($request->currentPage -1) * $request->recordsPerPage; | |
| $limit .=" limit ".$startFrom." , ".$request->recordsPerPage; | |
| } | |
| // $cond =" AND cp.patternID NOT IN(SELECT cfecm.attribute_id from course_file_element_content_map cfecm | |
| // inner join course_file_element_content cfec on cfec.id = cfecm.course_file_content_id | |
| // inner join course_file_element_types cfet on cfet.id = cfec.course_file_element_type_id | |
| // where cfet.name = 'PROGRAM' AND cfecm.course_file_content_id <> '$request->id') "; | |
| $sql = "SELECT cp.patternID as atrId,cp.patternName as atrName, cfecm.id as contentMapId | |
| from course_pattern cp left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = cp.patternID $joinCond | |
| WHERE 1=1 $cond | |
| order by cp.patternName ASC $limit"; | |
| $sqlCount = "SELECT count(cp.patternID) as count | |
| from course_pattern cp left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = cp.patternID $joinCond | |
| order by cp.patternName ASC "; | |
| try { | |
| $response = new stdClass(); | |
| $response->result = $this->executeQueryForList($sql); | |
| $response->totalRecordsCount = $this->executeQueryForObject($sqlCount)->count; | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllSubjectsAsAttributes($request) | |
| { | |
| $joinCond = "";$limit = "";$cond = ''; | |
| if($request->id){ | |
| $joinCond .= " AND cfecm.course_file_content_id = '$request->id' "; | |
| } | |
| if($request->searchText){ | |
| $cond .= " AND sub.subjectName like '%$request->searchText%' OR sub.subjectDesc like '%$request->searchText%' "; | |
| } | |
| if($request->currentPage && $request->recordsPerPage){ | |
| $startFrom = ($request->currentPage -1) * $request->recordsPerPage; | |
| $limit .=" limit ".$startFrom." , ".$request->recordsPerPage; | |
| } | |
| // $cond =" AND sub.subjectID NOT IN(SELECT cfecm.attribute_id from course_file_element_content_map cfecm | |
| // inner join course_file_element_content cfec on cfec.id = cfecm.course_file_content_id | |
| // inner join course_file_element_types cfet on cfet.id = cfec.course_file_element_type_id | |
| // where cfet.name = 'SUBJECT' AND cfecm.course_file_content_id <> '$request->id') "; | |
| $sql = "SELECT sub.subjectID as atrId,concat(sub.subjectName,'-',sub.subjectDesc) as atrName, cfecm.id as contentMapId | |
| from subjects sub left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = sub.subjectID $joinCond | |
| WHERE sub.hide != 1 $cond | |
| order by sub.subjectName ASC $limit"; | |
| $sqlCount = "SELECT count(sub.subjectID) as count | |
| from subjects sub left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = sub.subjectID $joinCond | |
| WHERE sub.hide != 1 $cond | |
| order by sub.subjectName ASC "; | |
| try { | |
| $response = new stdClass(); | |
| $response->result = $this->executeQueryForList($sql); | |
| $response->totalRecordsCount = $this->executeQueryForObject($sqlCount)->count; | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllBatchAsAttributes($request) | |
| { | |
| $joinCond = "";$limit = "";$cond = ''; | |
| if($request->id){ | |
| $joinCond .= " AND cfecm.course_file_content_id = '$request->id' "; | |
| } | |
| if($request->searchText){ | |
| $cond .= " AND bat.batchName like '%$request->searchText%' "; | |
| } | |
| if($request->currentPage && $request->recordsPerPage){ | |
| $startFrom = ($request->currentPage -1) * $request->recordsPerPage; | |
| $limit .=" limit ".$startFrom." , ".$request->recordsPerPage; | |
| } | |
| $sql = "SELECT bat.batchID AS atrId,bat.batchName AS atrName, cfecm.id AS contentMapId | |
| FROM batches bat | |
| LEFT JOIN course_file_element_content_map cfecm ON cfecm.attribute_id = bat.batchID $joinCond | |
| WHERE bat.batchHide != 1 AND bat.batchName <> 'failed' $cond | |
| ORDER BY bat.batchName ASC $limit"; | |
| $sqlCount = "SELECT count(bat.batchID) as count | |
| from batches bat left join course_file_element_content_map cfecm | |
| on cfecm.attribute_id = bat.batchID $joinCond | |
| WHERE bat.batchHide != 1 AND bat.batchName <> 'failed' $cond | |
| order by bat.batchName ASC "; | |
| try { | |
| $response = new stdClass(); | |
| $response->result = $this->executeQueryForList($sql); | |
| $response->totalRecordsCount = $this->executeQueryForObject($sqlCount)->count; | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function deleteContent($contentId) | |
| { | |
| $sql = "DELETE FROM course_file_element_content where id = $contentId"; | |
| try { | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function deleteCustomElement($elementId) | |
| { | |
| $sql = "DELETE FROM course_file_elements where id = $elementId"; | |
| try { | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function fetchCustomElementObjectivesForSubject($request) | |
| { | |
| $sql = "SELECT cfec.id as contentId, cfec.title, cfec.content as description, cfe.permission | |
| from course_file_element_content cfec | |
| inner join course_file_element_content_map cfecm on cfec.id = cfecm.course_file_content_id | |
| inner join course_file_elements cfe on cfe.id = cfec.course_file_element_id | |
| inner join course_file_element_types cfet on cfet.id = cfe.element_type_id | |
| where cfet.name = 'SUBJECT' AND cfecm.attribute_id = $request->subjectId "; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $item){ | |
| $item->permission = json_decode($item->permission); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function fetchCustomElementObjectivesForDepartment($request) | |
| { | |
| try { | |
| $isPseudoSubject = $request->pseudoSubjectId ? true : false; | |
| if($isPseudoSubject) | |
| { | |
| $psDetails = PseudoSubjectService::getInstance()->getPseudoSubjectById($request->pseudoSubjectId); | |
| #type1 - department elective, #type2 open course,#type3 foundation ,#type4 mentoring | |
| if($psDetails->pseudoSubjectTypeId == "1") | |
| { | |
| $psDeptID= DepartmentService::getInstance()->getDepartmentByBatchId($request->batchId); | |
| } | |
| else{ | |
| $psDeptID = $psDetails->handlingDepartmentId; | |
| } | |
| } | |
| $deptID = $psDeptID && $isPseudoSubject ? $psDeptID->deptID :""; | |
| $dept= DepartmentService::getInstance()->getDepartmentByBatchId($request->batchId); | |
| if(!$deptID) | |
| { | |
| $deptID = $dept->deptID; | |
| } | |
| $sql = "SELECT cfec.id as contentId, cfec.title, cfec.content as description, cfe.permission | |
| from course_file_element_content cfec | |
| inner join course_file_element_content_map cfecm on cfec.id = cfecm.course_file_content_id | |
| inner join course_file_elements cfe on cfe.id = cfec.course_file_element_id | |
| inner join course_file_element_types cfet on cfet.id = cfe.element_type_id | |
| where cfet.name = 'DEPARTMENT' AND cfecm.attribute_id = $deptID "; | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $item){ | |
| $item->permission = json_decode($item->permission); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function fetchCustomElementObjectivesForProgram($request) | |
| { | |
| $sql = "SELECT cfec.id as contentId, cfec.title, cfec.content as description, cfe.permission | |
| from course_file_element_content cfec | |
| inner join course_file_element_content_map cfecm on cfec.id = cfecm.course_file_content_id | |
| inner join course_file_elements cfe on cfe.id = cfec.course_file_element_id | |
| inner join course_file_element_types cfet on cfet.id = cfe.element_type_id | |
| where cfet.name = 'PROGRAM' AND cfecm.attribute_id = $request->coursePatternId "; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $item){ | |
| $item->permission = json_decode($item->permission); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function fetchCustomElementObjectivesForBatch($request) | |
| { | |
| $sql = "SELECT cfec.id as contentId, cfec.title, cfec.content as description, cfe.permission | |
| from course_file_element_content cfec | |
| inner join course_file_element_content_map cfecm on cfec.id = cfecm.course_file_content_id | |
| inner join course_file_elements cfe on cfe.id = cfec.course_file_element_id | |
| inner join course_file_element_types cfet on cfet.id = cfe.element_type_id | |
| where cfet.name = 'BATCH' AND cfecm.attribute_id = $request->batchId "; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $item){ | |
| $item->permission = json_decode($item->permission); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function fetchCustomElementObjectivesForCommon() | |
| { | |
| $sql = "SELECT cfec.id as contentId, cfec.title, cfec.content as description, cfe.permission | |
| from course_file_element_content cfec | |
| inner join course_file_element_content_map cfecm on cfec.id = cfecm.course_file_content_id | |
| inner join course_file_elements cfe on cfe.id = cfec.course_file_element_id | |
| inner join course_file_element_types cfet on cfet.id = cfe.element_type_id | |
| where cfet.name = 'COMMON' AND cfecm.attribute_id = 0 "; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $item){ | |
| $item->permission = json_decode($item->permission); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseFileConstants() | |
| { | |
| try { | |
| $sql = "SELECT id, constant,label, properties, `show` from | |
| course_file_and_diary_constants | |
| where is_hidden = '0' AND type = '".CourseFileAndDiary::COURSE_FILE."' order by order_no asc"; | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $r){ | |
| $r->properties = json_decode($r->properties); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseDiaryConstants() | |
| { | |
| try { | |
| $sql = "SELECT id, constant, label, properties, `show` | |
| from course_file_and_diary_constants | |
| where is_hidden = '0' AND type = '".CourseFileAndDiary::COURSE_DIARY."' order by order_no asc"; | |
| $result = $this->executeQueryForList($sql); | |
| foreach($result as $r){ | |
| $r->properties = json_decode($r->properties); | |
| } | |
| return $result; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateCourseFileConstants($request) | |
| { | |
| try { | |
| $sql = "UPDATE course_file_and_diary_constants | |
| SET label = '$request->customLabel' | |
| WHERE id= $request->constantId AND type = '".CourseFileAndDiary::COURSE_FILE."' "; | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateCourseDiaryConstants($request) | |
| { | |
| try { | |
| $sql = "UPDATE course_file_and_diary_constants | |
| SET label = '$request->customLabel' | |
| WHERE id= $request->constantId AND type = '".CourseFileAndDiary::COURSE_DIARY."' "; | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateCourseFileConstantsProperties($request) | |
| { | |
| try { | |
| $sql = "UPDATE course_file_and_diary_constants | |
| SET properties = '$request->updatedElement' | |
| WHERE id= $request->constantId AND type = '".CourseFileAndDiary::COURSE_FILE."' "; | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateCourseDiaryConstantsProperties($request) | |
| { | |
| try { | |
| $sql = "UPDATE course_file_and_diary_constants | |
| SET properties = '$request->updatedElement' | |
| WHERE id= $request->constantId "; | |
| $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseFileConstantPropertiesByName($name){ | |
| try { | |
| $sql = "SELECT properties | |
| from course_file_and_diary_constants | |
| where constant = '$name' AND type = '".CourseFileAndDiary::COURSE_FILE."' "; | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseDiaryConstantPropertiesByName($name){ | |
| try { | |
| $sql = "SELECT properties | |
| from course_file_and_diary_constants | |
| where constant = '$name' AND type = '".CourseFileAndDiary::COURSE_DIARY."' "; | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseDiaryConstantsForRender() | |
| { | |
| try { | |
| $sql = "SELECT id as constantId, constant as const,label as name | |
| from course_file_and_diary_constants | |
| where is_hidden = '0' AND type = '".CourseFileAndDiary::COURSE_DIARY."' | |
| order by order_no asc"; | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseFileConstantsForRender() | |
| { | |
| try { | |
| $sql = "SELECT id as constantId,constant as const,label as name | |
| from course_file_and_diary_constants | |
| where is_hidden = '0' AND type = '".CourseFileAndDiary::COURSE_FILE."' | |
| order by order_no asc"; | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateOrder($constants,$type) | |
| { | |
| if (empty($type)) { | |
| throw new ProfessionalException(ProfessionalException::INVALID_PARAMETERS, "Invalid params"); | |
| } | |
| try { | |
| foreach($constants as $key => $constant){ | |
| $order = $key+1; | |
| $id = $constant['id']; | |
| $label = addslashes($constant['label']); | |
| $sql = "UPDATE course_file_and_diary_constants SET order_no = $order, label = '$label' | |
| WHERE id = $id AND type = '$type'; "; | |
| $this->executeQuery($sql); | |
| } | |
| // update created staff elements | |
| $allUpdate = "UPDATE course_settings_staff_order s | |
| INNER JOIN course_file_and_diary_constants c ON c.id = s.constant_id | |
| SET s.order_no = c.order_no | |
| WHERE c.type = '$type';"; | |
| $this->executeQuery($allUpdate); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateCourseDiaryOrder($constants) | |
| { | |
| try { | |
| foreach($constants as $key => $constant){ | |
| $order = $key+1; | |
| $id = $constant['id']; | |
| $label = addslashes($constant['label']); | |
| $sql = "UPDATE course_file_and_diary_constants SET order_no = $order, label = '$label' WHERE id = $id"; | |
| $this->executeQuery($sql); | |
| } | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function editCourseFileSettingsOrder($request){ | |
| $constants = $request->courseFileSettings; | |
| $psId = $request->pseudoSubjectId?$request->pseudoSubjectId:'null'; | |
| try { | |
| foreach($constants as $key => $constant){ | |
| $order = $key+1; | |
| $properties = $constant->properties ? json_encode($constant->properties) : ""; | |
| $constantId = $constant->constantId; | |
| if(!$constantId){ | |
| continue; | |
| } | |
| $staffOrderConstantId = $constant->customConstantId; | |
| if($staffOrderConstantId){ | |
| $sql = "UPDATE course_settings_staff_order | |
| SET order_no = '$order', | |
| properties = '$properties', | |
| updatedBy = '$request->updatedBy', | |
| updatedDate = now() | |
| WHERE id= $staffOrderConstantId "; | |
| } | |
| else{ | |
| $sql = "INSERT INTO course_settings_staff_order (`constant_id`, `sbs_id`, `pseudosubject_id`, `order_no`, `properties`, `createdBy`, `updatedBy`) | |
| VALUES ('$constantId', '$request->sbsId', '$psId', '$order', '$properties', '$request->createdBy', '$request->updatedBy')"; | |
| } | |
| $this->executeQuery($sql); | |
| } | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseFileConstantsCustom($request) | |
| { | |
| $where = []; | |
| $request->pseudoSubjectId ? $where [] = "ss.pseudosubject_id = '$request->pseudoSubjectId'" : "" ; | |
| $request->staffId ? $where [] = "sbs.staffID = '$request->staffId'" : "" ; | |
| $request->batchId ? $where [] = "sbs.batchID = '$request->batchId'" : "" ; | |
| $request->subjectId ? $where [] = "sbs.subjectID = '$request->subjectId'" : "" ; | |
| $request->semId ? $where [] = "sbs.semId = '$request->semId'" : "" ; | |
| if(!$request->type){ | |
| throw new ProfessionalException (ProfessionalException::INVALID_REQUEST, "Invalid request"); | |
| } | |
| try { | |
| $sql = "SELECT con.id AS constantId, t.id AS customConstantId,con.constant AS const,con.label AS name, t.properties, con.properties as column_properties, IF(t.id, t.order_no, con.order_no) as orderNo, con.show | |
| FROM course_file_and_diary_constants con | |
| LEFT JOIN ( | |
| SELECT ss.id, ss.constant_id, ss.sbs_id, ss.pseudosubject_id, ss.order_no, ss.is_course_diary, ss.properties | |
| FROM course_settings_staff_order ss | |
| INNER JOIN sbs_relation sbs ON sbs.sbsID = ss.sbs_id | |
| ".($where?" WHERE ".implode(' AND ',$where):"")." | |
| ) t on t.constant_id = con.id | |
| WHERE con.type = '$request->type' and con.is_hidden = 0 | |
| GROUP BY con.id | |
| ORDER BY IF(t.id, t.order_no, con.order_no) ASC;"; | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function resetCourseFileCustomOrder($request) | |
| { | |
| $where = []; | |
| $request->pseudoSubjectId ? $where [] = "ss.pseudosubject_id = '$request->pseudoSubjectId'" : "" ; | |
| $request->staffId ? $where [] = "sbs.staffID = '$request->staffId'" : "" ; | |
| $request->batchId ? $where [] = "sbs.batchID = '$request->batchId'" : "" ; | |
| $request->subjectId ? $where [] = "sbs.subjectID = '$request->subjectId'" : "" ; | |
| $request->semId ? $where [] = "sbs.semId = '$request->semId'" : "" ; | |
| if(!$request->type){ | |
| throw new ProfessionalException (ProfessionalException::INVALID_REQUEST, "Invalid request"); | |
| } | |
| try { | |
| $sql = "DELETE ss FROM course_settings_staff_order ss | |
| INNER JOIN sbs_relation sbs ON sbs.sbsID = ss.sbs_id | |
| ".($where?" WHERE ".implode(' AND ',$where):"").""; | |
| return $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getCourseFileWeekDate($batchId,$semId) | |
| { | |
| try { | |
| $sql = "SELECT week_startDate as startDate, week_endDate as endDate FROM coursefile_timetable WHERE batchID = ".$batchId." AND semID = ".$semId.""; | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateShow($id) | |
| { | |
| try { | |
| $sql = "update course_file_and_diary_constants set `show` = if(`show`= 1,0,1) where id = '$id';"; | |
| return $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| } |