1<?php 2 3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5 6/** 7 * Class ilTestParticipantScoring 8 * 9 * @author Björn Heyser <info@bjoernheyser.de> 10 * 11 * @package Modules/Test 12 */ 13class ilTestParticipantScoring 14{ 15 /** 16 * @var integer 17 */ 18 protected $activeId; 19 20 /** 21 * @var integer 22 */ 23 protected $scoredPass; 24 25 /** 26 * @var integer 27 */ 28 protected $answeredQuestions; 29 30 /** 31 * @var integer 32 */ 33 protected $totalQuestions; 34 35 /** 36 * @var float 37 */ 38 protected $reachedPoints; 39 40 /** 41 * @var float 42 */ 43 protected $maxPoints; 44 45 /** 46 * @var bool 47 */ 48 protected $passed; 49 50 /** 51 * @var string 52 */ 53 protected $finalMark; 54 55 /** 56 * ilTestParticipantScoring constructor. 57 */ 58 public function __construct() 59 { 60 $this->activeId = 0; 61 $this->scoredPass = 0; 62 $this->answeredQuestions = 0; 63 $this->totalQuestions = 0; 64 $this->reachedPoints = 0.0; 65 $this->maxPoints = 0.0; 66 $this->passed = false; 67 $this->finalMark = ''; 68 } 69 70 71 /** 72 * @return int 73 */ 74 public function getActiveId() : int 75 { 76 return $this->activeId; 77 } 78 79 /** 80 * @param int $activeId 81 */ 82 public function setActiveId(int $activeId) 83 { 84 $this->activeId = $activeId; 85 } 86 87 /** 88 * @return int 89 */ 90 public function getScoredPass() : int 91 { 92 return $this->scoredPass; 93 } 94 95 /** 96 * @param int $scoredPass 97 */ 98 public function setScoredPass(int $scoredPass) 99 { 100 $this->scoredPass = $scoredPass; 101 } 102 103 /** 104 * @return int 105 */ 106 public function getAnsweredQuestions() : int 107 { 108 return $this->answeredQuestions; 109 } 110 111 /** 112 * @param int $answeredQuestions 113 */ 114 public function setAnsweredQuestions(int $answeredQuestions) 115 { 116 $this->answeredQuestions = $answeredQuestions; 117 } 118 119 /** 120 * @return int 121 */ 122 public function getTotalQuestions() : int 123 { 124 return $this->totalQuestions; 125 } 126 127 /** 128 * @param int $totalQuestions 129 */ 130 public function setTotalQuestions(int $totalQuestions) 131 { 132 $this->totalQuestions = $totalQuestions; 133 } 134 135 /** 136 * @return float 137 */ 138 public function getReachedPoints() : float 139 { 140 return $this->reachedPoints; 141 } 142 143 /** 144 * @param float $reachedPoints 145 */ 146 public function setReachedPoints(float $reachedPoints) 147 { 148 $this->reachedPoints = $reachedPoints; 149 } 150 151 /** 152 * @return float 153 */ 154 public function getMaxPoints() : float 155 { 156 return $this->maxPoints; 157 } 158 159 /** 160 * @param float $maxPoints 161 */ 162 public function setMaxPoints(float $maxPoints) 163 { 164 $this->maxPoints = $maxPoints; 165 } 166 167 /** 168 * @return bool 169 */ 170 public function isPassed() : bool 171 { 172 return $this->passed; 173 } 174 175 /** 176 * @param bool $passed 177 */ 178 public function setPassed(bool $passed) 179 { 180 $this->passed = $passed; 181 } 182 183 /** 184 * @return string 185 */ 186 public function getFinalMark() : string 187 { 188 return $this->finalMark; 189 } 190 191 /** 192 * @param string $finalMark 193 */ 194 public function setFinalMark(string $finalMark) 195 { 196 $this->finalMark = $finalMark; 197 } 198 199 /** 200 * @return int 201 */ 202 public function getPercentResult() 203 { 204 if ($this->getMaxPoints() > 0) { 205 return $this->getReachedPoints() / $this->getMaxPoints(); 206 } 207 208 return 0; 209 } 210} 211