4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once
'./Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
8 require_once
'./Modules/TestQuestionPool/classes/class.ilUserQuestionResult.php';
112 $this->parameters = array();
124 $params_array = explode(
"<separator>",
$params);
125 foreach ($params_array as $pair) {
126 if (preg_match(
"/(.*?)\=(.*)/", $pair, $matches)) {
127 switch ($matches[1]) {
129 $this->java_code = $matches[2];
131 case "java_codebase":
132 $this->java_codebase = $matches[2];
135 $this->java_archive = $matches[2];
138 $this->java_width = $matches[2];
141 $this->java_height = $matches[2];
144 if (preg_match(
"/param_name_(\d+)/", $matches[1], $found_key)) {
145 $this->parameters[$found_key[1]][
"name"] = $matches[2];
147 if (preg_match(
"/param_value_(\d+)/", $matches[1], $found_key)) {
148 $this->parameters[$found_key[1]][
"value"] = $matches[2];
163 $params_array = array();
164 if ($this->java_code) {
165 array_push($params_array,
"java_code=$this->java_code");
167 if ($this->java_codebase) {
168 array_push($params_array,
"java_codebase=$this->java_codebase");
170 if ($this->java_archive) {
171 array_push($params_array,
"java_archive=$this->java_archive");
173 if ($this->java_width) {
174 array_push($params_array,
"java_width=$this->java_width");
176 if ($this->java_height) {
177 array_push($params_array,
"java_height=$this->java_height");
179 foreach ($this->parameters as
$key => $value) {
180 array_push($params_array,
"param_name_$key=" . $value[
"name"]);
181 array_push($params_array,
"param_value_$key=" . $value[
"value"]);
184 return join(
"<separator>", $params_array);
194 $params_array = array();
195 if ($this->java_code) {
196 array_push($params_array,
"java_code=$this->java_code");
197 array_push($params_array,
"java_codebase=$this->java_codebase");
198 array_push($params_array,
"java_archive=$this->java_archive");
200 foreach ($this->parameters as
$key => $value) {
201 array_push($params_array,
"param_name_$key=" . $value[
"name"]);
202 array_push($params_array,
"param_value_$key=" . $value[
"value"]);
204 return join(
"<separator>", $params_array);
214 if (strlen($this->title)
217 && $this->javaapplet_filename
219 && $this->java_height
223 } elseif (strlen($this->title)
229 && $this->java_height
255 $ilDB = $DIC[
'ilDB'];
261 array( $this->
getId() )
265 ) .
" (question_fi, image_file, params) VALUES (%s, %s, %s)",
266 array(
"integer",
"text",
"text" ),
269 $this->javaapplet_filename,
284 $ilDB = $DIC[
'ilDB'];
293 $this->
setId($question_id);
302 include_once(
"./Services/RTE/classes/class.ilRTE.php");
313 parent::loadFromDb($question_id);
323 if ($this->
id <= 0) {
328 $this_id = $this->
getId();
332 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
336 if ((
int) $testObjId > 0) {
337 $clone->setObjId($testObjId);
356 $clone->copyPageOfQuestion($this_id);
358 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
360 $clone->duplicateApplet($this_id, $thisObjId);
362 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
376 if ($this->
id <= 0) {
382 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
385 $source_questionpool_id = $this->
getObjId();
386 $clone->setObjId($target_questionpool_id);
397 $clone->copyApplet(
$original_id, $source_questionpool_id);
399 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
406 if ($this->
id <= 0) {
411 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
414 $sourceParentId = $this->
getObjId();
420 $clone->setObjId($targetParentId);
422 if ($targetQuestionTitle) {
423 $clone->setTitle($targetQuestionTitle);
428 $clone->copyPageOfQuestion($sourceQuestionId);
430 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
432 $clone->copyApplet($sourceQuestionId, $sourceParentId);
434 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
442 $javapath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $javapath);
444 if ((
int) $objectId > 0) {
445 $javapath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $javapath_original);
448 if (!file_exists($javapath)) {
452 if (!copy($javapath_original .
$filename, $javapath . $filename)) {
453 print
"java applet could not be duplicated!!!! ";
457 public function copyApplet($question_id, $source_questionpool)
460 $javapath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $javapath);
461 $javapath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $javapath_original);
462 if (!file_exists($javapath)) {
466 if (!copy($javapath_original .
$filename, $javapath . $filename)) {
467 print
"java applet could not be copied!!!! ";
613 if ($returndetails) {
614 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
618 $ilDB = $DIC[
'ilDB'];
620 $found_values = array();
621 if (is_null(
$pass)) {
639 if (isset($solution[
'points'])) {
640 $points += $solution[
'points'];
681 $ilDB = $DIC[
'ilDB'];
683 $found_values = array();
684 if (is_null(
$pass)) {
688 "SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
689 array(
'integer',
'integer',
'integer'),
693 $user_result = array();
696 if (
$data[
"points"] > 0) {
701 "points" =>
$data[
"points"],
703 "value1" =>
$data[
"value1"],
704 "value2" =>
$data[
"value2"],
707 array_push($user_result, $solution);
724 $this->parameters[
$index] = array(
"name" =>
$name,
"value" => $value);
726 array_push($this->parameters, array(
"name" =>
$name,
"value" => $value));
732 if (array_key_exists(
$index, $this->parameters)) {
734 $newparams = array();
736 array_push($newparams, $this->parameters[
$i]);
738 array_push($newparams, array(
$name, $value));
739 for (
$i = $index;
$i < count($this->parameters);
$i++) {
740 array_push($newparams, $this->parameters[
$i]);
742 $this->parameters = $newparams;
744 array_push($this->parameters, array(
$name, $value));
760 if (count($this->parameters) < 1) {
763 if (
$index >= count($this->parameters)) {
766 unset($this->parameters[
$index]);
767 $this->parameters = array_values($this->parameters);
783 return $this->parameters[
$index];
796 foreach ($this->parameters as
$key => $value) {
797 if (array_key_exists(
$name, $value)) {
813 return count($this->parameters);
824 $this->parameters = array();
878 if (!empty($javaapplet_tempfilename)) {
880 if (!file_exists($javapath)) {
885 $ilLog->write(
"ERROR: java applet question: java applet not uploaded: $javaapplet_filename");
896 $this->javaapplet_filename =
"";
906 return "assJavaApplet";
916 return "qpl_qst_javaapplet";
925 return parent::getRTETextWithMediaObjects();
933 parent::setExportDetailsXLS($worksheet, $startrow, $active_id,
$pass);
938 foreach ($solutions as $solution) {
939 $worksheet->setCell($startrow +
$i, 1, $this->lng->txt(
"result") .
" $i");
940 if (strlen($solution[
"value1"])) {
941 $worksheet->setCell($startrow +
$i, 1, $solution[
"value1"]);
943 if (strlen($solution[
"value2"])) {
944 $worksheet->setCell($startrow +
$i, 2, $solution[
"value2"]);
949 return $startrow +
$i + 1;
967 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1026 return parent::buildTestPresentationConfig()
1028 ->setFormChangeDetectionEnabled(
false)
1029 ->setBackgroundChangeDetectionEnabled(
true);
duplicateApplet($question_id, $objectId=null)
getParameterIndex($name)
Returns the index of an applet parameter.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
addParameter($name="", $value="")
Adds a new parameter value to the parameter list.
getId()
Gets the id of the assQuestion object.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
static _getOriginalId($question_id)
Returns the original id of a question.
deleteJavaAppletFilename()
const PercentageResultExpression
Class iQuestionCondition.
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{}
getQuestionType()
Returns the question type of the question.
flushParams()
Removes all applet parameters.
getJavaWidth()
Returns the java applet width parameter.
calculateReachedPointsFromPreviewSession(ilAssQuestionPreviewSession $previewSession)
getPoints()
Returns the maximum available points for the question.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assJavaApplet.
Abstract basic class which is to be extended by the concrete assessment question type classes...
getSolutionValuesRegardlessOfAuthorization($active_id, $pass=null)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveWorkingData($active_id, $pass=null, $authorized=true)
Saves the learners input of the question to the database.
setJavaHeight($java_height="")
Sets the java applet height parameter.
ensureNonNegativePoints($points)
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setId($id=-1)
Sets the id of the assQuestion object.
setJavaArchive($java_archive="")
Sets the java applet archive parameter.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
splitParams($params="")
Sets the applet parameters from a parameter string containing all parameters in a list...
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
getSolutionValues($active_id, $pass=null, $authorized=true)
addParameterAtIndex($index=0, $name="", $value="")
getJavaPath()
Returns the image path for web accessable images of a question.
Class for Java Applet Questions.
copyApplet($question_id, $source_questionpool)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
getParticipantsSolution()
loadFromDb($question_id)
Loads a assJavaApplet object from a database.
buildParamsOnly()
Returns a string containing the additional applet parameters.
setNrOfTries($a_nr_of_tries)
getParameterCount()
Returns the number of additional applet parameters.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setJavaWidth($java_width="")
Sets the java applet width parameter.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
getObjId()
Get the object id of the container object.
Base Exception for all Exceptions relating to Modules/Test.
saveToDb($original_id="")
Saves a assJavaApplet object to a database.
setAuthor($author="")
Sets the authors name of the assQuestion object.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
getJavaHeight()
Returns the java applet height parameter.
getJavaAppletFilename()
Gets the java applet file name.
getParameter($index)
Returns the paramter at a given index.
Class ilUserQuestionResult.
removeParameter($index)
Removes a parameter value from the parameter list.
getOperators($expression)
Get all available operations for a specific question.
getJavaCodebase()
Returns the java applet codebase parameter.
savePreviewData(ilAssQuestionPreviewSession $previewSession)
calculateReachedPoints($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
Returns the points, a learner has reached answering the question.
static getOperatorsByExpression($expression)
buildTestPresentationConfig()
Get the test question configuration.
deductHintPointsFromReachedPoints(ilAssQuestionPreviewSession $previewSession, $reachedPoints)
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $javaapplet_filename="")
assJavaApplet constructor
setJavaAppletFilename($javaapplet_filename, $javaapplet_tempfilename="")
Sets the java applet file name.
setJavaCodebase($java_codebase="")
Sets the java applet codebase parameter.
getJavaArchive()
Returns the java applet archive parameter.
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
setOriginalId($original_id)
buildParams()
Returns a string containing the applet parameters.
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
isComplete()
Returns true, if a imagemap question is complete for use.
getReachedInformation($active_id, $pass=null)
Returns the evaluation data, a learner has entered to answer the question.
getExpressionTypes()
Get all available expression types for a specific question.
getUserQuestionResult($active_id, $pass)
Get the user solution for a question by active_id and the test pass.
getJavaCode()
Returns the java applet code parameter.
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
copyObject($target_questionpool_id, $title="")
Copies an assJavaApplet object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setJavaCode($java_code="")
Sets the java applet code parameter.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
const EmptyAnswerExpression