ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTestService.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
18 protected $object = null;
19
24 public function __construct(ilObjTest $a_object)
25 {
26 $this->object = $a_object;
27 }
28
36 public function getPassOverviewData($active_id, $short = false)
37 {
38 $passOverwiewData = array();
39
40 global $ilUser;
41
42 $scoredPass = $this->object->_getResultPass($active_id);
43 $lastPass = $this->object->_getPass($active_id);
44
45 $testPercentage = 0;
46 $testReachedPoints = 0;
47 $testMaxPoints = 0;
48
49 for( $pass = 0; $pass <= $lastPass; $pass++)
50 {
51 $passFinishDate = $this->object->getPassFinishDate($active_id, $pass);
52
53 if( $passFinishDate <= 0 )
54 {
55 continue;
56 }
57
58 if( !$short )
59 {
60 $resultData =& $this->object->getTestResult($active_id, $pass);
61
62 if (!$resultData["pass"]["total_max_points"])
63 {
64 $passPercentage = 0;
65 }
66 else
67 {
68 $passPercentage = ($resultData["pass"]["total_reached_points"]/$resultData["pass"]["total_max_points"])*100;
69 }
70
71 $passMaxPoints = $resultData["pass"]["total_max_points"];
72 $passReachedPoints = $resultData["pass"]["total_reached_points"];
73
74 $passAnsweredQuestions = $this->object->getAnsweredQuestionCount($active_id, $pass);
75 $passTotalQuestions = count($resultData) - 2;
76
77 if( $pass == $scoredPass )
78 {
79 $isScoredPass = true;
80
81 if (!$resultData["test"]["total_max_points"])
82 {
83 $testPercentage = 0;
84 }
85 else
86 {
87 $testPercentage = ($resultData["test"]["total_reached_points"]/$resultData["test"]["total_max_points"])*100;
88 }
89
90 $testMaxPoints = $resultData["test"]["total_max_points"];
91 $testReachedPoints = $resultData["test"]["total_reached_points"];
92
93 $passOverwiewData['test'] = array(
94 'active_id' => $active_id,
95 'scored_pass' => $scoredPass,
96 'max_points' => $testMaxPoints,
97 'reached_points' => $testReachedPoints,
98 'percentage' => $testPercentage
99 );
100 }
101 else $isScoredPass = false;
102
103 $passOverwiewData['passes'][] = array(
104 'active_id' => $active_id,
105 'pass' => $pass,
106 'finishdate' => $passFinishDate,
107 'max_points' => $passMaxPoints,
108 'reached_points' => $passReachedPoints,
109 'percentage' => $passPercentage,
110 'answered_questions' => $passAnsweredQuestions,
111 'total_questions' => $passTotalQuestions,
112 'is_scored_pass' => $isScoredPass
113 );
114 }
115 }
116
117 return $passOverwiewData;
118 }
119
128 public function getManScoringQuestionGuiList($activeId, $pass)
129 {
130 include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
131 $manScoringQuestionTypes = ilObjAssessmentFolder::_getManualScoring();
132
133 $testResultData = $this->object->getTestResult($activeId, $pass);
134
135 $manScoringQuestionGuiList = array();
136
137 foreach($testResultData as $questionData)
138 {
139 if( !isset($questionData['qid']) )
140 {
141 continue;
142 }
143
144 if( !isset($questionData['type']) )
145 {
146 throw new ilTestException('no question type given!');
147 }
148
149 $questionGUI = $this->object->createQuestionGUI("", $questionData['qid']);
150
151 if( !in_array($questionGUI->object->getQuestionTypeID(), $manScoringQuestionTypes) )
152 {
153 continue;
154 }
155
156 $manScoringQuestionGuiList[ $questionData['qid'] ] = $questionGUI;
157 }
158
159 return $manScoringQuestionGuiList;
160 }
161
171 public static function isManScoringDone($activeId)
172 {
173 $assessmentSetting = new ilSetting("assessment");
174 return $assessmentSetting->get("manscoring_done_" . $activeId, false);
175 }
176
186 public static function setManScoringDone($activeId, $manScoringDone)
187 {
188 $assessmentSetting = new ilSetting("assessment");
189 $assessmentSetting->set("manscoring_done_" . $activeId, (bool)$manScoringDone);
190 }
191}
192
_getManualScoring()
Retrieve the manual scoring settings.
ILIAS Setting Class.
Base Exception for all Exceptions relating to Modules/Test.
Service class for tests.
getManScoringQuestionGuiList($activeId, $pass)
Returns the list of answers of a users test pass and offers a scoring option.
static setManScoringDone($activeId, $manScoringDone)
stores the flag wether manscoring is done for the given test active or not within the global settings...
__construct(ilObjTest $a_object)
@access public
getPassOverviewData($active_id, $short=false)
@access public @global ilObjUser $ilUser
static isManScoringDone($activeId)
reads the flag wether manscoring is done for the given test active or not from the global settings (s...
global $ilUser
Definition: imgupload.php:15