497 lines
16 KiB
PHP
497 lines
16 KiB
PHP
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Gemiddeldescores
|
|
{
|
|
private $CI;
|
|
private $ijkpunten;
|
|
private $ijkpunt;
|
|
private $leerkrachten;
|
|
private $leerkracht;
|
|
private $score;
|
|
private $wensen;
|
|
private $aantalY;
|
|
private $ijkpuntenok = 0;
|
|
private $scoreteller;
|
|
private $slaover = false;
|
|
private $ambities;
|
|
private $adviezen= [] ;
|
|
private $resultaten;
|
|
private $metingen = [];
|
|
private $aantalnvt = 0;
|
|
private $aantalscores;
|
|
private $somscore = 0;
|
|
private $welkelaagste;
|
|
private $welkehoogste;
|
|
private $laagstescore = 110;
|
|
private $hoogstescore = 0;
|
|
|
|
|
|
|
|
public function __construct($orgversieid, $orgid, $scoretype)
|
|
{
|
|
$this->CI =& get_instance();
|
|
$this->orgversieid = $orgversieid;
|
|
$this->orgid = $orgid;
|
|
$this->scoretype = $scoretype;
|
|
|
|
$this->handle();
|
|
}
|
|
public function getResults(){
|
|
return $this->results;
|
|
}
|
|
|
|
public function getGemiddeldeScores()
|
|
{
|
|
return $this->results->leerkrachten ? $this->results : false;
|
|
}
|
|
|
|
public function getLeerkrachten()
|
|
{
|
|
return $this->leerkrachten;
|
|
}
|
|
|
|
public function getAantalLeerkrachten()
|
|
{
|
|
|
|
return $this->leerkrachten ? count($this->leerkrachten) : false;
|
|
}
|
|
|
|
public function getAmbities()
|
|
{
|
|
return $this->ambities;
|
|
}
|
|
|
|
public function getIJkpunten()
|
|
{
|
|
return $this->ijkpunten;
|
|
}
|
|
|
|
public function getWensen()
|
|
{
|
|
return $this->wensen;
|
|
}
|
|
|
|
private function handle()
|
|
{
|
|
$this->setIJkpunten();
|
|
$this->setOrg();
|
|
$this->setKleuren();
|
|
$this->setLeerkrachten();
|
|
$this->setLeerkrachtScores();
|
|
$this->setMetingen();
|
|
$this->telIJkpunten();
|
|
$this->loopIJkpunten();
|
|
$this->setAmbities();
|
|
$this->setWensen();
|
|
$this->loopIJkpunten2();
|
|
$this->setGemiddelde();
|
|
$this->addGemiddeldeScore();
|
|
$this->setResults();
|
|
}
|
|
|
|
private function setIJkpunten(){
|
|
$this->ijkpunten = $this->CI->Ijkpunten_model->getijkpuntenMetIndicatoren($this->orgversieid);
|
|
}
|
|
|
|
private function setOrg(){
|
|
$this->org = $this->CI->Organisaties_model->get_record_by_id($this->orgid);
|
|
$this->orgnaam = $this->org->brin? $this->org->brin . ' ' . $this->org->naamkort : $this->org->naamkort;
|
|
}
|
|
|
|
private function setKleuren(){
|
|
$this->kleuren = new stdClass();
|
|
$this->kleuren->grens1 = '60';
|
|
$this->kleuren->grens2 = '80';
|
|
$this->kleuren->grens3 = '90';
|
|
$this->kleuren->grens4 = '100';
|
|
if($this->scoretype == 7){
|
|
$this->kleuren->grens1 = '33';
|
|
$this->kleuren->grens2 = '66';
|
|
$this->kleuren->grens3 = '100';
|
|
|
|
}
|
|
|
|
|
|
$this->kleuren->kleur1 = '#e08885';
|
|
$this->kleuren->kleur2 = '#ffcc80';
|
|
$this->kleuren->kleur3 = '#9fdf9f';
|
|
$this->kleuren->kleur4 = '#99d6ff';
|
|
|
|
$this->kleuren->organisatie_id = '0';
|
|
}
|
|
|
|
|
|
private function setLeerkrachten(){
|
|
$this->leerkrachten = $this->CI->Filledversions_model->getlks($this->orgid, $this->orgversieid);
|
|
}
|
|
|
|
private function setLeerkrachtScores(){
|
|
if (!$this->leerkrachten) return;
|
|
foreach ($this->leerkrachten as $index => $this->leerkracht) {
|
|
$this->leerkracht->scores = $this->CI->Scores_model->calculateindividualscores(
|
|
$this->orgversieid, $this->orgid, $this->leerkracht->user_id);
|
|
}
|
|
}
|
|
|
|
private function setMetingen(){
|
|
if (!isset($this->leerkrachten)) return;
|
|
$this->metingen = new stdClass();
|
|
$this->metingen->aantal = 0;
|
|
$this->metingen->aantalorgs = 0;
|
|
|
|
if ($this->org->soort == 4) {
|
|
$gevuld = $this->CI->Scores_model->fCountGevuldeVersies($this->orgversieid, $this->orgid);
|
|
if($gevuld ){
|
|
$this->metingen->aantal = $gevuld->aantal;
|
|
$this->metingen->aantalorgs = 1;
|
|
}
|
|
};
|
|
|
|
if ($this->org->soort == 3) {
|
|
$gevuld = $this->CI->Scores_model->fCountGevuldeBestuurVersies($this->orgversieid, $this->orgid);
|
|
if($gevuld){
|
|
$this->metingen->aantal = $gevuld->aantal;
|
|
$this->metingen->aantalorgs = $gevuld->aantalorgs;}
|
|
};
|
|
|
|
if ($this->org->soort == 2) {
|
|
|
|
$this->onderorgs = $this->CI->Organisaties_model->getscholenonderkamer($this->orgid);
|
|
$this->setGevuldeVersies12();
|
|
$metingen = $this->CI->Scores_model->fCountGevuldeKamerEnSWVVersies($this->orgversieid, $this->orgstring);
|
|
if($metingen){
|
|
$this->metingen->aantal = $metingen->aantal;
|
|
$this->metingen->aantalorgs = $metingen->aantalorgs;
|
|
}
|
|
};
|
|
|
|
if ($this->org->soort == 1) {
|
|
$this->onderorgs = $this->CI->Organisaties_model->getscholenonderswv($this->orgid);
|
|
$this->setGevuldeVersies12();
|
|
$metingen = $this->CI->Scores_model->fCountGevuldeKamerEnSwvVersies($this->orgversieid, $this->orgstring);
|
|
if($metingen){
|
|
$this->metingen->aantal = $metingen->aantal;
|
|
$this->metingen->aantalorgs = $metingen->aantalorgs;
|
|
}
|
|
};
|
|
}
|
|
|
|
private function telIJkpunten(){
|
|
if($this->ijkpunten){
|
|
foreach($this->ijkpunten as $ijkpunt){
|
|
if($ijkpunt->disabled == 'F'){
|
|
$this->aantalY++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private function loopIJkpunten()
|
|
{
|
|
foreach ($this->ijkpunten as $index => $this->ijkpunt) {
|
|
$this->ijkpunt->disablenvt = 'F';
|
|
$this->ijkpunt->totaal = 0;
|
|
$this->ijkpunt->aantallkrtn = 0;
|
|
if($this->ijkpunt->disabled == 'F') {
|
|
$this->loopLeerkrachten();
|
|
$this->setNietvanToepassing();
|
|
$this->setIJkpuntGemiddeldeScores();
|
|
$this->telScoresOp();
|
|
$this->setAantalIJkpuntScores();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private function loopLeerkrachten()
|
|
{
|
|
if (!isset($this->leerkrachten) || !$this->leerkrachten) return;
|
|
foreach ($this->leerkrachten as $this->leerkracht) {
|
|
$this->slaover = false;
|
|
$this->scoreteller = 0;
|
|
$this->loopLeerkrachtScores();
|
|
$this->setVoldoendeAantal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private function loopLeerkrachtScores()
|
|
{
|
|
if (!isset($this->leerkracht->scores) || $this->leerkracht->scores == false) return;
|
|
$this->scoreteller = 0;
|
|
foreach ($this->leerkracht->scores as $index => $this->score) {
|
|
$this->setAantalScores();
|
|
|
|
if ($this->slaover == false) {
|
|
$this->setIJkpuntTotaal();
|
|
$this->telNietVanToepassing();
|
|
}
|
|
}
|
|
}
|
|
|
|
private function setAantalScores(){
|
|
if (!isset($this->leerkracht->scores) || $this->leerkracht->scores == false) return;
|
|
if($this->score->num > 0){
|
|
$this->scoreteller++;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private function setIJkpuntTotaal()
|
|
{
|
|
if ($this->score->nummer == $this->ijkpunt->nummer) {
|
|
if ($this->score->num > 0) {
|
|
$lkrtscore = $this->score->somscore / $this->score->num;
|
|
$this->ijkpunt->totaal = $this->ijkpunt->totaal + $lkrtscore;
|
|
$this->ijkpunt->aantallkrtn++;
|
|
$this->slaover = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private function telNietvanToepassing(){
|
|
if($this->score->scoretype != 4) return;
|
|
if ($this->score->nummer == $this->ijkpunt->nummer) {
|
|
if($this->score->aantalnvt == $this->score->aantalvier )
|
|
$this->aantalnvt++;
|
|
|
|
}
|
|
}
|
|
|
|
private function setVoldoendeAantal(){
|
|
if (!isset($this->leerkracht->scores) || $this->leerkracht->scores == false) return;
|
|
if ($this->scoreteller < 5){
|
|
$this->leerkrachtscores = false;
|
|
}
|
|
}
|
|
|
|
private function setNietVanToepassing(){
|
|
if($this->ijkpunt->aantallkrtn == $this->aantalnvt){
|
|
$this->ijkpunt->disablenvt = 'T';
|
|
}
|
|
}
|
|
|
|
private function setIJkpuntGemiddeldeScores(){
|
|
if ($this->ijkpunt->aantallkrtn > 0) {
|
|
$this->ijkpunt->score = round($this->ijkpunt->totaal / $this->ijkpunt->aantallkrtn);
|
|
$this->ijkpunt->gem = round($this->ijkpunt->totaal / $this->ijkpunt->aantallkrtn);
|
|
}
|
|
else{
|
|
$this->ijkpunt->score = 0;
|
|
$this->ijkpunt->gem = 0;
|
|
}
|
|
}
|
|
|
|
private function telScoresOp(){
|
|
if(! isset($this->ijkpunt->score) || ! $this->ijkpunt->score || $this->ijkpunt->disabled =='T') return;
|
|
|
|
$this->somscore = $this->somscore + $this->ijkpunt->score;
|
|
}
|
|
private function setAantalIJkpuntScores(){
|
|
if(! isset($this->ijkpunt->score) || ! $this->ijkpunt->score || $this->ijkpunt->disabled =='T') return;
|
|
if(!$this->ijkpunt->score) return;
|
|
$this->aantalscores++;
|
|
}
|
|
|
|
|
|
|
|
private function getKleur ($score){
|
|
$kleur = $this->CI->Scorekleuren_model->getGemiddeldeKleur($this->scoretype, $score);
|
|
$kleur = $kleur->kleurcode;
|
|
if(!$kleur) $kleur = '#ffffff';
|
|
|
|
return $kleur;
|
|
}
|
|
|
|
|
|
private function setAmbities(){
|
|
$ambitieorgs = '';
|
|
|
|
$ambitieorgs = $this->getAmbitieOrgs($this->orgid, $ambitieorgs);
|
|
$ambitieorgs = rtrim($ambitieorgs, ',');
|
|
|
|
$toporgsarray = explode(',', $ambitieorgs);
|
|
$toporgs = '';
|
|
$index = 0;
|
|
for($i = count($toporgsarray)-1; $i >= 0 ; $i--) {
|
|
if($index < 2) {
|
|
$toporgs .= $toporgsarray[$i] . ',';
|
|
$index++;
|
|
}
|
|
}
|
|
$toporgs = rtrim($toporgs, ',' );
|
|
|
|
$this->ambities = $this->CI->Ambities_model->mh_get_ambitie_orgversie($this->orgversieid, $ambitieorgs, $toporgs);
|
|
|
|
}
|
|
|
|
private function setWensen(){
|
|
$this->wensen = $this->CI->Wenssituaties_model->getgewenst($this->orgversieid, $this->orgid);
|
|
}
|
|
|
|
private function loopIJkpunten2(){
|
|
if(!$this->ijkpunten) return;
|
|
|
|
foreach($this->ijkpunten as $index => $this->ijkpunt){
|
|
if(!isset($this->ijkpunt->score)){continue;};
|
|
if(! $this->ijkpunt->score) $this->ijkpuntscore = 0;
|
|
$this->setScorenummer();
|
|
$this->rondScoresAf();
|
|
$this->setScoreKleuren();
|
|
$this->addGewensteScores($index);
|
|
$this->setWenskleuren();
|
|
$this->setAdviezen();
|
|
$this->setResultatenOverzicht();
|
|
$this->telIJkpuntenok();
|
|
}
|
|
}
|
|
|
|
private function setScoreNummer(){
|
|
if($this->scoretype != 7) {
|
|
$this->ijkpunt->huidig = 1;
|
|
if ($this->ijkpunt->score >= $this->kleuren->grens1) $this->ijkpunt->huidig = 2;
|
|
if ($this->ijkpunt->score >= $this->kleuren->grens2) $this->ijkpunt->huidig = 3;
|
|
if ($this->ijkpunt->score >= $this->kleuren->grens3) $this->ijkpunt->huidig = 4;
|
|
}
|
|
if($this->scoretype == 7){
|
|
if ($this->ijkpunt->score == $this->kleuren->grens3) $this->ijkpunt->huidig = 4;
|
|
if ($this->ijkpunt->score < $this->kleuren->grens3) $this->ijkpunt->huidig = 3;
|
|
if ($this->ijkpunt->score <= $this->kleuren->grens2) $this->ijkpunt->huidig = 2;
|
|
if ($this->ijkpunt->score <= $this->kleuren->grens1) $this->ijkpunt->huidig = 1;
|
|
}
|
|
}
|
|
|
|
private function rondScoresAf(){
|
|
$this->ijkpunt->score = round($this->ijkpunt->score);
|
|
}
|
|
|
|
private function setScoreKleuren(){
|
|
$kleur = $this->CI->Scorekleuren_model->getGemiddeldeKleur($this->scoretype, $this->ijkpunt->score);
|
|
$kleur = $kleur->kleurcode;
|
|
if(!$kleur) $kleur = '#ffffff';
|
|
$this->ijkpunt->kleur = $kleur;
|
|
|
|
}
|
|
|
|
private function addGewensteScores($index){
|
|
$this->ijkpunt->wens = 3;
|
|
|
|
if (isset($this->wensen) && isset($this->wensen[$index]) ) {
|
|
$this->ijkpunt->wens = $this->wensen[$index]->wens;
|
|
}
|
|
}
|
|
|
|
private function setWensKleuren(){
|
|
if(!isset($this->ijkpunt->wens)) return;
|
|
|
|
$kleur = $this->CI->Scorekleuren_model->getWensKleur($this->scoretype, $this->ijkpunt->wens);
|
|
if(!$kleur) $kleur = '#ffffff';
|
|
$this->ijkpunt->wenskleur = $kleur;
|
|
}
|
|
|
|
private function setAdviezen(){
|
|
if(isset($this->ijkpunt->wens) &&
|
|
$this->ijkpunt->huidig < $this->ijkpunt->wens &&
|
|
|
|
$this->ijkpunt->wens!= 0 &&
|
|
isset($this->ijkpunt->omschrijving ) &&
|
|
$this->ijkpunt->disabled == 'F' &&
|
|
$this->ijkpunt->disablenvt == 'F'){
|
|
$this->adviezen[] = [
|
|
"nummer"=> $this->ijkpunt->nummer,
|
|
"omschrijving" =>$this->ijkpunt->omschrijving
|
|
];
|
|
}
|
|
}
|
|
|
|
private function setResultatenOverzicht()
|
|
{
|
|
if ($this->ijkpunt->score > $this->hoogstescore) {
|
|
$this->hoogstescore = $this->ijkpunt->score;
|
|
$this->welkehoogste = $this->ijkpunt->nummer;
|
|
}
|
|
if ($this->ijkpunt->score <= $this->laagstescore) {
|
|
$this->laagstescore = $this->ijkpunt->score;
|
|
$this->welkelaagste = $this->ijkpunt->nummer;
|
|
}
|
|
}
|
|
|
|
private function telIJkpuntenok(){
|
|
if ($this->ambities && $this->ijkpunt->score >= $this->ambities->zprocent && $this->ijkpunt->disablenvt == 'F') {
|
|
$this->ijkpuntenok++;
|
|
}
|
|
}
|
|
|
|
private function setGemiddelde(){
|
|
$this->gemiddelde = new stdClass();
|
|
$this->gemiddelde->score = 0;
|
|
$deler = $this->aantalY - $this->aantalnvt;
|
|
if($deler > 0) $this->gemiddelde->score = round($this->somscore / $deler);
|
|
$this->gemiddelde->gem = $this->gemiddelde->score;
|
|
$this->gemiddelde->nummer = 'gem';
|
|
$this->gemiddelde->disabled = 'F';
|
|
$this->gemiddelde->disablenvt = 'F';
|
|
$this->gemiddelde->kleur = $this->getKleur ($this->gemiddelde->score);
|
|
|
|
}
|
|
|
|
private function addGemiddeldeScore(){
|
|
if(! $this->gemiddelde) return;
|
|
array_push($this->ijkpunten, $this->gemiddelde);
|
|
|
|
}
|
|
|
|
private function setResults()
|
|
{
|
|
$this->resultaten = [
|
|
'totgem' => $this->gemiddelde->score,
|
|
'ijkpuntenok' => $this->ijkpuntenok,
|
|
'welkehoogste' => $this->welkehoogste,
|
|
'hoogstescore' => round($this->hoogstescore, 1),
|
|
'welkelaagste' => $this->welkelaagste,
|
|
'laagstescore' => round($this->laagstescore, 1),
|
|
];
|
|
|
|
$this->results= [
|
|
'orgnaam' => $this->orgnaam,
|
|
'ijkpunten' => $this->ijkpunten,
|
|
'leerkrachten' => $this->leerkrachten,
|
|
'metingen' => $this->metingen,
|
|
'ambities' => $this->ambities,
|
|
'kleuren' => $this->kleuren,
|
|
'wensen' => $this->wensen,
|
|
'resultaten' => $this->resultaten,
|
|
'adviezen' => $this->adviezen,
|
|
'aantalY' => $this->aantalY
|
|
|
|
|
|
];
|
|
}
|
|
|
|
private function getAmbitieOrgs($orgid, $ambitieorgs){
|
|
$ambitieorgs .= $orgid . ',';
|
|
$valtonder = $this->CI->Organisaties_model->get_fieldvalue(['id' => $orgid], 'valtonder_id');
|
|
if($valtonder != $orgid){
|
|
return $this->getAmbitieOrgs($valtonder, $ambitieorgs);
|
|
}
|
|
|
|
return $ambitieorgs;
|
|
|
|
}
|
|
|
|
private function setGevuldeVersies12(){
|
|
$orgids = [];
|
|
if (count($this->onderorgs) > 0) {
|
|
foreach ($this->onderorgs as $index => $this->org) {
|
|
$orgids[] = $this->org->id;
|
|
}
|
|
$this->orgstring = implode(',', $orgids);
|
|
} else $this->orgstring = false;
|
|
|
|
|
|
}
|
|
} |