ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestNewScoring Class Reference

Scoring class for test-questions. More...

+ Collaboration diagram for ilTestNewScoring:

Public Member Functions

 ilTestNewScoring (&$a_object)
 loadTempTable ($qid)
 checkItemPoints ($postvars)
 saveOrderingItemPoints ($postvars)
 loadOrderingItemPoints ($q_id)
 saveQuestionAndUserResults ($postvars)
 calcReachedPoints ($active_id, $q_id, $orderingItemPoints)
 getSolutionStat ($a_qid, $a_par=0)
 getUserAnswers ($a_qid, $par1=0, $par2=0)
 checkLevenstein (&$a_question, $answerarray, $userans)
 addQuestionAnswer ($solutionId, $qtype)

Data Fields

 $object
 ilTestNewScoring constructor
 $lng
 $ctrl
 $tpl

Detailed Description

Scoring class for test-questions.

Author
Dimitrina Vissoultcheva dviss.nosp@m.@uni.nosp@m.-main.nosp@m.z.de
Version
$Id$

Definition at line 34 of file class.ilTestNewScoring.php.

Member Function Documentation

ilTestNewScoring::addQuestionAnswer (   $solutionId,
  $qtype 
)

Definition at line 555 of file class.ilTestNewScoring.php.

References $ilDB, $query, $res, and $row.

{
global $ilDB;
// Save the changed question
switch ($qtype)
{
case "assClozeTest":
$query = "SELECT value2 FROM tst_temp_solutions WHERE solution_id=". $solutionId;
$res = $ilDB->query($query);
$row = $ilDB->fetchAssoc($res);
$answer = $row["value2"];
break;
case "assTextSubset":
$query = "SELECT value1 FROM tst_temp_solutions WHERE solution_id = $solutionId";
$res = $ilDB->query($query);
$row = $ilDB->fetchAssoc($res);
$answer = $row["value1"];
break;
}
return $answer;
}
ilTestNewScoring::calcReachedPoints (   $active_id,
  $q_id,
  $orderingItemPoints 
)

Definition at line 333 of file class.ilTestNewScoring.php.

References $data, $ilDB, $pass, $points, and ilObjTest\_getResultPass().

Referenced by saveQuestionAndUserResults().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array('integer','integer','integer'),
array($active_id, $q_id, $pass)
);
$user_order = array();
while ($data = $ilDB->fetchAssoc($result))
{
if ((strcmp($data["value1"], "") != 0) && (strcmp($data["value2"], "") != 0))
{
$user_order[$data["value2"]] = $data["value1"];
}
}
ksort($user_order);
$user_order = array_values($user_order);
$points = 0;
foreach ($orderingItemPoints as $index => $value)
{
if (($index) == $user_order[$index])
{
$points = $points + $value;
}
}
return $points;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestNewScoring::checkItemPoints (   $postvars)

Definition at line 80 of file class.ilTestNewScoring.php.

Referenced by saveOrderingItemPoints().

{
$sum = 0;
foreach ($postvars as $key => $value)
{
if (strpos($value, ","))
{
$value = str_replace(",", ".",$value);
}
if (preg_match("/(\d+)_(\d+)/", $key, $matches) && is_numeric($value))
{
if ($matches[2] > 0)
{
$sum += $value;
}
else
{
$maxpoints = $value;
}
}
}
if ($maxpoints == $sum || $sum == 0)
{
return true;
}
else
{
return false;
}
}

+ Here is the caller graph for this function:

ilTestNewScoring::checkLevenstein ( $a_question,
  $answerarray,
  $userans 
)

Definition at line 521 of file class.ilTestNewScoring.php.

{
$question = & $a_question;
$temp = array();
//$syn_separator = $question->object->getSynonymSeparator();
$syn_separator = 0;
foreach($answerarray as $value)
{
$temp = split("_", $value);
if ($syn_separator)
{
$synonymArr = explode($syn_separator,$temp[0]);
for ($i = 0; $i < count($synonymArr); $i++)
{
$OK = $question->object->getTextgapPoints($userans, $synonymArr[$i], $temp[1]);
if (!$OK && ($userans == $synonymArr[$i]))
$OK = 1;
if ($OK)
break;
}
}
else
{
$OK = $question->object->getTextgapPoints($userans, $temp[0], $temp[1]);
if (!$OK && ($userans == $temp[0]))
$OK = 1;
}
if ($OK)
break;
}
return $OK;
}
ilTestNewScoring::getSolutionStat (   $a_qid,
  $a_par = 0 
)

Definition at line 364 of file class.ilTestNewScoring.php.

References $ilDB, $row, and assQuestion\_getQuestionType().

Referenced by ilTestNewScoringGUI\getQuestionStat().

{
global $ilDB;
$values = array();
switch ($qtype)
{
case "assClozeTest":
$rec = $ilDB->queryF("SELECT distinct(value2) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND value1 = %s AND active_id = active_fi",
array('integer', 'text'),
array($a_qid, $a_par)
);
while ($row = $ilDB->fetchAssoc($rec))
array_push($values, $row["value2"]);
break;
case "assMatchingQuestion":
$len = strlen($a_par);
if (strpos($a_par, ".jpg", ($len -4)))
$where = "picture";
else
$where = "definition";
//echo $a_qid."/".$a_par."/".$where;exit;
$select = "SELECT * FROM qpl_a_mdef WHERE question_fi= %s AND $where = %s";
$rec = $ilDB->queryF($select,
array('integer', 'text'),
array($a_qid, $a_par)
);
$row = $ilDB->fetchAssoc($rec);
$value2 = $row["morder"];
array_push($values, $value2);
$rec = $ilDB->queryF("SELECT distinct(value1) FROM tst_temp_solutions WHERE question_fi= %s AND value2 = %s",
array('integer', 'text'),
array($a_qid, $value2)
);
while ($row = $ilDB->fetchAssoc($rec))
array_push($values, $row["value1"]);
break;
case "assMultipleChoice":
case "assSingleChoice":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND value1 = %s AND active_id = active_fi",
array('integer', 'text'),
array($a_qid, $a_par)
);
while ($row = $ilDB->fetchAssoc($rec))
array_push($values, $row["value1"]);
break;
case "assOrderingQuestion":
$rec = $ilDB->queryF("SELECT distinct(value2) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND value1 = %s AND active_id = active_fi",
array('integer', 'text'),
array($a_qid, $a_par)
);
while ($row = $ilDB->fetchAssoc($rec))
array_push($values, $row["value2"]);
break;
case "assOrderingHorizontal":
$rec = $ilDB->queryF("SELECT distinct(value1) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND active_id = active_fi",
array('integer'),
array($a_qid)
);
while ($row = $ilDB->fetchAssoc($rec))
array_push($values, $row["value1"]);
break;
case "assNumeric";
case "assTextSubset":
$rec = $ilDB->queryF("SELECT distinct(value1) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND active_id = active_fi ORDER BY value1",
array('integer'),
array($a_qid)
);
while ($row = $ilDB->fetchAssoc($rec))
{
if ($row["value1"])
array_push($values, $row["value1"]);
}
break;
}
return $values;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestNewScoring::getUserAnswers (   $a_qid,
  $par1 = 0,
  $par2 = 0 
)

Definition at line 449 of file class.ilTestNewScoring.php.

References $ilDB, $row, and assQuestion\_getQuestionType().

Referenced by ilTestNewScoringGUI\getQuestionStat().

{
global $ilDB;
$stat = array("count", "val");
switch ($qtype)
{
case "assClozeTest":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions WHERE question_fi= %s AND value2= %s AND value1 =%s",
array("integer", "text", "text"),
array($a_qid, $par1, $par2)
);
$stat["count"] = $ilDB->numRows($rec);
$row = $ilDB->fetchAssoc($rec);
$stat["val"] = $row["solution_id"];
break;
case "assMatchingQuestion":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions WHERE question_fi= %s AND value1= %s AND value2= %s",
array("integer", "text", "text"),
array($a_qid, $par1, $par2)
);
$rec1 = $ilDB->queryF("SELECT * FROM qpl_a_mterm WHERE question_fi= %s AND term_id=%s",
array("integer", "integer"),
array($a_qid, $par1)
);
$row = $ilDB->fetchAssoc($rec1);
$stat["count"] = $ilDB->numRows($rec);
$stat["val"] = $row["term"];
break;
case "assOrderingQuestion":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND value2=%s AND active_id = active_fi",
array("integer", "text", "text"),
array($a_qid, $par1, $par2)
);
$stat["count"] = $ilDB->numRows($rec);
break;
case "assOrderingHorizontal":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND active_id = active_fi",
array("integer", "text"),
array($a_qid, $par2)
);
$stat["count"] = $ilDB->numRows($rec);
break;
case "assNumeric":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND active_id = active_fi",
array("integer", "text"),
array($a_qid, $par1)
);
$stat["count"] = $ilDB->numRows($rec);
break;
case "assTextSubset":
$rec = $ilDB->queryF("SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND active_id = active_fi",
array("integer", "text"),
array($a_qid, $par1)
);
$row = $ilDB->fetchAssoc($rec);
$stat["count"] = $ilDB->numRows($rec);
$stat["val"] = $row["solution_id"];
break;
}
return ($stat);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestNewScoring::ilTestNewScoring ( $a_object)

Definition at line 51 of file class.ilTestNewScoring.php.

References $ilCtrl, $lng, and $tpl.

{
global $lng, $ilCtrl, $tpl;
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$this->lng =& $lng;
$this->object =& $a_object;
$this->ctrl =& $ilCtrl;
$this->tpl =& $tpl;
}
ilTestNewScoring::loadOrderingItemPoints (   $q_id)

Definition at line 160 of file class.ilTestNewScoring.php.

References $data, and $ilDB.

{
global $ilDB;
$orderingItemPoints = array();
$result = $ilDB->queryF("SELECT * FROM qpl_a_ordering_old WHERE question_fi = %s ORDER BY aorder ASC",
array('integer'),
array($q_id)
);
if ($result->numRows() > 0)
{
while ($data = $ilDB->fetchAssoc($result))
{
array_push($orderingItemPoints, $data["points"]);
}
}
return $orderingItemPoints;
}
ilTestNewScoring::loadTempTable (   $qid)

Definition at line 62 of file class.ilTestNewScoring.php.

References $ilDB.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_temp_solutions WHERE question_fi = %s",
array('integer'), array($qid)
);
if ($ilDB->numRows($result) > 0)
{
$result = $ilDB->queryF("DELETE FROM tst_temp_solutions WHERE question_fi = %s",
array('integer'), array($qid)
);
}
$ilDB->queryF("INSERT INTO tst_temp_solutions (SELECT * FROM tst_solutions WHERE question_fi = %s)",
array('integer'), array($qid)
);
}
ilTestNewScoring::saveOrderingItemPoints (   $postvars)

Definition at line 112 of file class.ilTestNewScoring.php.

References $ilDB, and checkItemPoints().

{
global $ilDB;
$qid = $postvars["id"];
$result = $ilDB->queryF("SELECT * FROM qpl_a_ordering_old WHERE question_fi = %s",
array('integer'), array($qid)
);
if ($ilDB->numRows($result) > 0)
{
$result = $ilDB->queryF("DELETE FROM qpl_a_ordering_old WHERE question_fi = %s",
array('integer'), array($qid)
);
}
if (!$this->checkItemPoints($postvars))
{
return FALSE;
}
foreach ($postvars as $key => $value) // save points
{
if (strpos($value, ","))
{
$value = str_replace(",", ".",$value);
}
if (preg_match("/(\d+)_(\d+)/", $key, $matches) && is_numeric($value))
{
$order = $matches[2];
if ($order > 0)
{
$next_id = $ilDB->nextId('qpl_a_ordering_old');
$affectedRows = $ilDB->manipulateF("INSERT INTO qpl_a_ordering_old (answer_id, question_fi, ".
"points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s)",
array('integer','integer','float','integer', 'integer'),
array(
$next_id,
$qid,
$value,
$order,
time()
)
);
}
}
}
return TRUE;
}

+ Here is the call graph for this function:

ilTestNewScoring::saveQuestionAndUserResults (   $postvars)

Definition at line 179 of file class.ilTestNewScoring.php.

References $_POST, $data, $ilDB, $query, ilObjAssessmentFolder\_addLog(), assQuestion\_getQuestionType(), assQuestion\_setReachedPoints(), calcReachedPoints(), and CLOZE_NUMERIC.

{
global $ilDB, $ilUser;
$qid = $postvars["id"];
$question = $this->object->createQuestionGUI("", $qid);
// get $originalId zum Update der Frage im Fragenpool
$orderingItemPoints = array();
foreach ($postvars as $key => $value) // save points
{
if (!is_array($value) && strpos($value, ","))
{
$value = str_replace(",", ".",$value);
}
if (preg_match("/(\d+)_(\d+)/", $key, $matches))
{
$order = $matches[2];
switch($qtype)
{
case "assClozeTest":
if ($question->object->gaps[$matches[1]]->getType() == CLOZE_NUMERIC)
{
$answer = $question->object->gaps[$matches[1]]->getItem(0);
if ($order == 1)
{
$answer->setLowerBound($value);
}
if ($order == 2)
{
$answer->setUpperBound($value);
}
if ($order == 3)
{
$answer->setAnswertext($value);
}
if ($order == 0)
{
$answer->setPoints($value);
}
}
else
{
$question->object->gaps[$matches[1]]->setItemPoints($order, $value);
}
break;
case "assMultipleChoice":
$answer = $question->object->getAnswer($order);
if (!$matches[1])
{
$answer->points = $value;
}
else
{
$answer->points_unchecked = $value;
}
break;
case "assNumeric":
if ($matches[1] == 1)
{
$question->object->setLowerLimit($value);
}
if ($matches[1] == 2)
{
$question->object->setUpperLimit($value);
}
if ($matches[1] == 0)
{
$question->object->points = $value;
}
break;
case "assMatchingQuestion":
$query = "UPDATE qpl_a_matching SET points= $value WHERE question_fi=$qid AND term_fi = $order";
$ilDB->query($query);
$matching = 1;
break;
case "assOrderingQuestion":
case "assOrderingHorizontal":
if ($order == 0)
{
$question->object->setPoints($value);
}
elseif($order && is_numeric($value))
{
array_push($orderingItemPoints, $value);
}
break;
case "assSingleChoice":
case "assTextSubset":
$answer = $question->object->getAnswer($order);
$answer->points = $value;
break;
}
}
}
// addLog
$logtext = "Neu bewertete Frage";
$testObjId = $this->object->_lookupTestObjIdForQuestionId($qid);
$originalId = $question->object->original_id;
include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
ilObjAssessmentFolder::_addLog($ilUser->id, $testObjId, $logtext, $qid, $originalId);
// Neue Bewertung aller TestTeilnehmer
$maxpoints = $question->object->getMaximumPoints();
$query = "UPDATE qpl_questions SET points='$maxpoints' WHERE question_id=$qid";
$ilDB->query($query);
if ($qtype == "assClozeTest")
{
$question->object->setIdenticalScoring($_POST["ident_scoring"]);
$question->object->setTextgapRating($_POST["textgap_rating"]);
}
if ($qtype == "assTextSubset")
{
$question->object->setTextRating($_POST["text_rating"]);
}
if (!$matching)
{
$question->object->SaveToDb();
}
$data =& $this->object->getCompleteEvaluationData(FALSE);
$foundParticipants =& $data->getParticipants();
foreach ($foundParticipants as $active_id => $userdata)
{
if ($qtype == "assOrderingQuestion" && count($orderingItemPoints) > 0)
{
$reached = $this->calcReachedPoints($active_id, $qid, $orderingItemPoints);
}
else
{
$reached = $question->object->calculateReachedPoints($active_id);
}
// save und log the new Scoring
assQuestion::_setReachedPoints($active_id, $qid, $reached, $maxpoints, 0);
}
}

+ Here is the call graph for this function:

Field Documentation

ilTestNewScoring::$ctrl

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

ilTestNewScoring::$lng

Definition at line 47 of file class.ilTestNewScoring.php.

Referenced by ilTestNewScoring().

ilTestNewScoring::$object

ilTestNewScoring constructor

The constructor takes the test object reference as parameter

Parameters
object$a_objectAssociated ilObjTest class public

Definition at line 46 of file class.ilTestNewScoring.php.

ilTestNewScoring::$tpl

Definition at line 49 of file class.ilTestNewScoring.php.

Referenced by ilTestNewScoring().


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