399 lines
13 KiB
PHP
399 lines
13 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Gemiddeldenafbeeldingen {
|
|
|
|
private $CI;
|
|
private $swvid;
|
|
private $leerkrachten;
|
|
private $ijkpunten;
|
|
private $ijkpunt;
|
|
private $omschrijving;
|
|
private $aantalY;
|
|
private $somscore = 0;
|
|
private $aantalscores = 0;
|
|
private $score;
|
|
private $wensen;
|
|
private $wens;
|
|
private $ambities;
|
|
private $adviezen = [];
|
|
private $labels;
|
|
private $kleuren;
|
|
private $kleurcodes;
|
|
private $orgversie;
|
|
private $vantm;
|
|
private $gemiddelde;
|
|
private $nummer;
|
|
private $ijkpuntenok = 0;
|
|
private $welkehoogste = 0;
|
|
private $hoogstescore = -1;
|
|
private $welkelaagste = 0;
|
|
private $laagstescore = 101;
|
|
private $rij = 708;
|
|
private $standaardorg = 250;
|
|
private $aantal = 15;
|
|
private $resultaten;
|
|
private $kolombreedte;
|
|
private $orgbreedte;
|
|
private $disablenvt = 0;
|
|
|
|
private $gemiddeldenafbeeldingen;
|
|
|
|
public function __construct(Gemiddeldescores $gemiddeldescores, $modulenr, $orgversieid, $clusterid, $orgid){
|
|
$this->CI = & get_instance();
|
|
$this->gemiddeldescores = $gemiddeldescores;
|
|
$this->modulenr = $modulenr;
|
|
$this->orgversieid = $orgversieid;
|
|
$this->orgid = $orgid;
|
|
$this->clusterid = $clusterid;
|
|
$this->setLeerkrachten();
|
|
$this->setOrgversie();
|
|
$this->setAmbities();
|
|
$this->setIJkpunten();
|
|
$this->setWensen();
|
|
$this->handle();
|
|
}
|
|
|
|
public function getGemiddeldenAfbeeldingen(){
|
|
return $this->gemiddeldenafbeeldingen;
|
|
}
|
|
|
|
public function getAantalScores(){
|
|
return $this->aantalscores;
|
|
}
|
|
|
|
public function getIJkpunten(){
|
|
return $this->ijkpunten;
|
|
}
|
|
|
|
public function getAdviezen(){
|
|
return $this->adviezen;
|
|
}
|
|
|
|
public function getResultaten(){
|
|
$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),
|
|
];
|
|
|
|
return $this->resultaten;
|
|
}
|
|
|
|
public function getKleuren(){
|
|
return $this->kleuren;
|
|
}
|
|
|
|
private function setLeerkrachten(){
|
|
$this->leerkrachten = $this->gemiddeldescores->getLeerkrachten();
|
|
}
|
|
|
|
private function setOrgversie(){
|
|
$this->orgversie = $this->CI->Orgversies_model->get_record_by_id($this->orgversieid);
|
|
}
|
|
|
|
private function setAmbities(){
|
|
$this->ambities = $this->gemiddeldescores->getAmbities();
|
|
}
|
|
|
|
private function setIJkpunten(){
|
|
$this->ijkpunten = $this->gemiddeldescores->getIJKpunten();
|
|
}
|
|
|
|
private function setWensen(){
|
|
$this->wensen = $this->gemiddeldescores->getWensen();
|
|
}
|
|
|
|
private function handle(){
|
|
$this->setSwvid();
|
|
$this->setLabels();
|
|
$this->telIJkpunten();
|
|
$this->setPeriode();
|
|
$this->setKleurcodes();
|
|
$this->setKleuren();
|
|
$this->loopIJkpunten();
|
|
$this->loopIJkpunten2(); // verplaatst boven addGemiddelde score omdat je anders een "ijkpunt" te veel hebt
|
|
|
|
// moet hier niet eerst setGemiddelde worden gedaan?
|
|
$this->setGemiddeldeScore();
|
|
$this->addGemiddeldeScore();
|
|
$this->setGemiddeldenAfbeeldingen();
|
|
|
|
}
|
|
private function setSwvid(){
|
|
$this->swvid = $this->CI->Organisaties_model->get_swvid($this->orgid);
|
|
}
|
|
|
|
private function setLabels(){
|
|
$this->labels = $this->CI->Labels_model->getalllabels($this->modulenr);
|
|
if(! $this->labels){
|
|
$this->labels = $this->CI->Labels_model->getalllabels(1);
|
|
}
|
|
}
|
|
|
|
private function telIJkpunten(){
|
|
if($this->ijkpunten){
|
|
$this->aantalY = count($this->ijkpunten);
|
|
}
|
|
}
|
|
|
|
private function setPeriode(){
|
|
$this->orgversie = $this->CI->Orgversies_model->get_record_by_id($this->orgversieid);
|
|
$this->vantm = "Gegevens uit periode ".$this->orgversie->periodenummer." van ".
|
|
mysql2date($this->orgversie->geldigvanaf)." t/m ".mysql2date($this->orgversie->geldigtm);
|
|
}
|
|
|
|
|
|
private function setKleurcodes(){
|
|
$this->kleurcodes = new Kleurcodes();
|
|
}
|
|
|
|
private function setKleuren(){
|
|
|
|
// $this->kleuren = $this->kleurcodes->getKleurcodesOrg($this->clusterid, $this->swvid);
|
|
// $this->CI->firephp->log($this->kleuren, "kleuren");
|
|
// if(!$this->kleuren || $this->kleuren == " "){
|
|
$this->kleuren = new stdClass();
|
|
$this->kleuren->cluster_id = $this->clusterid;
|
|
$this->kleuren->grens1 = '60';
|
|
$this->kleuren->grens2 = '80';
|
|
$this->kleuren->grens3 = '90';
|
|
$this->kleuren->grens4 = '100';
|
|
if($this->orgversie->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 loopIJkpunten(){
|
|
foreach($this->ijkpunten as $index =>$this->ijkpunt){
|
|
if(! isset($this->ijkpunt->score) || ! $this->ijkpunt->score || $this->ijkpunt->disabled =='T') {continue;};
|
|
$this->setDisablenvt();
|
|
$this->telScoresOp();
|
|
$this->setAantalScores();
|
|
}
|
|
$this->setGemiddeldeScore(); // gemiddelde ga je niet in de loop berekenen
|
|
}
|
|
|
|
private function setDisablenvt(){
|
|
$this->ijkpunt->disablenvt = 'F';
|
|
if($this->ijkpunt->aantalvier > 0 && $this->ijkpunt->aantalvier == $this->ijkpunt->aantalnvt)
|
|
$this->ijkpunt->disablenvt = 'T';
|
|
$this->disablenvt++;
|
|
|
|
}
|
|
|
|
private function telScoresOp(){
|
|
$this->somscore = $this->somscore + $this->ijkpunt->score;
|
|
}
|
|
private function setAantalScores(){
|
|
if(!$this->ijkpunt->score) return;
|
|
$this->aantalscores++;
|
|
}
|
|
|
|
private function getKleur ($score){
|
|
$grensnummer = 1;
|
|
if ($score>= $this->kleuren->grens1) $grensnummer = 2;
|
|
if ($score>= $this->kleuren->grens2) $grensnummer = 3;
|
|
if ($score>= $this->kleuren->grens3) $grensnummer = 4;
|
|
|
|
switch ( $grensnummer) {
|
|
case 1:
|
|
$kleur = $this->kleuren->kleur1;
|
|
break;
|
|
case 2:
|
|
$kleur = $this->kleuren->kleur2;
|
|
break;
|
|
case 3:
|
|
$kleur = $this->kleuren->kleur3;
|
|
break;
|
|
case 4:
|
|
$kleur = $this->kleuren->kleur4;
|
|
break;
|
|
default:
|
|
$kleur = $this->kleuren->kleur1;
|
|
}
|
|
return $kleur;
|
|
}
|
|
|
|
private function setGemiddeldeScore(){
|
|
$this->gemiddelde = new stdClass();
|
|
$this->gemiddelde->score = 0;
|
|
$deler = $this->aantalY - $this->disablenvt;
|
|
if($deler > 0) $this->gemiddelde->score = round($this->somscore / $deler);
|
|
|
|
|
|
$this->gemiddelde->nummer = 'gem';
|
|
$this->gemiddelde->disabled = 'F';
|
|
$this->gemiddelde->kleur =$this->getKleur ($this->gemiddelde->score);
|
|
$this->ijkpunt = $this->gemiddelde;
|
|
}
|
|
|
|
private function addGemiddeldeScore(){
|
|
if(! $this->gemiddelde) return;
|
|
array_push($this->ijkpunten, $this->ijkpunt);
|
|
|
|
}
|
|
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->setAdvies();
|
|
$this->setResultatenOverzicht();
|
|
$this->telIJkpuntenok();
|
|
}
|
|
}
|
|
|
|
private function setScoreNummer(){
|
|
if($this->orgversie->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->orgversie->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(){
|
|
switch ($this->ijkpunt->huidig) {
|
|
case 1:
|
|
$this->ijkpunt->kleur = $this->kleuren->kleur1;
|
|
break;
|
|
case 2:
|
|
$this->ijkpunt->kleur = $this->kleuren->kleur2;
|
|
break;
|
|
case 3:
|
|
$this->ijkpunt->kleur = $this->kleuren->kleur3;
|
|
break;
|
|
case 4:
|
|
$this->ijkpunt->kleur = $this->kleuren->kleur4;
|
|
break;
|
|
default:
|
|
$this->ijkpunt->kleur = $this->kleuren->kleur1;
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
switch ($this->ijkpunt->wens) {
|
|
case 1:
|
|
$this->ijkpunt->wenskleur = $this->kleuren->kleur1;
|
|
break;
|
|
case 2:
|
|
$this->ijkpunt->wenskleur = $this->kleuren->kleur2;
|
|
break;
|
|
case 3:
|
|
$this->ijkpunt->wenskleur = $this->kleuren->kleur3;
|
|
break;
|
|
case 4:
|
|
$this->ijkpunt->wenskleur = $this->kleuren->kleur4;
|
|
break;
|
|
default:
|
|
$this->ijkpunt->wenskleur = '#ffffff';
|
|
}
|
|
}
|
|
|
|
private function setAdvies(){
|
|
if(isset($this->ijkpunt->wens) && $this->ijkpunt->huidig < $this->ijkpunt->wens &&
|
|
$this->ijkpunt->huidig != 0 && $this->ijkpunt->wens!= 0 && isset($this->ijkpunt->omschrijving)){
|
|
array_push($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->nummer!= 'gem') {
|
|
$this->ijkpuntenok++;
|
|
}
|
|
}
|
|
|
|
private function setKolombreedte(){
|
|
if($this->aantalY > 1) $this->aantal = $this->aantalY;
|
|
$kolombreedte = floor(($this->rij - $this->standaardorg)/$this->aantal);
|
|
$this->kolombreedte = $kolombreedte . 'px';
|
|
}
|
|
private function setOrgbreedte(){
|
|
if($this->aantalY > 1) $this->aantal = $this->aantalY;
|
|
$orgbreedte = floor($this->rij - ($this->aantal * $this->kolombreedte));
|
|
$this->orgbreedte = $orgbreedte . 'px';
|
|
}
|
|
|
|
|
|
private function setGemiddeldenAfbeeldingen(){
|
|
|
|
$this->gemiddeldenafbeeldingen = [
|
|
"module" => $this->modulenr,
|
|
"leerkrachten" => $this->leerkrachten,
|
|
"labels" => $this->labels,
|
|
"kleuren" => $this->kleuren,
|
|
"vantm" => $this->vantm,
|
|
"ambitie" => $this->ambities,
|
|
"adviezen" => $this->adviezen,
|
|
"ijkpunten" => $this->ijkpunten,
|
|
'ijkpuntenok' => $this->ijkpuntenok,
|
|
'welkehoogste' => $this->welkehoogste,
|
|
'hoogstescore' => round($this->hoogstescore,1),
|
|
'welkelaagste' => $this->welkelaagste,
|
|
'laagstescore' => round($this->laagstescore,1),
|
|
"aantalY" => $this->aantalY,
|
|
"totgem" => $this->gemiddelde->score,
|
|
"orgbreedte" => $this->orgbreedte,
|
|
"kolombreedte" => $this->kolombreedte,
|
|
"aantalscores" => $this->aantalscores
|
|
];
|
|
}
|
|
|
|
} |