Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 102 |
| RubricService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
240.00 | |
0.00% |
0 / 101 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getRubricDetailsByQuestionId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 27 |
|||
| insertRubricDetailsOfQuestion | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 22 |
|||
| deleteQuestionRubric | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 20 |
|||
| insertRubricWiseStudentQuestionMark | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| deleteQuestionWiseStudentRubricMark | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\dto\nba\RubricWiseAssessmentCriteriaDetails; | |
| use com\linways\core\ams\professional\dto\nba\RubricWiseAssessment; | |
| use com\linways\core\ams\professional\dto\nba\HolisticRubricCriteria; | |
| use com\linways\core\ams\professional\mapper\nba\RubricsServiceMapper; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use function GuzzleHttp\json_decode; | |
| class RubricService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| private $mapper = []; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| { | |
| $this->mapper = RubricsServiceMapper::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 rubric details of a question by questionId | |
| * @param int $assessmentQuestionId | |
| */ | |
| public function getRubricDetailsByQuestionId($assessmentQuestionId) | |
| { | |
| $assessmentQuestionId = $this->realEscapeString($assessmentQuestionId); | |
| $sqlGetRubricDetails = | |
| "SELECT | |
| rwa.id question_rubric_id, | |
| rwa.assessment_question_id, | |
| rwa.is_percentage, | |
| rwa.batch_id, | |
| rwa.sem_id, | |
| rwa.subject_id, | |
| rwa.staff_id, | |
| rwacd.id rubric_criteria_id, | |
| rwacd.rubric_wise_assessment_id, | |
| rwacd.criteria, | |
| rwacd.value_and_justification | |
| FROM | |
| rubric_wise_assessment rwa | |
| INNER JOIN | |
| rubric_wise_assessment_criteria_details rwacd ON (rwacd.rubric_wise_assessment_id = rwa.id) | |
| WHERE | |
| rwa.assessment_question_id = '$assessmentQuestionId'"; | |
| try { | |
| return $this->executeQueryForList($sqlGetRubricDetails,$this->mapper[RubricsServiceMapper::GET_RUBRIC_DETAILS_BY_QUESTION_ID])[0]; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode,$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * insert rubric details of a question | |
| * @param int $assessmentQuestionId | |
| */ | |
| public function insertRubricDetailsOfQuestion($assessmentQuestionRubricDetails) | |
| { | |
| $assessmentQuestionRubricDetails = $this->realEscapeObject($assessmentQuestionRubricDetails); | |
| $sqlInsertRubricQuestionDetails = "INSERT INTO | |
| rubric_wise_assessment (assessment_question_id, is_percentage, batch_id, sem_id, subject_id, staff_id) | |
| VALUES | |
| ('$assessmentQuestionRubricDetails->assessmentQuestionId', '0', '$assessmentQuestionRubricDetails->batchId', '$assessmentQuestionRubricDetails->semId', '$assessmentQuestionRubricDetails->subjectId', '$assessmentQuestionRubricDetails->staffId')"; | |
| try { | |
| $questionRubricId = $this->executeQueryForObject($sqlInsertRubricQuestionDetails, true); | |
| $sqlInsertRubricDetails="INSERT INTO | |
| rubric_wise_assessment_criteria_details (rubric_wise_assessment_id, criteria, value_and_justification) | |
| VALUES "; | |
| $insertValues = []; | |
| foreach ($assessmentQuestionRubricDetails->rubricWiseAssessmentCriteriaDetails as $rubricCriteria ) { | |
| $valueAndJustification=json_encode($rubricCriteria->valueAndJustification); | |
| $insertValues[] = " ('$questionRubricId', '$rubricCriteria->criteria', '$valueAndJustification')"; | |
| } | |
| $sqlInsertRubricDetails .= implode(',', $insertValues); | |
| return $this->executeQuery($sqlInsertRubricDetails); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode,$e->getMessage()); | |
| } | |
| } | |
| public function deleteQuestionRubric($assessmentQuestionId) | |
| { | |
| $assessmentQuestionId = $this->realEscapeString($assessmentQuestionId); | |
| $sqlDeleteQuestionRubricDetails = "DELETE FROM rubric_wise_assessment_criteria_details | |
| WHERE | |
| rubric_wise_assessment_id = (SELECT | |
| id | |
| FROM | |
| rubric_wise_assessment | |
| WHERE | |
| assessment_question_id = '$assessmentQuestionId')"; | |
| try { | |
| $this->executeQuery($sqlDeleteQuestionRubricDetails); | |
| $sqlDeleteQuestionRubric="DELETE FROM rubric_wise_assessment | |
| WHERE | |
| assessment_question_id = '$assessmentQuestionId'"; | |
| return $this->executeQuery($sqlDeleteQuestionRubric); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode,$e->getMessage()); | |
| } | |
| } | |
| public function insertRubricWiseStudentQuestionMark($assessmentQuestionRubricStudentMarkDetails) | |
| { | |
| $assessmentQuestionRubricStudentMarkDetails = $this->realEscapeObject($assessmentQuestionRubricStudentMarkDetails); | |
| $sqlInsertRubricQuestionStudentMarkDetails = "INSERT INTO | |
| rubric_wise_assessment_student_mark (rubric_wise_assessment_id, rubric_wise_assessment_criteria_and_details_id, student_id, mark_obtained, staff_id) | |
| VALUES | |
| ('$assessmentQuestionRubricStudentMarkDetails->rubricWiseAssessmentId', '$assessmentQuestionRubricStudentMarkDetails->rubricWiseAssessmentCriteriaAndDetailsId', '$assessmentQuestionRubricStudentMarkDetails->studentId', '$assessmentQuestionRubricStudentMarkDetails->markObtained', '$assessmentQuestionRubricStudentMarkDetails->staffId') ON DUPLICATE KEY UPDATE mark_obtained = VALUES(mark_obtained),staff_id = VALUES(staff_id)"; | |
| try { | |
| $questionRubricId = $this->executeQueryForObject($sqlInsertRubricQuestionStudentMarkDetails, true); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode,$e->getMessage()); | |
| } | |
| } | |
| public function deleteQuestionWiseStudentRubricMark($assessmentQuestionRubricStudentMarkDetails) | |
| { | |
| $assessmentQuestionRubricStudentMarkDetails = $this->realEscapeObject($assessmentQuestionRubricStudentMarkDetails); | |
| $sqlDeleteQuestionRubricDetails = "DELETE FROM rubric_wise_assessment_student_mark | |
| WHERE | |
| rubric_wise_assessment_id = '$assessmentQuestionRubricStudentMarkDetails->rubricWiseAssessmentId' AND student_id = $assessmentQuestionRubricStudentMarkDetails->studentId"; | |
| try { | |
| return $this->executeQuery($sqlDeleteQuestionRubricDetails); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode,$e->getMessage()); | |
| } | |
| } | |
| } |