Public Member Functions | Data Fields

ASS_MarkSchema Class Reference

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

Public Member Functions

 ASS_MarkSchema ()
 ASS_MarkSchema constructor.
 create_simple_schema ($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.
 add_mark_step ($txt_short="", $txt_official="", $percentage=0, $passed=0)
 Adds a mark step to the mark schema.
 saveToDb ($test_id)
 Saves a ASS_MarkSchema object to a database.
 loadFromDb ($test_id)
 Loads a 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.
 delete_mark_step ($index=0)
 Deletes a mark step.
 delete_mark_steps ($indexes)
 Deletes multiple mark steps.
 get_matching_mark ($percentage)
 Returns the matching mark for a given percentage.
 checkMarks ()
 Check the marks for consistency.
 logAction ($test_id, $logtext="")
 Logs an action into the Test&Assessment log.

Data Fields

 $mark_steps

Detailed Description

A class defining mark schemas for assessment test objects.

A class defining mark schemas for assessment test objects

Author:
Helmut Schottmüller <hschottm@tzi.de>
Version:
Id:
class.assMarkSchema.php 6549 2005-01-25 14:45:43Z hschottm

class.assMarkSchema.php Assessment

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


Member Function Documentation

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

Adds a mark step to the mark schema.

Adds a mark step to the mark schema. A new ASS_Mark object will be created and stored in the $mark_steps array.

Parameters:
string $txt_short The short text of the mark
string $txt_official The official text of the mark
double $percentage The minimum percentage level reaching the mark
integer $passed The passed status of the mark (0 = failed, 1 = passed) public
See also:
$mark_steps

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

Referenced by create_simple_schema(), and loadFromDb().

  {
    $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::ASS_MarkSchema (  ) 

ASS_MarkSchema constructor.

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

public

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

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

ASS_MarkSchema::checkMarks (  ) 

Check the marks for consistency.

Check the marks for consistency

Returns:
mixed true if the check succeeds, als a text string containing a language string for an error message public
See also:
$mark_steps

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

        {
                $minimum_percentage = 100;
                $passed = 0;
    for ($i = 0; $i < count($this->mark_steps); $i++) {
                        if ($this->mark_steps[$i]->get_minimum_level() < $minimum_percentage)
                        {
                                $minimum_percentage = $this->mark_steps[$i]->get_minimum_level();
                        }
                        if ($this->mark_steps[$i]->get_passed())
                        {
                                $passed++;
                        }
    }
                if ($minimum_percentage != 0)
                {
                        return "min_percentage_ne_0";
                }
                if ($passed == 0)
                {
                        return "no_passed_mark";
                }
                return true;
        }

ASS_MarkSchema::create_simple_schema ( 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.

Creates a simple mark schema for two mark steps: failed an passed.

Parameters:
string $txt_failed_short The short text of the failed mark
string $txt_failed_official The official text of the failed mark
double $percentage_failed The minimum percentage level reaching the failed mark
integer $failed_passed Indicates the passed status of the failed mark (0 = failed, 1 = passed)
string $txt_passed_short The short text of the passed mark
string $txt_passed_official The official text of the passed mark
double $percentage_passed The minimum percentage level reaching the passed mark
integer $passed_passed Indicates the passed status of the passed mark (0 = failed, 1 = passed) public
See also:
$mark_steps

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

References add_mark_step(), and flush().

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

Here is the call graph for this function:

ASS_MarkSchema::delete_mark_step ( index = 0  ) 

Deletes a mark step.

Deletes the mark step with a given index.

Parameters:
integer $index The index of the mark step to delete public
See also:
$mark_steps

Definition at line 300 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::delete_mark_steps ( indexes  ) 

Deletes multiple mark steps.

Deletes multiple mark steps using their index positions.

Parameters:
array $indexes An array with all the index positions to delete public
See also:
$mark_steps

Definition at line 317 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.

Empties the mark schema and removes all mark steps

public

See also:
$mark_steps

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

Referenced by create_simple_schema().

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

Here is the caller graph for this function:

ASS_MarkSchema::get_matching_mark ( percentage  ) 

Returns the matching mark for a given percentage.

Returns the matching mark for a given percentage

Parameters:
double $percentage A percentage value between 0 and 100
Returns:
mixed The mark object, if a matching mark was found, false otherwise public
See also:
$mark_steps

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

                                          {
    for ($i = count($this->mark_steps) - 1; $i >= 0; $i--) {
      if ($percentage >= $this->mark_steps[$i]->get_minimum_level()) {
        return $this->mark_steps[$i];
      }
    }
                return false;
  }

ASS_MarkSchema::loadFromDb ( test_id  ) 

Loads a ASS_MarkSchema object from a database.

Loads a ASS_MarkSchema object from a database (experimental)

Parameters:
integer $test_id A unique key which defines the test in the database public

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

References $data, $ilias, $query, $result, and add_mark_step().

  {
                global $ilias;
                $db =& $ilias->db->db;
                
    if (!$test_id) return;
    $query = sprintf("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
      $db->quote($test_id)
    );

    $result = $db->query($query);
    if (strcmp(strtolower(get_class($result)), db_result) == 0) {
      while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) {
        $this->add_mark_step($data->short_name, $data->official_name, $data->minimum_level, $data->passed);
      }
    }
  }

Here is the call graph for this function:

ASS_MarkSchema::logAction ( test_id,
logtext = "" 
)

Logs an action into the Test&Assessment log.

Logs an action into the Test&Assessment log

Parameters:
integer $test_id The database id of the test
string $logtext The log text public

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

References $ilUser, $query, $result, and ilObjTest::_getObjectIDFromTestID().

Referenced by saveToDb().

        {
                global $ilUser, $ilDB;

                $query = sprintf("INSERT INTO ass_log (ass_log_id, user_fi, obj_fi, logtext, question_fi, original_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, NULL, NULL)",
                        $ilDB->quote($ilUser->id . ""),
                        $ilDB->quote(ilObjTest::_getObjectIDFromTestID($test_id) . ""),
                        $ilDB->quote($logtext . "")
                );
                $result = $ilDB->query($query);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ASS_MarkSchema::saveToDb ( test_id  ) 

Saves a ASS_MarkSchema object to a database.

Saves a ASS_MarkSchema object to a database (experimental)

Parameters:
integer $test_id The database id of the related test public

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

References $ilias, $lng, $query, $result, $row, ilObjAssessmentFolder::_enabledAssessmentLogging(), and logAction().

  {
                global $ilias, $lng;
                $db =& $ilias->db->db;

                $oldmarks = array();
                if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                {
                        $query = sprintf("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
                                $db->quote($test_id)
                        );
                        $result = $db->query($query);
                        if ($result->numRows())
                        {
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        $oldmarks[$row["minimum_level"]] = $row;
                                }
                        }
                }
                
    if (!$test_id) return;
    // Delete all entries
    $query = sprintf("DELETE FROM tst_mark WHERE test_fi = %s",
      $db->quote($test_id)
    );
    $result = $db->query($query);
    if (count($this->mark_steps) == 0) return;
    
    // Write new datasets
    foreach ($this->mark_steps as $key => $value) 
                {
      $query = sprintf("INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
        $db->quote($test_id),
        $db->quote($value->get_short_name()), 
        $db->quote($value->get_official_name()), 
        $db->quote($value->get_minimum_level()),
        $db->quote(sprintf("%d", $value->get_passed()))
      );
      $result = $db->query($query);
      if ($result == DB_OK) {
      }
    }
                if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                {
                        $query = sprintf("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
                                $db->quote($test_id)
                        );
                        $result = $db->query($query);
                        $newmarks = array();
                        if ($result->numRows())
                        {
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        $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 "TIMESTAMP":
                                                                        break;
                                                                default:
                                                                        array_push($difffields, "$key: $value => " .$newmarks[$level][$key]); 
                                                                        break;
                                                        }
                                                }
                                        }
                                        if (count($difffields))
                                        {
                                                $this->logAction($test_id, $lng->txt("log_mark_changed") . ": " . join($difffields, ", "));
                                        }
                                }
                                else
                                {
                                        $this->logAction($test_id, $lng->txt("log_mark_removed") . ": " . 
                                                $lng->txt("tst_mark_minimum_level") . " = " . $row["minimum_level"] . ", " .
                                                $lng->txt("tst_mark_short_form") . " = " . $row["short_name"] . ", " .
                                                $lng->txt("tst_mark_official_form") . " = " . $row["official_name"] . ", " .
                                                $lng->txt("tst_mark_passed") . " = " . $row["passed"]);
                                }
                        }
                        foreach ($newmarks as $level => $row)
                        {
                                if (!array_key_exists($level, $oldmarks))
                                {
                                        $this->logAction($test_id, $lng->txt("log_mark_added") . ": " . 
                                                $lng->txt("tst_mark_minimum_level") . " = " . $row["minimum_level"] . ", " .
                                                $lng->txt("tst_mark_short_form") . " = " . $row["short_name"] . ", " .
                                                $lng->txt("tst_mark_official_form") . " = " . $row["official_name"] . ", " .
                                                $lng->txt("tst_mark_passed") . " = " . $row["passed"]);
                                }
                        }
                }
  }

Here is the call graph for this function:

ASS_MarkSchema::sort (  ) 

Sorts the mark schema using the minimum level values.

Sorts the mark schema using the minimum level values

public

See also:
$mark_steps

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

References $res.

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


Field Documentation

ASS_MarkSchema::$mark_steps

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


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