Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 19 |
CRAP | |
0.00% |
0 / 222 |
NormalizeRule3Service | |
0.00% |
0 / 1 |
|
0.00% |
0 / 19 |
2352.00 | |
0.00% |
0 / 222 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
getExamTypes | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getQuizTypes | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
insertExamTypes | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
insertQuizTypes | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
insertapproveExamtypeIDs | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
insertapproveQuiztypeIDs | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
get_approve_exam_marks | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 16 |
|||
save_normalization_rule_temp_settings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 14 |
|||
update_normalization_rule_temp_settings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 14 |
|||
normalization_rule_temp_settings_by_ruleID | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
normalization_rule_temp_settings_by_sbsID_subbatchID | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
isExamMarksPublished | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 10 |
|||
getNormalizeSubjectRules | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 14 |
|||
getNormalizeGroupAssignment | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 20 |
|||
getNormalizeRule | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 12 |
|||
getNormalizeSubjectGroupExams | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
class NormalizeRule3Service extends BaseService | |
{ | |
// /Condition 1 - Presence of a static member variable | |
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; | |
} | |
/** | |
* get examtypeids in table | |
* @author Aswin | |
* @param $ruleID | |
* @throws ProfessionalException | |
* @return object|array|\com\linways\base\util\$objectList[] | |
*/ | |
public function getExamTypes($ruleID) | |
{ | |
$ruleID=$this->realEscapeString($ruleID); | |
$query="select examtypeIDs from normalization_rule3_groupexams where ruleID=$ruleID and approved=1"; | |
try{ | |
$response=$this->executeQueryForList($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* get quiztypeids in table | |
* @author Aswin | |
* @param $ruleID | |
* @throws ProfessionalException | |
* @return object|array|\com\linways\base\util\$objectList[] | |
*/ | |
public function getQuizTypes($ruleID) | |
{ | |
$ruleID=$this->realEscapeString($ruleID); | |
$query="select quiztypeIDs from normalization_rule3_groupquiz where ruleID=$ruleID and approved=1"; | |
try{ | |
$response=$this->executeQueryForList($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $response; | |
} | |
/** | |
* insert examtypeIDs into temptable | |
* @author Aswin | |
* @param unknown $examTypeArray | |
* @param $ruleID | |
* @throws ProfessionalException | |
* @return string | |
*/ | |
public function insertExamTypes($examTypeArray,$ruleID) | |
{ | |
$ruleID=$this->realEscapeString($ruleID); | |
foreach ($examTypeArray as $r) | |
{ | |
try{ | |
$query="insert into normalization_temp_table (examtypeIDs,ruleID) values ($r,$ruleID)"; | |
$response=$this->executeQueryForList($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
return "inserted"; | |
} | |
/** | |
* insert quiztypeIDs into temptable | |
* @author Aswin | |
* @param unknown $quizTypeArray | |
* @param $ruleID | |
* @throws ProfessionalException | |
* @return string | |
*/ | |
public function insertQuizTypes($quizTypeArray,$ruleID) | |
{ | |
$ruleID=$this->realEscapeString($ruleID); | |
foreach ($quizTypeArray as $r) | |
{ | |
try{ | |
$query="insert into normalization_temp_table (quiztypeIDs,ruleID) values ($r,$ruleID)"; | |
$response=$this->executeQueryForList($query); | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
return "inserted"; | |
} | |
/** | |
* change examtypeID approved to 1 or 0 | |
* @author Aswin | |
* @param unknown $ruleID | |
* @param unknown $examtypeIDs | |
* @param unknown $approve | |
* @throws ProfessionalException | |
* @return string | |
*/ | |
public function insertapproveExamtypeIDs($ruleID,$examtypeIDs,$approve) | |
{ | |
$ruleID=$this->realEscapeString($ruleID); | |
$examtypeIDs=$this->realEscapeString($examtypeIDs); | |
$approve=$this->realEscapeString($approve); | |
try{ | |
$query="update normalization_rule3_groupexams set approved=$approve where ruleID=$ruleID and examtypeIDs='$examtypeIDs'"; | |
$response=$this->executeQuery($query); | |
// error_log($query); | |
return "approved"; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* change quiztypeID approved to 1 or 0 | |
* @author Aswin | |
* @param unknown $ruleID | |
* @param unknown $quiztypeIDs | |
* @param unknown $approve | |
* @throws ProfessionalException | |
* @return string | |
*/ | |
public function insertapproveQuiztypeIDs($ruleID,$quiztypeIDs,$approve) | |
{ | |
$ruleID=$this->realEscapeString($ruleID); | |
$quiztypeIDs=$this->realEscapeString($quiztypeIDs); | |
$approve=$this->realEscapeString($approve); | |
try{ | |
$query="update normalization_rule3_groupquiz set approved=$approve where ruleID=$ruleID and quiztypeIDs='$quiztypeIDs'"; | |
$response=$this->executeQueryForList($query); | |
return "approved"; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* method to return aprove_exam_marks object values | |
* @author Kishan | |
* @param unknown $batchID subbatchID semID examID subjectID | |
* @throws ProfessionalException | |
* @return submitted flag | |
*/ | |
public function get_approve_exam_marks($batchID,$subbatchID,$semID,$examID,$subjectID) | |
{ | |
$response = null; | |
$batchID=$this->realEscapeString($batchID); | |
$subbatchID=$this->realEscapeString($subbatchID); | |
$semID=$this->realEscapeString($semID); | |
$examID=$this->realEscapeString($examID); | |
$subjectID =$this->realEscapeString($subjectID); | |
try{ | |
$query="SELECT * FROM aprove_exam_marks WHERE batchID = '$batchID' AND subbatchID = '$subbatchID' AND semID = '$semID' AND examID = '$examID' AND subjectID = '$subjectID'"; | |
$response=$this->executeQueryForObject($query); | |
return $response; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* method to save values to normalization rule settings | |
* @author Kishan | |
* @param ruleID subbatchID sbsID | |
* @throws ProfessionalException | |
* @return last inserted id | |
*/ | |
public function save_normalization_rule_temp_settings($subbatchID,$sbsID,$ruleID) | |
{ | |
$response = null; | |
$subbatchID = $this->realEscapeString($subbatchID); | |
$sbsID = $this->realEscapeString($sbsID); | |
$ruleID = $this->realEscapeString($ruleID); | |
try{ | |
$query="INSERT INTO normalization_rule3_temp_settings (ruleID,sbsID,subbatchID) values ('$ruleID','$sbsID','$subbatchID')"; | |
$response= $this->executeQueryForObject($query,TRUE); | |
return $response; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* method to update values to normalization rule settings | |
* @author Kishan | |
* @param ruleID subbatchID sbsID | |
* @throws ProfessionalException | |
* @return 0 | |
*/ | |
public function update_normalization_rule_temp_settings($subbatchID,$sbsID,$ruleID) | |
{ | |
$response = null; | |
$subbatchID = $this->realEscapeString($subbatchID); | |
$sbsID = $this->realEscapeString($sbsID); | |
$ruleID = $this->realEscapeString($ruleID); | |
try{ | |
$query="UPDATE normalization_rule3_temp_settings set sbsID = '$sbsID', subbatchID = '$subbatchID' WHERE ruleID = '$ruleID'"; | |
$response= $this->executeQueryForObject($query,TRUE); | |
return $response; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* method to fetch normalization rule temp settings by ruleID | |
* @author Kishan | |
* @param ruleID | |
* @throws ProfessionalException | |
* @return temp settings object | |
*/ | |
public function normalization_rule_temp_settings_by_ruleID($ruleID) | |
{ | |
$response = null; | |
$ruleID = $this->realEscapeString($ruleID); | |
try{ | |
$query="SELECT * FROM normalization_rule3_temp_settings WHERE ruleID = '$ruleID'"; | |
$response= $this->executeQueryForObject($query); | |
return $response; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* method to fetch normalization rule temp settings by sbsID and subbatchID | |
* @author Kishan | |
* @param subbatchID sbsID | |
* @throws ProfessionalException | |
* @return temp settings object | |
*/ | |
public function normalization_rule_temp_settings_by_sbsID_subbatchID($subbatchID,$sbsID) | |
{ | |
$response = null; | |
$subbatchID = $this->realEscapeString($subbatchID); | |
$sbsID = $this->realEscapeString($sbsID); | |
try{ | |
$query="SELECT * FROM normalization_rule3_temp_settings WHERE subbatchID = '$subbatchID' AND sbsID = '$sbsID'"; | |
$response= $this->executeQueryForObject($query); | |
return $response; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function isExamMarksPublished($examId) | |
{ | |
$examId = $this->realEscapeString($examId); | |
$sql="select nre.approved from normalization_rule3_subject nrs inner join normalization_rule3_groupexams_subject nre ON nre.rule_id=nrs.id inner join exam ex ON ex.batchID=nrs.batch_id AND ex.semID=nrs.sem_id AND ex.subjectID=nrs.subject_id AND ex.subbatchID=nrs.subbatchID AND ex.examTypeID IN(nre.examtypeIDs) WHERE ex.examID=$examId group by ex.examTypeID order by nre.approved DESC"; | |
try{ | |
return $this->executeQueryForObject($sql)->approved?true:false; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function getNormalizeSubjectRules($request){ | |
$request = $this->realEscapeObject($request); | |
$request->batchId?$where[] = "batch_id = $request->batchId":NULL; | |
$request->semId?$where[] ="sem_id = $request->semId":NULL; | |
$request->subjectId?$where[] = "subject_id = $request->subjectId":NULL; | |
$request->subbatchId != NULL?$where[] = "subbatchID = $request->subbatchId":NULL; | |
$sql = "SELECT id, batch_id as batchID, sem_id as semID, isAttendance, att_max_mark, att_offset, roundOffAttnPercent from normalization_rule3_subject WHERE ".implode(" AND ",$where); | |
try{ | |
$rules = $this->executeQueryForList($sql); | |
return $rules; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function getNormalizeGroupAssignment($ruleID) | |
{ | |
$sql = "select rule_id from normalization_rule3_groupassignments_subject where rule_id = $ruleID"; | |
try{ | |
$rules = $this->executeQueryForList($sql); | |
if (!empty($rules)) { | |
if (!empty($rules[0]->rule_id)) { | |
$assign_needed = 1; | |
} | |
else{ | |
$assign_needed = 0; | |
} | |
} else { | |
$assign_needed = 0; | |
} | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return $assign_needed; | |
} | |
public function getNormalizeRule($request){ | |
$request = $this->realEscapeObject($request); | |
$request->batchId?$where[] = "batchID = $request->batchId":NULL; | |
$request->semId?$where[] ="semID = $request->semId":NULL; | |
$sql = "SELECT ruleID,batchID, semID, isAttendance, att_max_mark, att_offset, roundOffAttnPercent from normalization_rule3 WHERE ".implode(" AND ",$where); | |
try{ | |
$rules = $this->executeQueryForList($sql); | |
return $rules; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
public function getNormalizeSubjectGroupExams($ruleId,$subjectSpecRule){ | |
if(!$subjectSpecRule){ | |
$sql = "SELECT examgroupID, examtypeIDs, examMark, examBestOf, isExamAvg, ordinal_no, rule_name FROM normalization_rule3_groupexams WHERE ruleID = ".$ruleId.""; | |
} | |
else{ | |
$sql_exam = "SELECT id as examgroupID, examtypeIDs, examMark, examBestOf, isExamAvg, ordinal_no,approved, rule_name FROM normalization_rule3_groupexams_subject WHERE rule_id = ".$ruleId.""; | |
} | |
try{ | |
$rules = $this->executeQueryForList($sql); | |
return $rules; | |
}catch(\Exception $e) | |
{ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
} | |