ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ASS_MarkSchema Class Reference

A class defining mark schemas for assessment test objects. More...

+ Collaboration diagram for ASS_MarkSchema:

Public Member Functions

 __construct ()
 ASS_MarkSchema constructor.
 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.
 addMarkStep ($txt_short="", $txt_official="", $percentage=0, $passed=0)
 Adds a mark step to the mark schema.
 saveToDb ($test_id)
 Saves an ASS_MarkSchema object to a database.
 loadFromDb ($test_id)
 Loads an ASS_MarkSchema object from a database.
 flush ()
 Empties the mark schema and removes all mark steps.
 sort ()
 Sorts the mark schema using the minimum level values.
 deleteMarkStep ($index=0)
 Deletes the mark step with a given index.
 deleteMarkSteps ($indexes)
 Deletes multiple mark steps using their index positions.
 getMatchingMark ($percentage)
 Returns the matching mark for a given percentage.
 _getMatchingMark ($test_id, $percentage)
 Returns the matching mark for a given percentage.
 _getMatchingMarkFromObjId ($a_obj_id, $percentage)
 Returns the matching mark for a given percentage.
 checkMarks ()
 Check the marks for consistency.

Data Fields

 $mark_steps

Detailed Description

A class defining mark schemas for assessment test objects.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
Id:
class.assMarkSchema.php 61161 2015-10-19 15:10:11Z gitmgr

Definition at line 16 of file class.assMarkSchema.php.

Constructor & Destructor Documentation

ASS_MarkSchema::__construct ( )

ASS_MarkSchema constructor.

The constructor takes possible arguments an creates an instance of the ASS_MarkSchema object.

Returns
ASS_MarkSchema

Definition at line 28 of file class.assMarkSchema.php.

{
$this->mark_steps = array();
}

Member Function Documentation

ASS_MarkSchema::_getMatchingMark (   $test_id,
  $percentage 
)

Returns the matching mark for a given percentage.

See Also
$mark_steps
Parameters
integer$test_idThe database id of the test.
double$percentageA percentage value between 0 and 100.
Returns
mixed The mark object, if a matching mark was found, false otherwise.

PhpAssignmentInConditionInspection

Definition at line 326 of file class.assMarkSchema.php.

References $result, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level DESC",
array('integer'),
array($test_id)
);
while ($row = $ilDB->fetchAssoc($result))
{
if ($percentage >= $row["minimum_level"])
{
return $row;
}
}
return FALSE;
}
ASS_MarkSchema::_getMatchingMarkFromObjId (   $a_obj_id,
  $percentage 
)

Returns the matching mark for a given percentage.

See Also
$mark_steps
Parameters
integer$a_obj_idThe database id of the test.
double$percentageA percentage value between 0 and 100.
Returns
mixed The mark object, if a matching mark was found, false otherwise.

Definition at line 355 of file class.assMarkSchema.php.

References $result, and $row.

Referenced by ilObjTestAccess\_isPassed().

{
global $ilDB;
$result = $ilDB->queryF("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",
array('integer'),
array($a_obj_id)
);
while ($row = $ilDB->fetchAssoc($result))
{
if ($percentage >= $row["minimum_level"])
{
return $row;
}
}
return FALSE;
}

+ Here is the caller graph for this function:

ASS_MarkSchema::addMarkStep (   $txt_short = "",
  $txt_official = "",
  $percentage = 0,
  $passed = 0 
)

Adds a mark step to the mark schema.

A new ASS_Mark object will be created and stored in the $mark_steps array.

See Also
$mark_steps
Parameters
string$txt_shortThe short text of the mark.
string$txt_officialThe official text of the mark.
float | integer$percentageThe minimum percentage level reaching the mark.
integer$passedThe passed status of the mark (0 = failed, 1 = passed).

Definition at line 75 of file class.assMarkSchema.php.

Referenced by createSimpleSchema(), and loadFromDb().

{
require_once './Modules/Test/classes/class.assMark.php';
$mark = new ASS_Mark($txt_short, $txt_official, $percentage, $passed);
array_push($this->mark_steps, $mark);
}

+ Here is the caller graph for this function:

ASS_MarkSchema::checkMarks ( )

Check the marks for consistency.

See Also
$mark_steps
Returns
bool|string true if the check succeeds, als a text string containing a language string for an error message

Definition at line 409 of file class.assMarkSchema.php.

{
$minimum_percentage = 100;
$passed = 0;
for ($i = 0; $i < count($this->mark_steps); $i++)
{
if ($this->mark_steps[$i]->getMinimumLevel() < $minimum_percentage)
{
$minimum_percentage = $this->mark_steps[$i]->getMinimumLevel();
}
if ($this->mark_steps[$i]->getPassed())
{
$passed++;
}
}
if ($minimum_percentage != 0)
{
return "min_percentage_ne_0";
}
if ($passed == 0)
{
return "no_passed_mark";
}
return true;
}
ASS_MarkSchema::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.

See Also
$mark_steps
Parameters
string$txt_failed_shortThe short text of the failed mark.
string$txt_failed_officialThe official text of the failed mark.
float | int$percentage_failedThe minimum percentage level reaching the failed mark.
integer$failed_passedIndicates the passed status of the failed mark (0 = failed, 1 = passed).
string$txt_passed_shortThe short text of the passed mark.
string$txt_passed_officialThe official text of the passed mark.
float | int$percentage_passedThe minimum percentage level reaching the passed mark.
integer$passed_passedIndicates the passed status of the passed mark (0 = failed, 1 = passed).

Definition at line 48 of file class.assMarkSchema.php.

References addMarkStep(), and flush().

{
$this->flush();
$this->addMarkStep($txt_failed_short, $txt_failed_official, $percentage_failed, $failed_passed);
$this->addMarkStep($txt_passed_short, $txt_passed_official, $percentage_passed, $passed_passed);
}

+ Here is the call graph for this function:

ASS_MarkSchema::deleteMarkStep (   $index = 0)

Deletes the mark step with a given index.

See Also
$mark_steps
Parameters
integer$indexThe index of the mark step to delete.

Definition at line 265 of file class.assMarkSchema.php.

{
if ($index < 0) return;
if (count($this->mark_steps) < 1) return;
if ($index >= count($this->mark_steps)) return;
unset($this->mark_steps[$index]);
$this->mark_steps = array_values($this->mark_steps);
}
ASS_MarkSchema::deleteMarkSteps (   $indexes)

Deletes multiple mark steps using their index positions.

See Also
$mark_steps
Parameters
array$indexesAn array with all the index positions to delete.

Definition at line 281 of file class.assMarkSchema.php.

{
foreach ($indexes as $key => $index)
{
if (!(($index < 0) or (count($this->mark_steps) < 1)))
{
unset($this->mark_steps[$index]);
}
}
$this->mark_steps = array_values($this->mark_steps);
}
ASS_MarkSchema::flush ( )

Empties the mark schema and removes all mark steps.

See Also
$mark_steps

Definition at line 227 of file class.assMarkSchema.php.

Referenced by createSimpleSchema().

{
$this->mark_steps = array();
}

+ Here is the caller graph for this function:

ASS_MarkSchema::getMatchingMark (   $percentage)

Returns the matching mark for a given percentage.

See Also
$mark_steps
Parameters
double$percentageA percentage value between 0 and 100.
Returns
ASS_Mark|bool The mark object, if a matching mark was found, false otherwise.

Definition at line 302 of file class.assMarkSchema.php.

{
for ($i = count($this->mark_steps) - 1; $i >= 0; $i--)
{
$curMinLevel = $this->mark_steps[$i]->getMinimumLevel();
if( $percentage > $curMinLevel || (string)$percentage == (string)$curMinLevel )
{ // >= does NOT work since PHP is a fucking female float pig !!!!
return $this->mark_steps[$i];
}
}
return false;
}
ASS_MarkSchema::loadFromDb (   $test_id)

Loads an ASS_MarkSchema object from a database.

Parameters
integer$test_idA unique key which defines the test in the database.

PhpAssignmentInConditionInspection

Definition at line 203 of file class.assMarkSchema.php.

References $result, and addMarkStep().

{
global $ilDB;
if (!$test_id) return;
$result = $ilDB->queryF("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
array('integer'),
array($test_id)
);
if ($result->numRows() > 0)
{
while ($data = $ilDB->fetchAssoc($result))
{
$this->addMarkStep($data["short_name"], $data["official_name"], $data["minimum_level"], $data["passed"]);
}
}
}

+ Here is the call graph for this function:

ASS_MarkSchema::saveToDb (   $test_id)

Saves an ASS_MarkSchema object to a database.

Parameters
integer$test_idThe database id of the related test.

PhpAssignmentInConditionInspection

PhpAssignmentInConditionInspection

Definition at line 87 of file class.assMarkSchema.php.

References $lng, $result, $row, ilObjAssessmentFolder\_enabledAssessmentLogging(), and ilObjAssessmentFolder\_getLogLanguage().

{
global $lng;
global $ilDB;
$oldmarks = array();
include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
{
$result = $ilDB->queryF("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
array('integer'),
array($test_id)
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
$oldmarks[$row["minimum_level"]] = $row;
}
}
}
if (!$test_id) return;
// Delete all entries
$ilDB->manipulateF("DELETE FROM tst_mark WHERE test_fi = %s",
array('integer'),
array($test_id)
);
if (count($this->mark_steps) == 0) return;
// Write new datasets
foreach ($this->mark_steps as $key => $value)
{
$next_id = $ilDB->nextId('tst_mark');
$ilDB->manipulateF("INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
array('integer','integer','text','text','float','text','integer'),
array(
$next_id,
$test_id,
$value->getShortName(),
$value->getOfficialName(),
$value->getMinimumLevel(),
$value->getPassed(),
time()
)
);
}
{
$result = $ilDB->queryF("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
array('integer'),
array($test_id)
);
$newmarks = array();
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
$newmarks[$row["minimum_level"]] = $row;
}
}
foreach ($oldmarks as $level => $row)
{
if (array_key_exists($level, $newmarks))
{
$difffields = array();
foreach ($row as $key => $value)
{
if (strcmp($value, $newmarks[$level][$key]) != 0)
{
switch ($key)
{
case "mark_id":
case "tstamp":
break;
default:
array_push($difffields, "$key: $value => " .$newmarks[$level][$key]);
break;
}
}
}
if (count($difffields))
{
$this->logAction($test_id, $lng->txtlng("assessment", "log_mark_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . join($difffields, ", "));
}
}
else
{
$this->logAction($test_id, $lng->txtlng("assessment", "log_mark_removed", ilObjAssessmentFolder::_getLogLanguage()) . ": " .
$lng->txtlng("assessment", "tst_mark_minimum_level", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["minimum_level"] . ", " .
$lng->txtlng("assessment", "tst_mark_short_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["short_name"] . ", " .
$lng->txtlng("assessment", "tst_mark_official_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["official_name"] . ", " .
$lng->txtlng("assessment", "tst_mark_passed", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["passed"]);
}
}
foreach ($newmarks as $level => $row)
{
if (!array_key_exists($level, $oldmarks))
{
$this->logAction($test_id, $lng->txtlng("assessment", "log_mark_added", ilObjAssessmentFolder::_getLogLanguage()) . ": " .
$lng->txtlng("assessment", "tst_mark_minimum_level", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["minimum_level"] . ", " .
$lng->txtlng("assessment", "tst_mark_short_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["short_name"] . ", " .
$lng->txtlng("assessment", "tst_mark_official_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["official_name"] . ", " .
$lng->txtlng("assessment", "tst_mark_passed", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["passed"]);
}
}
}
}

+ Here is the call graph for this function:

ASS_MarkSchema::sort ( )

Sorts the mark schema using the minimum level values.

See Also
$mark_steps

Definition at line 237 of file class.assMarkSchema.php.

References $res.

{
function level_sort($a, $b)
{
if ($a->getMinimumLevel() == $b->getMinimumLevel())
{
$res = strcmp($a->getShortName(), $b->getShortName());
if ($res == 0)
{
return strcmp($a->getOfficialName(), $b->getOfficialName());
}
else
{
return $res;
}
}
return ($a->getMinimumLevel() < $b->getMinimumLevel()) ? -1 : 1;
}
usort($this->mark_steps, 'level_sort');
}

Field Documentation

ASS_MarkSchema::$mark_steps

Definition at line 19 of file class.assMarkSchema.php.


The documentation for this class was generated from the following file: