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($params_array,
"<separator>");
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($params_array,
"<separator>");
214 if (strlen($this->title)
217 && $this->javaapplet_filename
219 && $this->java_height
223 } elseif (strlen($this->title)
229 && $this->java_height
264 ) .
" (question_fi, image_file, params) VALUES (%s, %s, %s)",
265 array(
"integer",
"text",
"text" ),
268 $this->javaapplet_filename,
291 $this->
setId($question_id);
300 include_once(
"./Services/RTE/classes/class.ilRTE.php");
311 parent::loadFromDb($question_id);
321 if ($this->
id <= 0) {
326 $this_id = $this->
getId();
330 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
334 if ((
int) $testObjId > 0) {
335 $clone->setObjId($testObjId);
354 $clone->copyPageOfQuestion($this_id);
356 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
358 $clone->duplicateApplet($this_id, $thisObjId);
360 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
374 if ($this->
id <= 0) {
380 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
383 $source_questionpool_id = $this->
getObjId();
384 $clone->setObjId($target_questionpool_id);
395 $clone->copyApplet(
$original_id, $source_questionpool_id);
397 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
404 if ($this->
id <= 0) {
409 include_once(
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
412 $sourceParentId = $this->
getObjId();
418 $clone->setObjId($targetParentId);
420 if ($targetQuestionTitle) {
421 $clone->setTitle($targetQuestionTitle);
426 $clone->copyPageOfQuestion($sourceQuestionId);
428 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
430 $clone->copyApplet($sourceQuestionId, $sourceParentId);
432 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
440 $javapath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $javapath);
442 if ((
int) $objectId > 0) {
443 $javapath_original = str_replace(
"/$this->obj_id/",
"/$objectId/", $javapath_original);
446 if (!file_exists($javapath)) {
450 if (!copy($javapath_original .
$filename, $javapath . $filename)) {
451 print
"java applet could not be duplicated!!!! ";
455 public function copyApplet($question_id, $source_questionpool)
458 $javapath_original = preg_replace(
"/([^\d])$this->id([^\d])/",
"\${1}$question_id\${2}", $javapath);
459 $javapath_original = str_replace(
"/$this->obj_id/",
"/$source_questionpool/", $javapath_original);
460 if (!file_exists($javapath)) {
464 if (!copy($javapath_original .
$filename, $javapath . $filename)) {
465 print
"java applet could not be copied!!!! ";
611 if ($returndetails) {
612 throw new ilTestException(
'return details not implemented for ' . __METHOD__);
617 $found_values =
array();
618 if (is_null(
$pass)) {
636 if (isset($solution[
'points'])) {
637 $points += $solution[
'points'];
679 $found_values =
array();
680 if (is_null(
$pass)) {
684 "SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
685 array(
'integer',
'integer',
'integer'),
689 $user_result =
array();
692 if (
$data[
"points"] > 0) {
697 "points" =>
$data[
"points"],
699 "value1" =>
$data[
"value1"],
700 "value2" =>
$data[
"value2"],
703 array_push($user_result, $solution);
722 array_push($this->parameters,
array(
"name" =>
$name,
"value" => $value));
728 if (array_key_exists(
$index, $this->parameters)) {
730 $newparams =
array();
732 array_push($newparams, $this->parameters[
$i]);
735 for (
$i = $index;
$i < count($this->parameters);
$i++) {
736 array_push($newparams, $this->parameters[
$i]);
738 $this->parameters = $newparams;
740 array_push($this->parameters,
array(
$name, $value));
756 if (count($this->parameters) < 1) {
759 if (
$index >= count($this->parameters)) {
762 unset($this->parameters[
$index]);
763 $this->parameters = array_values($this->parameters);
776 if ((
$index < 0) or (
$index >= count($this->parameters))) {
779 return $this->parameters[
$index];
792 foreach ($this->parameters as
$key => $value) {
793 if (array_key_exists(
$name, $value)) {
809 return count($this->parameters);
820 $this->parameters =
array();
882 if (!empty($javaapplet_tempfilename)) {
884 if (!file_exists($javapath)) {
889 $ilLog->write(
"ERROR: java applet question: java applet not uploaded: $javaapplet_filename");
900 $this->javaapplet_filename =
"";
910 return "assJavaApplet";
920 return "qpl_qst_javaapplet";
929 return parent::getRTETextWithMediaObjects();
942 foreach ($solutions as $solution) {
943 $worksheet->setCell($startrow +
$i, 1, $this->lng->txt(
"result") .
" $i");
944 if (strlen($solution[
"value1"])) {
945 $worksheet->setCell($startrow +
$i, 1, $solution[
"value1"]);
947 if (strlen($solution[
"value2"])) {
948 $worksheet->setCell($startrow +
$i, 2, $solution[
"value2"]);
953 return $startrow +
$i + 1;
971 require_once
"./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1030 return parent::buildTestPresentationConfig()
1032 ->setFormChangeDetectionEnabled(
false)
1033 ->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.
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{}
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.
Create styles array
The data for the language used.
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