4 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
30 $this->mark_steps =
array();
49 $txt_failed_short =
"failed",
50 $txt_failed_official =
"failed",
51 $percentage_failed = 0,
53 $txt_passed_short =
"passed",
54 $txt_passed_official =
"passed",
55 $percentage_passed = 50,
59 $this->
addMarkStep($txt_failed_short, $txt_failed_official, $percentage_failed, $failed_passed);
60 $this->
addMarkStep($txt_passed_short, $txt_passed_official, $percentage_passed, $passed_passed);
74 public function addMarkStep($txt_short =
"", $txt_official =
"", $percentage = 0, $passed = 0)
76 require_once
'./Modules/Test/classes/class.assMark.php';
77 $mark =
new ASS_Mark($txt_short, $txt_official, $percentage, $passed);
78 array_push($this->mark_steps, $mark);
92 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
95 "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
102 $oldmarks[
$row[
"minimum_level"]] =
$row;
112 "DELETE FROM tst_mark WHERE test_fi = %s",
116 if (count($this->mark_steps) == 0) {
121 foreach ($this->mark_steps as
$key => $value) {
122 $next_id = $ilDB->nextId(
'tst_mark');
124 "INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
125 array(
'integer',
'integer',
'text',
'text',
'float',
'text',
'integer'),
129 $value->getShortName(),
130 $value->getOfficialName(),
131 $value->getMinimumLevel(),
139 "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
147 $newmarks[
$row[
"minimum_level"]] =
$row;
150 foreach ($oldmarks as $level =>
$row) {
151 if (array_key_exists($level, $newmarks)) {
152 $difffields =
array();
154 if (strcmp($value, $newmarks[$level][
$key]) != 0) {
160 array_push($difffields,
"$key: $value => " . $newmarks[$level][$key]);
165 if (count($difffields)) {
176 foreach ($newmarks as $level =>
$row) {
177 if (!array_key_exists($level, $oldmarks)) {
201 "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
220 $this->mark_steps =
array();
230 function level_sort($a, $b)
232 if ($a->getMinimumLevel() == $b->getMinimumLevel()) {
233 $res = strcmp($a->getShortName(), $b->getShortName());
235 return strcmp($a->getOfficialName(), $b->getOfficialName());
240 return ($a->getMinimumLevel() < $b->getMinimumLevel()) ? -1 : 1;
242 usort($this->mark_steps,
'level_sort');
257 if (count($this->mark_steps) < 1) {
260 if (
$index >= count($this->mark_steps)) {
263 unset($this->mark_steps[
$index]);
264 $this->mark_steps = array_values($this->mark_steps);
277 if (!((
$index < 0) or (count($this->mark_steps) < 1))) {
278 unset($this->mark_steps[
$index]);
281 $this->mark_steps = array_values($this->mark_steps);
295 for (
$i = count($this->mark_steps) - 1;
$i >= 0;
$i--) {
296 $curMinLevel = $this->mark_steps[
$i]->getMinimumLevel();
298 if ($percentage > $curMinLevel || (
string) $percentage == (
string) $curMinLevel) {
299 return $this->mark_steps[
$i];
319 "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level DESC",
326 if ($percentage >=
$row[
"minimum_level"]) {
347 "SELECT tst_mark.* FROM tst_mark, tst_tests WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.obj_fi = %s ORDER BY minimum_level DESC",
352 if ($percentage >=
$row[
"minimum_level"]) {
369 public static function _getMatchingMarkFromActiveId($active_id, $percentage)
374 "SELECT tst_mark.* FROM tst_active, tst_mark, tst_tests WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s ORDER BY minimum_level DESC",
381 if ($percentage >=
$row[
"minimum_level"]) {
397 $minimum_percentage = 100;
399 for (
$i = 0;
$i < count($this->mark_steps);
$i++) {
400 if ($this->mark_steps[
$i]->getMinimumLevel() < $minimum_percentage) {
401 $minimum_percentage = $this->mark_steps[
$i]->getMinimumLevel();
403 if ($this->mark_steps[
$i]->getPassed()) {
408 if ($minimum_percentage != 0) {
409 return "min_percentage_ne_0";
413 return "no_passed_mark";
442 public function logAction($test_id, $logtext =
"")
446 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
static _getObjectIDFromTestID($test_id)
Returns the ILIAS test object id for a given test id.
sort()
Sorts the mark schema using the minimum level values.
flush()
Empties the mark schema and removes all mark steps.
A class defining marks for assessment test objects.
addMarkStep($txt_short="", $txt_official="", $percentage=0, $passed=0)
Adds a mark step to the mark schema.
deleteMarkSteps($indexes)
Deletes multiple mark steps using their index positions.
static _getLogLanguage()
retrieve the log language for assessment logging
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
saveToDb($test_id)
Saves an ASS_MarkSchema object to a database.
foreach($_POST as $key=> $value) $res
static _addLog($user_id, $object_id, $logtext, $question_id="", $original_id="", $test_only=false, $test_ref_id=null)
Add an assessment log entry.
createSimpleSchema( $txt_failed_short="failed", $txt_failed_official="failed", $percentage_failed=0, $failed_passed=0, $txt_passed_short="passed", $txt_passed_official="passed", $percentage_passed=50, $passed_passed=1)
Creates a simple mark schema for two mark steps: failed and passed.
Create styles array
The data for the language used.
__construct()
ASS_MarkSchema constructor.
checkMarks()
Check the marks for consistency.
loadFromDb($test_id)
Loads an ASS_MarkSchema object from a database.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
A class defining mark schemas for assessment test objects.
static _getMatchingMark($test_id, $percentage)
Returns the matching mark for a given percentage.
setMarkSteps($mark_steps)
deleteMarkStep($index=0)
Deletes the mark step with a given index.
getMatchingMark($percentage)
Returns the matching mark for a given percentage.