4require_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);
 
   93        include_once 
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
 
   96                "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
 
  103                    $oldmarks[$row[
"minimum_level"]] = $row;
 
  113            "DELETE FROM tst_mark WHERE test_fi = %s",
 
  117        if (count($this->mark_steps) == 0) {
 
  122        foreach ($this->mark_steps as $key => $value) {
 
  123            $next_id = 
$ilDB->nextId(
'tst_mark');
 
  125                "INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
  126                array(
'integer',
'integer',
'text',
'text',
'float',
'text',
'integer'),
 
  130                    $value->getShortName(),
 
  131                    $value->getOfficialName(),
 
  132                    $value->getMinimumLevel(),
 
  140                "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
 
  148                    $newmarks[$row[
"minimum_level"]] = $row;
 
  151            foreach ($oldmarks as $level => $row) {
 
  152                if (array_key_exists($level, $newmarks)) {
 
  153                    $difffields = array();
 
  154                    foreach ($row as $key => $value) {
 
  155                        if (strcmp($value, $newmarks[$level][$key]) != 0) {
 
  161                                    array_push($difffields, 
"$key: $value => " . $newmarks[$level][$key]);
 
  166                    if (count($difffields)) {
 
  177            foreach ($newmarks as $level => $row) {
 
  178                if (!array_key_exists($level, $oldmarks)) {
 
  203            "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
 
  222        $this->mark_steps = array();
 
  232        function level_sort(
$a, 
$b)
 
  234            if (
$a->getMinimumLevel() == 
$b->getMinimumLevel()) {
 
  235                $res = strcmp(
$a->getShortName(), 
$b->getShortName());
 
  237                    return strcmp(
$a->getOfficialName(), 
$b->getOfficialName());
 
  242            return (
$a->getMinimumLevel() < 
$b->getMinimumLevel()) ? -1 : 1;
 
  244        usort($this->mark_steps, 
'level_sort');
 
  259        if (count($this->mark_steps) < 1) {
 
  262        if (
$index >= count($this->mark_steps)) {
 
  265        unset($this->mark_steps[
$index]);
 
  266        $this->mark_steps = array_values($this->mark_steps);
 
  278        foreach ($indexes as $key => 
$index) {
 
  279            if (!((
$index < 0) or (count($this->mark_steps) < 1))) {
 
  280                unset($this->mark_steps[
$index]);
 
  283        $this->mark_steps = array_values($this->mark_steps);
 
  297        for (
$i = count($this->mark_steps) - 1; 
$i >= 0; 
$i--) {
 
  298            $curMinLevel = $this->mark_steps[
$i]->getMinimumLevel();
 
  300            if ($percentage > $curMinLevel || (
string) $percentage == (
string) $curMinLevel) { 
 
  301                return $this->mark_steps[
$i];
 
  322            "SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level DESC",
 
  329            if ($percentage >= $row[
"minimum_level"]) {
 
  351            "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",
 
  356            if ($percentage >= $row[
"minimum_level"]) {
 
  373    public static function _getMatchingMarkFromActiveId($active_id, $percentage)
 
  379            "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",
 
  386            if ($percentage >= $row[
"minimum_level"]) {
 
  402        $minimum_percentage = 100;
 
  404        for (
$i = 0; 
$i < count($this->mark_steps); 
$i++) {
 
  405            if ($this->mark_steps[
$i]->getMinimumLevel() < $minimum_percentage) {
 
  406                $minimum_percentage = $this->mark_steps[
$i]->getMinimumLevel();
 
  408            if ($this->mark_steps[
$i]->getPassed()) {
 
  413        if ($minimum_percentage != 0) {
 
  414            return "min_percentage_ne_0";
 
  418            return "no_passed_mark";
 
  447    public function logAction($test_id, $logtext = 
"")
 
  452        include_once 
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
 
A class defining mark schemas for assessment test objects.
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.
setMarkSteps($mark_steps)
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.
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.
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
static _getMatchingMark($test_id, $percentage)
Returns the matching mark for a given percentage.
loadFromDb($test_id)
Loads an ASS_MarkSchema object from a database.
checkMarks()
Check the marks for consistency.
getMatchingMark($percentage)
Returns the matching mark for a given percentage.
saveToDb($test_id)
Saves an ASS_MarkSchema object to a database.
__construct()
ASS_MarkSchema constructor.
A class defining marks for assessment test objects.
An exception for terminatinating execution or to throw for unit testing.
static _addLog($user_id, $object_id, $logtext, $question_id="", $original_id="", $test_only=false, $test_ref_id=null)
Add an assessment log entry.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getObjectIDFromTestID($test_id)
Returns the ILIAS test object id for a given test id.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
foreach($_POST as $key=> $value) $res