Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 124
SlowLearnerIdentificationService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 9
650.00
0.00% covered (danger)
0.00%
0 / 124
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 __clone
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 getInstance
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 5
 addSlowLearnerIdentification
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 28
 updateSlowLearnerIdentification
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 22
 getSlowLearnerIdentification
0.00% covered (danger)
0.00%
0 / 1
132.00
0.00% covered (danger)
0.00%
0 / 26
 updateSlowLearnerIdentificationActions
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 updateSlowLearnerIdentificationAttendance
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 16
 removeSlowLearnerIdentificationById
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 9
<?php
namespace com\linways\core\ams\professional\service;
use com\linways\core\ams\professional\dto\ExamType;
use com\linways\core\ams\professional\util\CommonUtil;
use com\linways\core\ams\professional\service\CommonService;
use com\linways\core\ams\professional\service\StudentService;
use com\linways\core\ams\professional\mapper\ExamServiceMapper;
use com\linways\core\ams\professional\mapper\InternalExamMapper;
use com\linways\core\ams\professional\dto\SlowLearnerIdentification;
use com\linways\core\ams\professional\exception\ProfessionalException;
class SlowLearnerIdentificationService extends BaseService
{
    // private $batchService = BatchService::getInstance();
    // /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 = ExamServiceMapper::getInstance()->getMapper();
        // $this->internalExamMapper = InternalExamMapper::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;
    }
    /**
     * add slow learner identification
     * @param SlowLearnerIdentification $slowLearnerIdentification
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @throws ProfessionalException
     */
    public function addSlowLearnerIdentification($slowLearnerIdentification)
    {
        $slowLearnerIdentification = $this->realEscapeObject($slowLearnerIdentification);
        $slowLearnerIdentification->identifyingContext = json_encode($slowLearnerIdentification->identifyingContext);
        $slowLearnerIdentification->weakStudentIds = json_encode($slowLearnerIdentification->weakStudentIds);
        $slowLearnerIdentification->attendedStudentsIds = json_encode($slowLearnerIdentification->attendedStudentsIds);
        $slowLearnerIdentification->actions = json_encode($slowLearnerIdentification->actions);
        $sql = "INSERT INTO slowLearnerIdentification (
                    identifying_context, 
                    exam_type_id, 
                    percentage, 
                    weakStudentIds, 
                    attendedStudentsIds, 
                    remedialMeasure, 
                    remedialActionEffectivenes, 
                    actions, 
                    date, 
                    createdBy, 
                    createdDate, 
                    updatedBy, 
                    updatedDate) 
                VALUES (
                    '$slowLearnerIdentification->identifyingContext', '$slowLearnerIdentification->examTypeId', $slowLearnerIdentification->percentage, '$slowLearnerIdentification->weakStudentIds', '$slowLearnerIdentification->attendedStudentsIds', '$slowLearnerIdentification->remedialMeasure', '$slowLearnerIdentification->remedialActionEffectivenes', '$slowLearnerIdentification->actions', '$slowLearnerIdentification->date', $slowLearnerIdentification->createdBy, utc_timestamp(), $slowLearnerIdentification->updatedBy, utc_timestamp())";
        try {
            return $this->executeQueryForObject($sql, true);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getMessage(), $e->getCode());
        }
    }
    /**
     * update slow learner identification
     * @param SlowLearnerIdentification $slowLearnerIdentification
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @throws ProfessionalException
     */
    public function updateSlowLearnerIdentification($slowLearnerIdentification)
    {
        $slowLearnerIdentification = $this->realEscapeObject($slowLearnerIdentification);
        $slowLearnerIdentification->weakStudentIds = json_encode($slowLearnerIdentification->weakStudentIds);
        $slowLearnerIdentification->attendedStudentsIds = json_encode($slowLearnerIdentification->attendedStudentsIds);
        $slowLearnerIdentification->actions = json_encode($slowLearnerIdentification->actions);
        $sql = "UPDATE slowLearnerIdentification SET
                    percentage = $slowLearnerIdentification->percentage
                    weakStudentIds = '$slowLearnerIdentification->weakStudentIds', 
                    attendedStudentsIds = '$slowLearnerIdentification->attendedStudentsIds', 
                    remedialMeasure = '$slowLearnerIdentification->remedialMeasure', 
                    remedialActionEffectivenes = '$slowLearnerIdentification->remedialActionEffectivenes', 
                    actions = '$slowLearnerIdentification->actions', 
                    date = '$slowLearnerIdentification->date', 
                    updatedBy = $slowLearnerIdentification->updatedBy
                    updatedDate = utc_timestamp()
                WHERE id = '$slowLearnerIdentification->id'";
        try {
            return $this->executeQueryForObject($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getMessage(), $e->getCode());
        }
    }
    /**
     * get slow learner identification
     * @param int $examTypeId
     * @param in $batchId
     * @param int $subjectId
     * @param float $percenatge
     * @param int $semId
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @throws ProfessionalException
     */
    public function getSlowLearnerIdentification($request)
    {
        $request = $this->realEscapeObject($request);
        $where = [];
        $request->examTypeId? $where[] = " sl.exam_type_id = $request->examTypeId ":"";
        $request->batchId? $where[] = " sl.identifying_context->>'$.batchId' = $request->batchId ":"";
        $request->semId? $where[] = " sl.identifying_context->>'$.semId' = $request->semId ":"";
        $request->subjectId? $where[] = " sl.identifying_context->>'$.subjectId' = $request->subjectId ":"";
        $request->pseudoSubjectId? $where[] = " sl.identifying_context->>'$.pseudoSubjectId' = $request->pseudoSubjectId ":"";
        $request->id? $where[] = " sl.id = $request->id ":"";
        
        $request->date ? $where[] = " date = '$request->date":"";
        $sql = "SELECT sl.id, sl.identifying_context as identifyingContext, sl.exam_type_id as examTypeId, sl.percentage, sl.weakStudentIds, sl.attendedStudentsIds, actions, date FROM slowLearnerIdentification sl
        INNER JOIN exam_type et on et.typeID = sl.exam_type_id
        WHERE ".($where?implode(' AND ',$where):"")." ORDER BY sl.id";
        try {
            $identifications = $this->executeQueryForList($sql);
            foreach ($identifications as $key => $identification) {
                $identification->identifyingContext = json_decode($identification->identifyingContext);
                $identification->weakStudentIds = json_decode($identification->weakStudentIds);
                $identification->attendedStudentsIds = json_decode($identification->attendedStudentsIds);
                $identification->actions = json_decode($identification->actions);
            }
            return $identifications;
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getMessage(), $e->getCode());
        }
    }
    /**
     * update slow learner identification
     * @param SlowLearnerIdentification $slowLearnerIdentification
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @throws ProfessionalException
     */
    public function updateSlowLearnerIdentificationActions($slowLearnerIdentification)
    {
        $slowLearnerIdentification = $this->realEscapeObject($slowLearnerIdentification);
        $slowLearnerIdentification->actions = json_encode($slowLearnerIdentification->actions);
        $sql = "UPDATE slowLearnerIdentification SET
                    actions = '$slowLearnerIdentification->actions', 
                    updatedBy = $slowLearnerIdentification->updatedBy
                    updatedDate = utc_timestamp()
                WHERE id = '$slowLearnerIdentification->id'";
        try {
            return $this->executeQueryForObject($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getMessage(), $e->getCode());
        }
    }
    /**
     * update slow learner identification
     * @param SlowLearnerIdentification $slowLearnerIdentification
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @throws ProfessionalException
     */
    public function updateSlowLearnerIdentificationAttendance($slowLearnerIdentification)
    {
        $slowLearnerIdentification = $this->realEscapeObject($slowLearnerIdentification);
        $slowLearnerIdentification->weakStudentIds = json_encode($slowLearnerIdentification->weakStudentIds);
        $slowLearnerIdentification->attendedStudentsIds = json_encode($slowLearnerIdentification->attendedStudentsIds);
        $sql = "UPDATE slowLearnerIdentification SET
                    weakStudentIds = '$slowLearnerIdentification->weakStudentIds', 
                    attendedStudentsIds = '$slowLearnerIdentification->attendedStudentsIds',
                    updatedBy = $slowLearnerIdentification->updatedBy
                    updatedDate = utc_timestamp()
                WHERE id = '$slowLearnerIdentification->id'";
        try {
            return $this->executeQueryForObject($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getMessage(), $e->getCode());
        }
    }
    /**
     * get slow learner identification by examId
     * @param int $id
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @throws ProfessionalException
     */
    public function removeSlowLearnerIdentificationById($id)
    {
        $id = $this->realEscapeString($id);
        $sql = "DELETE FROM slowLearnerIdentification WHERE id=$id";
        try {
            return $this->executeQuery($sql);
        } catch (\Exception $e) {
            throw new ProfessionalException($e->getMessage(), $e->getCode());
        }
    }
}
?>