Class for Java Applet Questions. More...
Inheritance diagram for ASS_JavaApplet:
Collaboration diagram for ASS_JavaApplet:Public Member Functions | |
| ASS_JavaApplet ($title="", $comment="", $author="", $owner=-1, $question="", $javaapplet_filename="") | |
| ASS_JavaApplet constructor. | |
| to_xml ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false) | |
| Returns a QTI xml representation of the question. | |
| from_xml ($xml_text) | |
| Imports a question from XML. | |
| splitParams ($params="") | |
| Sets the applet parameters from a parameter string containing all parameters in a list. | |
| buildParams () | |
| Returns a string containing the applet parameters. | |
| buildParamsOnly () | |
| Returns a string containing the additional applet parameters. | |
| isComplete () | |
| Returns true, if a imagemap question is complete for use. | |
| saveToDb ($original_id="") | |
| Saves a ASS_JavaApplet object to a database. | |
| loadFromDb ($question_id) | |
| Loads a ASS_JavaApplet object from a database. | |
| duplicate ($for_test=true, $title="", $author="", $owner="") | |
| Duplicates an ASS_JavaApplet. | |
| duplicateApplet ($question_id) | |
| getQuestion () | |
| Gets the multiple choice question. | |
| setQuestion ($question="") | |
| Sets the question text. | |
| getMaximumPoints () | |
| Returns the maximum points, a learner can reach answering the question. | |
| getJavaCode () | |
| Returns the java applet code parameter. | |
| setJavaCode ($java_code="") | |
| Sets the java applet code parameter. | |
| getJavaWidth () | |
| Returns the java applet width parameter. | |
| setJavaWidth ($java_width="") | |
| Sets the java applet width parameter. | |
| getJavaHeight () | |
| Returns the java applet height parameter. | |
| setJavaHeight ($java_height="") | |
| Sets the java applet height parameter. | |
| calculateReachedPoints ($user_id, $test_id) | |
| Returns the points, a learner has reached answering the question. | |
| getReachedInformation ($user_id, $test_id) | |
| Returns the evaluation data, a learner has entered to answer the question. | |
| addParameter ($name="", $value="") | |
| Adds a new parameter value to the parameter list. | |
| addParameterAtIndex ($index=0, $name="", $value="") | |
| Adds a new parameter value to the parameter list at a given index. | |
| removeParameter ($name) | |
| Removes a parameter value from the parameter list. | |
| getParameter ($index) | |
| Returns the paramter at a given index. | |
| getParameterIndex ($name) | |
| Returns the index of an applet parameter. | |
| getParameterCount () | |
| Returns the number of additional applet parameters. | |
| flushParams () | |
| Removes all applet parameters. | |
| saveWorkingData ($test_id, $limit_to=LIMIT_NO_LIMIT) | |
| Saves the learners input of the question to the database. | |
| getJavaAppletFilename () | |
| Gets the java applet file name. | |
| setJavaAppletFilename ($javaapplet_filename, $javaapplet_tempfilename="") | |
| Sets the java applet file name. | |
| syncWithOriginal () | |
| getQuestionType () | |
| Returns the question type of the question. | |
Data Fields | |
| $question | |
| $javaapplet_filename | |
| $java_code | |
| $java_width | |
| $java_height | |
| $parameters | |
Class for Java Applet Questions.
ASS_JavaApplet is a class for Java Applet Questions.
class.assJavaApplet.php Assessment
Definition at line 37 of file class.assJavaApplet.php.
| ASS_JavaApplet::addParameter | ( | $ | name = "", |
|
| $ | value = "" | |||
| ) |
Adds a new parameter value to the parameter list.
Adds a new parameter value to the parameter list
| string | $name The name of the parameter value | |
| string | $value The value of the parameter value public |
Definition at line 1084 of file class.assJavaApplet.php.
References getParameterIndex().
Referenced by from_xml().
{
$index = $this->getParameterIndex($name);
if ($index > -1)
{
$this->parameters[$index] = array("name" => $name, "value" => $value);
}
else
{
array_push($this->parameters, array("name" => $name, "value" => $value));
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ASS_JavaApplet::addParameterAtIndex | ( | $ | index = 0, |
|
| $ | name = "", |
|||
| $ | value = "" | |||
| ) |
Adds a new parameter value to the parameter list at a given index.
Adds a new parameter value to the parameter list at a given index
| integer | $index The index at which the parameter should be inserted | |
| string | $name The name of the parameter value | |
| string | $value The value of the parameter value public |
Definition at line 1108 of file class.assJavaApplet.php.
{
$this->parameters[$index] = array("name" => $name, "value" => $value);
}
| ASS_JavaApplet::ASS_JavaApplet | ( | $ | title = "", |
|
| $ | comment = "", |
|||
| $ | author = "", |
|||
| $ | owner = -1, |
|||
| $ | question = "", |
|||
| $ | javaapplet_filename = "" | |||
| ) |
ASS_JavaApplet constructor.
The constructor takes possible arguments an creates an instance of the ASS_JavaApplet object.
| string | $title A title string to describe the question | |
| string | $comment A comment string to describe the question | |
| string | $author A string containing the name of the questions author | |
| integer | $owner A numerical ID to identify the owner/creator | |
| string | $question The question string of the multiple choice question | |
| integer | $response Indicates the response type of the multiple choice question | |
| integer | $output_type The output order of the multiple choice answers public |
Definition at line 108 of file class.assJavaApplet.php.
References ASS_Question::$author, ASS_Question::$comment, $javaapplet_filename, ASS_Question::$owner, $question, ASS_Question::$title, and ASS_Question::ASS_Question().
{
$this->ASS_Question($title, $comment, $author, $owner);
$this->question = $question;
$this->javaapplet_filename = $javaapplet_filename;
$this->parameters = array();
}
Here is the call graph for this function:| ASS_JavaApplet::buildParams | ( | ) |
Returns a string containing the applet parameters.
Returns a string containing the applet parameters. This is used for saving the applet data to database
Definition at line 598 of file class.assJavaApplet.php.
Referenced by saveToDb().
{
$params_array = array();
if ($this->java_code)
{
array_push($params_array, "java_code=$this->java_code");
}
if ($this->java_width)
{
array_push($params_array, "java_width=$this->java_width");
}
if ($this->java_height)
{
array_push($params_array, "java_height=$this->java_height");
}
foreach ($this->parameters as $key => $value)
{
array_push($params_array, "param_name_$key=" . $value["name"]);
array_push($params_array, "param_value_$key=" . $value["value"]);
}
return join($params_array, "<separator>");
}
Here is the caller graph for this function:| ASS_JavaApplet::buildParamsOnly | ( | ) |
Returns a string containing the additional applet parameters.
Returns a string containing the additional applet parameters
Definition at line 629 of file class.assJavaApplet.php.
Referenced by to_xml().
{
$params_array = array();
if ($this->java_code)
{
array_push($params_array, "java_code=$this->java_code");
}
foreach ($this->parameters as $key => $value)
{
array_push($params_array, "param_name_$key=" . $value["name"]);
array_push($params_array, "param_value_$key=" . $value["value"]);
}
return join($params_array, "<separator>");
}
Here is the caller graph for this function:| ASS_JavaApplet::calculateReachedPoints | ( | $ | user_id, | |
| $ | test_id | |||
| ) |
Returns the points, a learner has reached answering the question.
Returns the points, a learner has reached answering the question The points are calculated from the given answers including checks for all special scoring options in the test container.
| integer | $user_id The database ID of the learner | |
| integer | $test_id The database Id of the test containing the question public |
Definition at line 994 of file class.assJavaApplet.php.
References $data, ASS_Question::$points, $query, $result, $row, ASS_Question::$test_id, $user_id, ASS_Question::getId(), and getMaximumPoints().
{
global $ilDB;
$found_values = array();
$query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$ilDB->quote($user_id),
$ilDB->quote($test_id),
$ilDB->quote($this->getId())
);
$result = $ilDB->query($query);
$points = 0;
while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
$points += $data->points;
}
// check for special scoring options in test
$query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s",
$ilDB->quote($test_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
if ($row["count_system"] == 1)
{
if ($points != $this->getMaximumPoints())
{
$points = 0;
}
}
}
else
{
$points = 0;
}
return $points;
}
Here is the call graph for this function:| ASS_JavaApplet::duplicate | ( | $ | for_test = true, |
|
| $ | title = "", |
|||
| $ | author = "", |
|||
| $ | owner = "" | |||
| ) |
Duplicates an ASS_JavaApplet.
Duplicates an ASS_JavaApplet
public
Definition at line 809 of file class.assJavaApplet.php.
References ASS_Question::$author, ASS_Question::$owner, ASS_Question::$title, and ASS_Question::_getOriginalId().
{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$clone = $this;
include_once ("./assessment/classes/class.assQuestion.php");
$original_id = ASS_Question::_getOriginalId($this->id);
$clone->id = -1;
if ($title)
{
$clone->setTitle($title);
}
if ($author)
{
$clone->setAuthor($author);
}
if ($owner)
{
$clone->setOwner($owner);
}
if ($for_test)
{
$clone->saveToDb($original_id);
}
else
{
$clone->saveToDb();
}
// copy question page content
$clone->copyPageOfQuestion($original_id);
// duplicate the image
$clone->duplicateApplet($original_id);
return $clone->id;
}
Here is the call graph for this function:| ASS_JavaApplet::duplicateApplet | ( | $ | question_id | ) |
Definition at line 850 of file class.assJavaApplet.php.
References getJavaAppletFilename(), ASS_Question::getJavaPath(), and ilUtil::makeDirParents().
{
$javapath = $this->getJavaPath();
$javapath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $javapath);
if (!file_exists($javapath))
{
ilUtil::makeDirParents($javapath);
}
$filename = $this->getJavaAppletFilename();
if (!copy($javapath_original . $filename, $javapath . $filename)) {
print "java applet could not be duplicated!!!! ";
}
}
Here is the call graph for this function:| ASS_JavaApplet::flushParams | ( | ) |
Removes all applet parameters.
Removes all applet parameters
public
Definition at line 1197 of file class.assJavaApplet.php.
{
$this->parameters = array();
}
| ASS_JavaApplet::from_xml | ( | $ | xml_text | ) |
Imports a question from XML.
Sets the attributes of the question from the XML text passed as argument
Definition at line 368 of file class.assJavaApplet.php.
References ASS_Question::$comment, $idx, $ilErr, $result, ASS_Question::$shuffle, addParameter(), domxml_open_mem(), ASS_Question::getId(), ASS_Question::getJavaPath(), ilUtil::makeDirParents(), saveToDb(), ASS_Question::setAuthor(), ASS_Question::setComment(), ASS_Question::setEstimatedWorkingTime(), ASS_Question::setPoints(), setQuestion(), ASS_Question::setSuggestedSolution(), and ASS_Question::setTitle().
{
$result = false;
if (!empty($this->domxml))
{
$this->domxml->free();
}
$xml_text = preg_replace("/>\s*?</", "><", $xml_text);
$this->domxml = domxml_open_mem($xml_text);
if (!empty($this->domxml))
{
$root = $this->domxml->document_element();
$item = $root->first_child();
$this->setTitle($item->get_attribute("title"));
$this->gaps = array();
$itemnodes = $item->child_nodes();
$materials = array();
$images = array();
$shuffle = "";
foreach ($itemnodes as $index => $node)
{
switch ($node->node_name())
{
case "qticomment":
$comment = $node->get_content();
if (strpos($comment, "ILIAS Version=") !== false)
{
}
elseif (strpos($comment, "Questiontype=") !== false)
{
}
elseif (strpos($comment, "Author=") !== false)
{
$comment = str_replace("Author=", "", $comment);
$this->setAuthor($comment);
}
else
{
$this->setComment($comment);
}
break;
case "itemmetadata":
$md_array = array();
$metanodes = $node->child_nodes();
foreach ($metanodes as $metanode)
{
switch ($metanode->node_name())
{
case "qtimetadata":
$metafields = $metanode->child_nodes();
foreach ($metafields as $metafield)
{
switch ($metafield->node_name())
{
case "qtimetadatafield":
$metafieldlist = $metafield->child_nodes();
$md = array("label" => "", "entry" => "");
foreach ($metafieldlist as $attr)
{
switch ($attr->node_name())
{
case "fieldlabel":
$md["label"] = $attr->get_content();
break;
case "fieldentry":
$md["entry"] = $attr->get_content();
break;
}
}
array_push($md_array, $md);
break;
}
}
break;
}
}
foreach ($md_array as $md)
{
switch ($md["label"])
{
case "ILIAS_VERSION":
break;
case "QUESTIONTYPE":
break;
case "AUTHOR":
$this->setAuthor($md["entry"]);
break;
}
}
break;
case "duration":
$iso8601period = $node->get_content();
if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
{
$this->setEstimatedWorkingTime($matches[4], $matches[5], $matches[6]);
}
break;
case "presentation":
$flow = $node->first_child();
$flownodes = $flow->child_nodes();
foreach ($flownodes as $idx => $flownode)
{
if (strcmp($flownode->node_name(), "material") == 0)
{
$childnodes = $flownode->child_nodes();
foreach ($childnodes as $childnodeindex => $childnode)
{
if (strcmp($childnode->get_attribute("label"), "suggested_solution") == 0)
{
$mattype = $childnode->first_child();
if (strcmp($mattype->node_name(), "mattext") == 0)
{
$suggested_solution = $mattype->get_content();
if ($suggested_solution)
{
if ($this->getId() < 1)
{
$this->saveToDb();
}
$this->setSuggestedSolution($suggested_solution, 0, true);
}
}
}
elseif (strcmp($childnode->node_name(), "mattext") == 0)
{
if (!$childnode->has_attribute("label"))
{
$this->setQuestion($childnode->get_content());
}
elseif (strcmp($childnode->get_attribute("label"), "points") == 0)
{
$this->setPoints($childnode->get_content());
}
elseif (strcmp($childnode->get_attribute("label"), "java_code") == 0)
{
$this->java_code = $childnode->get_content();
}
elseif (strcmp($childnode->get_attribute("label"), "") != 0)
{
$this->addParameter($childnode->get_attribute("label"), $childnode->get_content());
}
}
elseif (strcmp($childnode->node_name(), "matapplet") == 0)
{
if (strcmp($childnode->get_attribute("label"), "applet data") == 0)
{
$this->javaapplet_filename = $childnode->get_attribute("uri");
$this->java_height = $childnode->get_attribute("height");
$this->java_width = $childnode->get_attribute("width");
$java = base64_decode($childnode->get_content());
}
}
}
}
}
break;
}
}
if ($this->javaapplet_filename)
{
$this->saveToDb();
$javapath = $this->getJavaPath();
if (!file_exists($javapath))
{
ilUtil::makeDirParents($javapath);
}
$javapath .= $this->javaapplet_filename;
$fh = fopen($javapath, "wb");
if ($fh == false)
{
global $ilErr;
$ilErr->raiseError($this->lng->txt("error_save_java_file") . ": $php_errormsg", $ilErr->MESSAGE);
return;
}
$javafile = fwrite($fh, $java);
fclose($fh);
}
$result = true;
}
return $result;
}
Here is the call graph for this function:| ASS_JavaApplet::getJavaAppletFilename | ( | ) |
Gets the java applet file name.
Gets the java applet file name
Definition at line 1275 of file class.assJavaApplet.php.
Referenced by duplicateApplet(), and to_xml().
{
return $this->javaapplet_filename;
}
Here is the caller graph for this function:| ASS_JavaApplet::getJavaCode | ( | ) |
Returns the java applet code parameter.
Returns the java applet code parameter
Definition at line 913 of file class.assJavaApplet.php.
{
return $this->java_code;
}
| ASS_JavaApplet::getJavaHeight | ( | ) |
Returns the java applet height parameter.
Returns the java applet height parameter
Definition at line 965 of file class.assJavaApplet.php.
Referenced by to_xml().
{
return $this->java_height;
}
Here is the caller graph for this function:| ASS_JavaApplet::getJavaWidth | ( | ) |
Returns the java applet width parameter.
Returns the java applet width parameter
Definition at line 939 of file class.assJavaApplet.php.
Referenced by to_xml().
{
return $this->java_width;
}
Here is the caller graph for this function:| ASS_JavaApplet::getMaximumPoints | ( | ) |
Returns the maximum points, a learner can reach answering the question.
Returns the maximum points, a learner can reach answering the question
public
Reimplemented from ASS_Question.
Definition at line 900 of file class.assJavaApplet.php.
Referenced by calculateReachedPoints().
{
return $this->points;
}
Here is the caller graph for this function:| ASS_JavaApplet::getParameter | ( | $ | index | ) |
Returns the paramter at a given index.
Returns the paramter at a given index
| intege | $index The index value of the parameter |
Definition at line 1144 of file class.assJavaApplet.php.
{
if (($index < 0) or ($index >= count($this->parameters)))
{
return undef;
}
return $this->parameters[$index];
}
| ASS_JavaApplet::getParameterCount | ( | ) |
Returns the number of additional applet parameters.
Returns the number of additional applet parameters
Definition at line 1184 of file class.assJavaApplet.php.
{
return count($this->parameters);
}
| ASS_JavaApplet::getParameterIndex | ( | $ | name | ) |
Returns the index of an applet parameter.
Returns the index of an applet parameter
| string | $name The name of the parameter value |
Definition at line 1163 of file class.assJavaApplet.php.
Referenced by addParameter().
{
foreach ($this->parameters as $key => $value)
{
if (array_key_exists($name, $value))
{
return $key;
}
}
return -1;
}
Here is the caller graph for this function:| ASS_JavaApplet::getQuestion | ( | ) |
Gets the multiple choice question.
Gets the question string of the ASS_JavaApplet object
Definition at line 873 of file class.assJavaApplet.php.
Referenced by to_xml().
{
return $this->question;
}
Here is the caller graph for this function:| ASS_JavaApplet::getQuestionType | ( | ) |
Returns the question type of the question.
Returns the question type of the question
Definition at line 1354 of file class.assJavaApplet.php.
Referenced by saveToDb().
{
return 7;
}
Here is the caller graph for this function:| ASS_JavaApplet::getReachedInformation | ( | $ | user_id, | |
| $ | test_id | |||
| ) |
Returns the evaluation data, a learner has entered to answer the question.
Returns the evaluation data, a learner has entered to answer the question
| integer | $user_id The database ID of the learner | |
| integer | $test_id The database Id of the test containing the question public |
Definition at line 1043 of file class.assJavaApplet.php.
References $counter, $data, $query, $result, ASS_Question::$test_id, $user_id, and ASS_Question::getId().
Referenced by to_xml().
{
$found_values = array();
$query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$this->ilias->db->quote($user_id),
$this->ilias->db->quote($test_id),
$this->ilias->db->quote($this->getId())
);
$result = $this->ilias->db->query($query);
$counter = 1;
$user_result = array();
while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
$true = 0;
if ($data->points > 0)
{
$true = 1;
}
$solution = array(
"order" => "$counter",
"points" => "$data->points",
"true" => "$true",
"value1" => "$data->value1",
"value2" => "$data->value2",
);
$counter++;
array_push($user_result, $solution);
}
return $user_result;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ASS_JavaApplet::isComplete | ( | ) |
Returns true, if a imagemap question is complete for use.
Returns true, if a imagemap question is complete for use
Reimplemented from ASS_Question.
Definition at line 652 of file class.assJavaApplet.php.
Referenced by saveToDb(), and syncWithOriginal().
{
if (($this->title) and ($this->author) and ($this->question) and ($this->javaapplet_filename) and ($this->java_width) and ($this->java_height) and ($this->points != ""))
{
return true;
}
else
{
return false;
}
}
Here is the caller graph for this function:| ASS_JavaApplet::loadFromDb | ( | $ | question_id | ) |
Loads a ASS_JavaApplet object from a database.
Loads a ASS_JavaApplet object from a database (experimental)
| object | $db A pear DB object | |
| integer | $question_id A unique key which defines the multiple choice test in the database public |
Reimplemented from ASS_Question.
Definition at line 768 of file class.assJavaApplet.php.
References $data, ASS_Question::$ilias, $query, $result, ASS_Question::setEstimatedWorkingTime(), ASS_Question::setShuffle(), and splitParams().
{
global $ilias;
$db = & $ilias->db;
$query = sprintf("SELECT * FROM qpl_questions WHERE question_id = %s",
$db->quote($question_id)
);
$result = $db->query($query);
if (strcmp(strtolower(get_class($result)), db_result) == 0)
{
if ($result->numRows() == 1)
{
$data = $result->fetchRow(DB_FETCHMODE_OBJECT);
$this->id = $question_id;
$this->title = $data->title;
$this->comment = $data->comment;
$this->obj_id = $data->obj_fi;
$this->author = $data->author;
$this->points = $data->points;
$this->owner = $data->owner;
$this->original_id = $data->original_id;
$this->javaapplet_filename = $data->image_file;
$this->question = $data->question_text;
$this->solution_hint = $data->solution_hint;
$this->splitParams($data->params);
$this->setShuffle($data->shuffle);
$this->setEstimatedWorkingTime(substr($data->working_time, 0, 2), substr($data->working_time, 3, 2), substr($data->working_time, 6, 2));
}
}
parent::loadFromDb($question_id);
}
Here is the call graph for this function:| ASS_JavaApplet::removeParameter | ( | $ | name | ) |
Removes a parameter value from the parameter list.
Removes a parameter value from the parameter list
| string | $name The name of the parameter value public |
Definition at line 1122 of file class.assJavaApplet.php.
{
foreach ($this->parameters as $key => $value)
{
if (strcmp($name, $value["name"]) == 0)
{
array_splice($this->parameters, $key, 1);
return;
}
}
}
| ASS_JavaApplet::saveToDb | ( | $ | original_id = "" |
) |
Saves a ASS_JavaApplet object to a database.
Saves a ASS_JavaApplet object to a database (experimental)
| object | $db A pear DB object public |
Reimplemented from ASS_Question.
Definition at line 673 of file class.assJavaApplet.php.
References ASS_Question::$ilias, $params, $query, $result, buildParams(), ASS_Question::createPageObject(), ASS_Question::getEstimatedWorkingTime(), getQuestionType(), ASS_Question::getTestId(), ASS_Question::insertIntoTest(), and isComplete().
Referenced by from_xml().
{
global $ilias;
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
$db = & $ilias->db;
$params = $this->buildParams();
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
if ($original_id)
{
$original_id = $db->quote($original_id);
}
else
{
$original_id = "NULL";
}
if ($this->id == -1)
{
// Neuen Datensatz schreiben
$now = getdate();
$question_type = $this->getQuestionType();
$created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
$query = sprintf("INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, points, working_time, shuffle, complete, image_file, params, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
$db->quote($question_type . ""),
$db->quote($this->obj_id . ""),
$db->quote($this->title . ""),
$db->quote($this->comment . ""),
$db->quote($this->author . ""),
$db->quote($this->owner . ""),
$db->quote($this->question . ""),
$db->quote($this->points . ""),
$db->quote($estw_time . ""),
$db->quote($this->shuffle . ""),
$db->quote($complete . ""),
$db->quote($this->javaapplet_filename . ""),
$db->quote($params . ""),
$db->quote($created . ""),
$original_id
);
$result = $db->query($query);
if ($result == DB_OK)
{
$this->id = $this->ilias->db->getLastInsertId();
// create page object of question
$this->createPageObject();
// Falls die Frage in einen Test eingef�gt werden soll, auch diese Verbindung erstellen
if ($this->getTestId() > 0)
{
$this->insertIntoTest($this->getTestId());
}
}
}
else
{
// Vorhandenen Datensatz aktualisieren
$query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %s, working_time=%s, shuffle = %s, complete = %s, image_file = %s, params = %s WHERE question_id = %s",
$db->quote($this->obj_id. ""),
$db->quote($this->title . ""),
$db->quote($this->comment . ""),
$db->quote($this->author . ""),
$db->quote($this->question . ""),
$db->quote($this->points . ""),
$db->quote($estw_time . ""),
$db->quote($this->shuffle . ""),
$db->quote($complete . ""),
$db->quote($this->javaapplet_filename . ""),
$db->quote($params . ""),
$db->quote($this->id . "")
);
$result = $db->query($query);
}
parent::saveToDb($original_id);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ASS_JavaApplet::saveWorkingData | ( | $ | test_id, | |
| $ | limit_to = LIMIT_NO_LIMIT | |||
| ) |
Saves the learners input of the question to the database.
Saves the learners input of the question to the database
| integer | $test_id The database id of the test containing this question |
Reimplemented from ASS_Question.
Definition at line 1212 of file class.assJavaApplet.php.
References ASS_Question::$test_id.
{
parent::saveWorkingData($test_id);
return true;
/* global $ilDB;
global $ilUser;
$db =& $ilDB->db;
if ($this->response == RESPONSE_SINGLE) {
$query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$db->quote($ilUser->id),
$db->quote($test_id),
$db->quote($this->getId())
);
$result = $db->query($query);
$row = $result->fetchRow(DB_FETCHMODE_OBJECT);
$update = $row->solution_id;
if ($update) {
$query = sprintf("UPDATE tst_solutions SET value1 = %s WHERE solution_id = %s",
$db->quote($_POST["multiple_choice_result"]),
$db->quote($update)
);
} else {
$query = sprintf("INSERT INTO tst_solutions (solution_id, user_fi, test_fi, question_fi, value1, value2, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL, NULL)",
$db->quote($ilUser->id),
$db->quote($test_id),
$db->quote($this->getId()),
$db->quote($_POST["multiple_choice_result"])
);
}
$result = $db->query($query);
} else {
$query = sprintf("DELETE FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s",
$db->quote($ilUser->id),
$db->quote($test_id),
$db->quote($this->getId())
);
$result = $db->query($query);
foreach ($_POST as $key => $value) {
if (preg_match("/multiple_choice_result_(\d+)/", $key, $matches)) {
$query = sprintf("INSERT INTO tst_solutions (solution_id, user_fi, test_fi, question_fi, value1, value2, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL, NULL)",
$db->quote($ilUser->id),
$db->quote($test_id),
$db->quote($this->getId()),
$db->quote($value)
);
$result = $db->query($query);
}
}
}
//parent::saveWorkingData($limit_to);
return true;
*/ }
| ASS_JavaApplet::setJavaAppletFilename | ( | $ | javaapplet_filename, | |
| $ | javaapplet_tempfilename = "" | |||
| ) |
Sets the java applet file name.
Sets the java applet file name
| string | $javaapplet_file. public |
Definition at line 1289 of file class.assJavaApplet.php.
References $javaapplet_filename, ASS_Question::getJavaPath(), ilUtil::makeDirParents(), and ilUtil::moveUploadedFile().
{
if (!empty($javaapplet_filename))
{
$this->javaapplet_filename = $javaapplet_filename;
}
if (!empty($javaapplet_tempfilename))
{
$javapath = $this->getJavaPath();
if (!file_exists($javapath))
{
ilUtil::makeDirParents($javapath);
}
//if (!move_uploaded_file($javaapplet_tempfilename, $javapath . $javaapplet_filename))
if (!ilUtil::moveUploadedFile($javaapplet_tempfilename, $javaapplet_filename, $javapath.$javaapplet_filename))
{
print "java applet not uploaded!!!! ";
}
}
}
Here is the call graph for this function:| ASS_JavaApplet::setJavaCode | ( | $ | java_code = "" |
) |
Sets the java applet code parameter.
Sets the java applet code parameter
| string | java applet code parameter public |
Definition at line 926 of file class.assJavaApplet.php.
References $java_code.
{
$this->java_code = $java_code;
}
| ASS_JavaApplet::setJavaHeight | ( | $ | java_height = "" |
) |
Sets the java applet height parameter.
Sets the java applet height parameter
| integer | java applet height parameter public |
Definition at line 978 of file class.assJavaApplet.php.
References $java_height.
{
$this->java_height = $java_height;
}
| ASS_JavaApplet::setJavaWidth | ( | $ | java_width = "" |
) |
Sets the java applet width parameter.
Sets the java applet width parameter
| integer | java applet width parameter public |
Definition at line 952 of file class.assJavaApplet.php.
References $java_width.
{
$this->java_width = $java_width;
}
| ASS_JavaApplet::setQuestion | ( | $ | question = "" |
) |
Sets the question text.
Sets the question string of the ASS_JavaApplet object
| string | $question A string containing the question text public |
Definition at line 887 of file class.assJavaApplet.php.
References $question.
Referenced by from_xml().
{
$this->question = $question;
}
Here is the caller graph for this function:| ASS_JavaApplet::splitParams | ( | $ | params = "" |
) |
Sets the applet parameters from a parameter string containing all parameters in a list.
Sets the applet parameters from a parameter string containing all parameters in a list
| string | $params All applet parameters in a list public |
Definition at line 559 of file class.assJavaApplet.php.
References $params.
Referenced by loadFromDb().
{
$params_array = split("<separator>", $params);
foreach ($params_array as $pair)
{
if (preg_match("/(.*?)\=(.*)/", $pair, $matches))
{
switch ($matches[1])
{
case "java_code" :
$this->java_code = $matches[2];
break;
case "java_width" :
$this->java_width = $matches[2];
break;
case "java_height" :
$this->java_height = $matches[2];
break;
}
if (preg_match("/param_name_(\d+)/", $matches[1], $found_key))
{
$this->parameters[$found_key[1]]["name"] = $matches[2];
}
if (preg_match("/param_value_(\d+)/", $matches[1], $found_key))
{
$this->parameters[$found_key[1]]["value"] = $matches[2];
}
}
}
}
Here is the caller graph for this function:| ASS_JavaApplet::syncWithOriginal | ( | ) |
Reimplemented from ASS_Question.
Definition at line 1311 of file class.assJavaApplet.php.
References ASS_Question::$ilias, $params, $query, $result, ASS_Question::getEstimatedWorkingTime(), and isComplete().
{
global $ilias;
if ($this->original_id)
{
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
$db = & $ilias->db;
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
$query = sprintf("UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %s, working_time=%s, shuffle = %s, complete = %s, image_file = %s, params = %s WHERE question_id = %s",
$db->quote($this->obj_id. ""),
$db->quote($this->title . ""),
$db->quote($this->comment . ""),
$db->quote($this->author . ""),
$db->quote($this->question . ""),
$db->quote($this->points . ""),
$db->quote($estw_time . ""),
$db->quote($this->shuffle . ""),
$db->quote($complete . ""),
$db->quote($this->javaapplet_filename . ""),
$db->quote($params . ""),
$db->quote($this->original_id . "")
);
$result = $db->query($query);
parent::syncWithOriginal();
}
}
Here is the call graph for this function:| ASS_JavaApplet::to_xml | ( | $ | a_include_header = true, |
|
| $ | a_include_binary = true, |
|||
| $ | a_shuffle = false, |
|||
| $ | test_output = false | |||
| ) |
Returns a QTI xml representation of the question.
Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation
Definition at line 133 of file class.assJavaApplet.php.
References $ilUser, $pos, $xml, ilObjTest::_getTestType(), buildParamsOnly(), domxml_open_mem(), ASS_Question::getAuthor(), ASS_Question::getComment(), ASS_Question::getEstimatedWorkingTime(), ASS_Question::getId(), getJavaAppletFilename(), getJavaHeight(), ASS_Question::getJavaPath(), getJavaWidth(), ASS_Question::getPoints(), getQuestion(), getReachedInformation(), ASS_Question::getSuggestedSolution(), ASS_Question::getTitle(), and ilUtil::removeTrailingPathSeparators().
{
if (!empty($this->domxml))
{
$this->domxml->free();
}
$xml_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<questestinterop></questestinterop>\n";
$this->domxml = domxml_open_mem($xml_header);
$root = $this->domxml->document_element();
// qti comment with version information
$qtiComment = $this->domxml->create_element("qticomment");
// qti ident
$qtiIdent = $this->domxml->create_element("item");
$qtiIdent->set_attribute("ident", "il_".IL_INST_ID."_qst_".$this->getId());
$qtiIdent->set_attribute("title", $this->getTitle());
$root->append_child($qtiIdent);
// add question description
$qtiComment = $this->domxml->create_element("qticomment");
$qtiCommentText = $this->domxml->create_text_node($this->getComment());
$qtiComment->append_child($qtiCommentText);
$qtiIdent->append_child($qtiComment);
// add estimated working time
$qtiDuration = $this->domxml->create_element("duration");
$workingtime = $this->getEstimatedWorkingTime();
$qtiDurationText = $this->domxml->create_text_node(sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]));
$qtiDuration->append_child($qtiDurationText);
$qtiIdent->append_child($qtiDuration);
// add ILIAS specific metadata
$qtiItemmetadata = $this->domxml->create_element("itemmetadata");
$qtiMetadata = $this->domxml->create_element("qtimetadata");
$qtiMetadatafield = $this->domxml->create_element("qtimetadatafield");
$qtiFieldlabel = $this->domxml->create_element("fieldlabel");
$qtiFieldlabelText = $this->domxml->create_text_node("ILIAS_VERSION");
$qtiFieldlabel->append_child($qtiFieldlabelText);
$qtiFieldentry = $this->domxml->create_element("fieldentry");
$qtiFieldentryText = $this->domxml->create_text_node($this->ilias->getSetting("ilias_version"));
$qtiFieldentry->append_child($qtiFieldentryText);
$qtiMetadatafield->append_child($qtiFieldlabel);
$qtiMetadatafield->append_child($qtiFieldentry);
$qtiMetadata->append_child($qtiMetadatafield);
$qtiMetadatafield = $this->domxml->create_element("qtimetadatafield");
$qtiFieldlabel = $this->domxml->create_element("fieldlabel");
$qtiFieldlabelText = $this->domxml->create_text_node("QUESTIONTYPE");
$qtiFieldlabel->append_child($qtiFieldlabelText);
$qtiFieldentry = $this->domxml->create_element("fieldentry");
$qtiFieldentryText = $this->domxml->create_text_node(JAVAAPPLET_QUESTION_IDENTIFIER);
$qtiFieldentry->append_child($qtiFieldentryText);
$qtiMetadatafield->append_child($qtiFieldlabel);
$qtiMetadatafield->append_child($qtiFieldentry);
$qtiMetadata->append_child($qtiMetadatafield);
$qtiMetadatafield = $this->domxml->create_element("qtimetadatafield");
$qtiFieldlabel = $this->domxml->create_element("fieldlabel");
$qtiFieldlabelText = $this->domxml->create_text_node("AUTHOR");
$qtiFieldlabel->append_child($qtiFieldlabelText);
$qtiFieldentry = $this->domxml->create_element("fieldentry");
$qtiFieldentryText = $this->domxml->create_text_node($this->getAuthor());
$qtiFieldentry->append_child($qtiFieldentryText);
$qtiMetadatafield->append_child($qtiFieldlabel);
$qtiMetadatafield->append_child($qtiFieldentry);
$qtiMetadata->append_child($qtiMetadatafield);
$qtiItemmetadata->append_child($qtiMetadata);
$qtiIdent->append_child($qtiItemmetadata);
// PART I: qti presentation
$qtiPresentation = $this->domxml->create_element("presentation");
$qtiPresentation->set_attribute("label", $this->getTitle());
// add flow to presentation
$qtiFlow = $this->domxml->create_element("flow");
// add material with question text to presentation
$qtiMaterial = $this->domxml->create_element("material");
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatTextText = $this->domxml->create_text_node($this->getQuestion());
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
$qtiFlow->append_child($qtiMaterial);
$solution = $this->getSuggestedSolution(0);
if (count($solution))
{
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
{
$qtiMaterial = $this->domxml->create_element("material");
$qtiMaterial->set_attribute("label", "suggested_solution");
$qtiMatText = $this->domxml->create_element("mattext");
$intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
if (strcmp($matches[1], "") != 0)
{
$intlink = $solution["internal_link"];
}
$qtiMatTextText = $this->domxml->create_text_node($intlink);
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
$qtiFlow->append_child($qtiMaterial);
}
}
$qtiMaterial = $this->domxml->create_element("material");
$qtiMatApplet = $this->domxml->create_element("matapplet");
$qtiMatApplet->set_attribute("label", "applet data");
$qtiMatApplet->set_attribute("uri", $this->getJavaAppletFilename());
$qtiMatApplet->set_attribute("height", $this->getJavaHeight());
$qtiMatApplet->set_attribute("width", $this->getJavaWidth());
$qtiMatApplet->set_attribute("embedded", "base64");
$javapath = $this->getJavaPath() . $this->getJavaAppletFilename();
$fh = @fopen($javapath, "rb");
if ($fh == false)
{
//global $ilErr;
//$ilErr->raiseError($this->lng->txt("error_open_java_file"), $ilErr->MESSAGE);
return;
}
$javafile = fread($fh, filesize($javapath));
fclose($fh);
$base64 = base64_encode($javafile);
$qtiBase64Data = $this->domxml->create_text_node($base64);
$qtiMatApplet->append_child($qtiBase64Data);
$qtiMaterial->append_child($qtiMatApplet);
if ($this->buildParamsOnly())
{
if ($this->java_code)
{
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "java_code");
$qtiAppletParams = $this->domxml->create_text_node($this->java_code);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
}
foreach ($this->parameters as $key => $value)
{
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", $value["name"]);
$qtiAppletParams = $this->domxml->create_text_node($value["value"]);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
}
if ($test_output)
{
require_once "./assessment/classes/class.ilObjTest.php";
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "test_type");
$qtiAppletParams = $this->domxml->create_text_node(ilObjTest::_getTestType($test_output));
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "test_id");
$qtiAppletParams = $this->domxml->create_text_node($test_output);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "question_id");
$qtiAppletParams = $this->domxml->create_text_node($this->getId());
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "user_id");
global $ilUser;
$qtiAppletParams = $this->domxml->create_text_node($ilUser->id);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "points_max");
$qtiAppletParams = $this->domxml->create_text_node($this->getPoints());
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "post_url");
$qtiAppletParams = $this->domxml->create_text_node(ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/save_java_question_result.php");
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$info = $this->getReachedInformation($ilUser->id, $test_output);
foreach ($info as $kk => $infodata)
{
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "value_" . $infodata["order"] . "_1");
$qtiAppletParams = $this->domxml->create_text_node($infodata["value1"]);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "value_" . $infodata["order"] . "_2");
$qtiAppletParams = $this->domxml->create_text_node($infodata["value2"]);
$qtiMatText->append_child($qtiAppletParams);
$qtiMaterial->append_child($qtiMatText);
}
}
}
$qtiFlow->append_child($qtiMaterial);
// add available points as material
$qtiMaterial = $this->domxml->create_element("material");
$qtiMatText = $this->domxml->create_element("mattext");
$qtiMatText->set_attribute("label", "points");
$qtiMatTextText = $this->domxml->create_text_node($this->getPoints());
$qtiMatText->append_child($qtiMatTextText);
$qtiMaterial->append_child($qtiMatText);
$qtiFlow->append_child($qtiMaterial);
$qtiPresentation->append_child($qtiFlow);
$qtiIdent->append_child($qtiPresentation);
$xml = $this->domxml->dump_mem(true);
if (!$a_include_header)
{
$pos = strpos($xml, "?>");
$xml = substr($xml, $pos + 2);
}
//echo htmlentities($xml);
return $xml;
}
Here is the call graph for this function:| ASS_JavaApplet::$java_code |
Definition at line 64 of file class.assJavaApplet.php.
Referenced by setJavaCode().
| ASS_JavaApplet::$java_height |
Definition at line 82 of file class.assJavaApplet.php.
Referenced by setJavaHeight().
| ASS_JavaApplet::$java_width |
Definition at line 73 of file class.assJavaApplet.php.
Referenced by setJavaWidth().
| ASS_JavaApplet::$javaapplet_filename |
Definition at line 55 of file class.assJavaApplet.php.
Referenced by ASS_JavaApplet(), and setJavaAppletFilename().
| ASS_JavaApplet::$parameters |
Definition at line 91 of file class.assJavaApplet.php.
| ASS_JavaApplet::$question |
Definition at line 46 of file class.assJavaApplet.php.
Referenced by ASS_JavaApplet(), and setQuestion().
1.7.1