Public Member Functions | Data Fields

assJavaApplet Class Reference

Class for Java Applet Questions. More...

Inheritance diagram for assJavaApplet:
Collaboration diagram for assJavaApplet:

Public Member Functions

 assJavaApplet ($title="", $comment="", $author="", $owner=-1, $question="", $javaapplet_filename="")
 assJavaApplet constructor
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file.
 to_xml ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question.
 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 assJavaApplet object to a database.
 loadFromDb ($question_id)
 Loads a assJavaApplet object from a database.
 duplicate ($for_test=true, $title="", $author="", $owner="")
 Duplicates an assJavaApplet.
 copyObject ($target_questionpool, $title="")
 Copies an assJavaApplet object.
 duplicateApplet ($question_id)
 copyApplet ($question_id, $source_questionpool)
 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.
 getJavaCodebase ()
 Returns the java applet codebase parameter.
 getJavaArchive ()
 Returns the java applet archive parameter.
 setJavaCode ($java_code="")
 Sets the java applet code parameter.
 setJavaCodebase ($java_codebase="")
 Sets the java applet codebase parameter.
 setJavaArchive ($java_archive="")
 Sets the java applet archive 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 ($active_id, $pass=NULL)
 Returns the points, a learner has reached answering the question.
 getReachedInformation ($active_id, $pass=NULL)
 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 ($active_id, $pass=NULL)
 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.
 deleteJavaAppletFilename ()
 syncWithOriginal ()
 getQuestionType ()
 Returns the question type of the question.
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database.

Data Fields

 $question
 $javaapplet_filename
 $java_code
 $java_codebase
 $java_archive
 $java_width
 $java_height
 $parameters

Detailed Description

Class for Java Applet Questions.

assJavaApplet is a class for Java Applet Questions.

Author:
Helmut Schottmüller <helmut.schottmueller@mac.com>
Version:
Id:
class.assJavaApplet.php 15912 2008-02-05 12:54:38Z hschottm

class.assJavaApplet.php Assessment

Definition at line 36 of file class.assJavaApplet.php.


Member Function Documentation

assJavaApplet::addParameter ( name = "",
value = "" 
)

Adds a new parameter value to the parameter list.

Adds a new parameter value to the parameter list

Parameters:
string $name The name of the parameter value
string $value The value of the parameter value public
See also:
$parameters

Definition at line 1105 of file class.assJavaApplet.php.

References getParameterIndex().

Referenced by fromXML().

        {
                $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:

assJavaApplet::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

Parameters:
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
See also:
$parameters

Definition at line 1129 of file class.assJavaApplet.php.

        {
                $this->parameters[$index] = array("name" => $name, "value" => $value);
        }

assJavaApplet::assJavaApplet ( title = "",
comment = "",
author = "",
owner = -1,
question = "",
javaapplet_filename = "" 
)

assJavaApplet constructor

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

Parameters:
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
See also:
assQuestion:assQuestion()

Definition at line 125 of file class.assJavaApplet.php.

References assQuestion::$author, assQuestion::$comment, $javaapplet_filename, assQuestion::$owner, $question, assQuestion::$title, and assQuestion::assQuestion().

        {
                $this->assQuestion($title, $comment, $author, $owner);
                $this->question = $question;
                $this->javaapplet_filename = $javaapplet_filename;
                $this->parameters = array();
        }

Here is the call graph for this function:

assJavaApplet::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

Returns:
string All applet parameters public

Definition at line 500 of file class.assJavaApplet.php.

References $key.

Referenced by saveToDb(), and syncWithOriginal().

        {
                $params_array = array();
                if ($this->java_code)
                {
                        array_push($params_array, "java_code=$this->java_code");
                }
                if ($this->java_codebase)
                {
                        array_push($params_array, "java_codebase=$this->java_codebase");
                }
                if ($this->java_archive)
                {
                        array_push($params_array, "java_archive=$this->java_archive");
                }
                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:

assJavaApplet::buildParamsOnly (  ) 

Returns a string containing the additional applet parameters.

Returns a string containing the additional applet parameters

Returns:
string All additional applet parameters public

Definition at line 539 of file class.assJavaApplet.php.

References $key.

Referenced by to_xml().

        {
                $params_array = array();
                if ($this->java_code)
                {
                        array_push($params_array, "java_code=$this->java_code");
                        array_push($params_array, "java_codebase=$this->java_codebase");
                        array_push($params_array, "java_archive=$this->java_archive");
                }
                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:

assJavaApplet::calculateReachedPoints ( active_id,
pass = NULL 
)

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.

Parameters:
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 1024 of file class.assJavaApplet.php.

References $data, assQuestion::$points, $query, $result, assQuestion::getId(), and assQuestion::getSolutionMaxPass().

        {
                global $ilDB;
                
                $found_values = array();
                if (is_null($pass))
                {
                        $pass = $this->getSolutionMaxPass($active_id);
                }
                $query = sprintf("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
                        $ilDB->quote($active_id . ""),
                        $ilDB->quote($this->getId() . ""),
                        $ilDB->quote($pass . "")
                );
                $result = $ilDB->query($query);
                $points = 0;
                while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $points += $data->points;
                }

                $points = parent::calculateReachedPoints($active_id, $pass = NULL, $points);
                return $points;
        }

Here is the call graph for this function:

assJavaApplet::copyApplet ( question_id,
source_questionpool 
)

Definition at line 827 of file class.assJavaApplet.php.

References getJavaAppletFilename(), assQuestion::getJavaPath(), and ilUtil::makeDirParents().

        {
                $javapath = $this->getJavaPath();
                $javapath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $javapath);
                $javapath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $javapath_original);
                if (!file_exists($javapath))
                {
                        ilUtil::makeDirParents($javapath);
                }
                $filename = $this->getJavaAppletFilename();
                if (!copy($javapath_original . $filename, $javapath . $filename)) {
                        print "java applet could not be copied!!!! ";
                }
        }

Here is the call graph for this function:

assJavaApplet::copyObject ( target_questionpool,
title = "" 
)

Copies an assJavaApplet object.

Copies an assJavaApplet object

public

Definition at line 783 of file class.assJavaApplet.php.

References assQuestion::$title, assQuestion::_getOriginalId(), and assQuestion::getObjId().

        {
                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 = assQuestion::_getOriginalId($this->id);
                $clone->id = -1;
                $source_questionpool = $this->getObjId();
                $clone->setObjId($target_questionpool);
                if ($title)
                {
                        $clone->setTitle($title);
                }
                $clone->saveToDb();

                // copy question page content
                $clone->copyPageOfQuestion($original_id);
                // copy XHTML media objects
                $clone->copyXHTMLMediaObjectsOfQuestion($original_id);

                // duplicate the image
                $clone->copyApplet($original_id, $source_questionpool);
                return $clone->id;
        }

Here is the call graph for this function:

assJavaApplet::deleteJavaAppletFilename (  ) 

Definition at line 1289 of file class.assJavaApplet.php.

References getJavaAppletFilename(), and assQuestion::getJavaPath().

        {
                unlink($this->getJavaPath() . $this->getJavaAppletFilename());
                $this->javaapplet_filename = "";
        }

Here is the call graph for this function:

assJavaApplet::duplicate ( for_test = true,
title = "",
author = "",
owner = "" 
)

Duplicates an assJavaApplet.

Duplicates an assJavaApplet

public

Definition at line 732 of file class.assJavaApplet.php.

References assQuestion::$author, assQuestion::$owner, assQuestion::$title, assQuestion::_getOriginalId(), and assQuestion::getId().

Referenced by fromXML().

        {
                if ($this->id <= 0)
                {
                        // The question has not been saved. It cannot be duplicated
                        return;
                }
                // duplicate the question in database
                $this_id = $this->getId();
                $clone = $this;
                include_once ("./assessment/classes/class.assQuestion.php");
                $original_id = assQuestion::_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($this_id);
                // copy XHTML media objects
                $clone->copyXHTMLMediaObjectsOfQuestion($this_id);

                // duplicate the image
                $clone->duplicateApplet($this_id);
                return $clone->id;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

assJavaApplet::duplicateApplet ( question_id  ) 

Definition at line 813 of file class.assJavaApplet.php.

References getJavaAppletFilename(), assQuestion::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:

assJavaApplet::flushParams (  ) 

Removes all applet parameters.

Removes all applet parameters

public

See also:
$parameters

Definition at line 1218 of file class.assJavaApplet.php.

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

assJavaApplet::fromXML ( &$  item,
&$  questionpool_id,
&$  tst_id,
&$  tst_object,
&$  question_counter,
&$  import_mapping 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters:
object $item The QTI item object
integer $questionpool_id The id of the parent questionpool
integer $tst_id The id of the parent test if the question is part of a test
object $tst_object A reference to the parent test object
integer $question_counter A reference to a question counter to count the questions of an imported question pool
array $import_mapping An array containing references to included ILIAS objects public

Definition at line 154 of file class.assJavaApplet.php.

References $_SESSION, ilObjQuestionPool::_getImportDirectory(), ilObjTest::_getImportDirectory(), ilRTE::_replaceMediaObjectImageSrc(), ilObjMediaObject::_saveTempFileAsMediaObject(), ilObjMediaObject::_saveUsage(), addParameter(), duplicate(), getContent(), assQuestion::getId(), assQuestion::getJavaPath(), getQuestion(), ilUtil::makeDirParents(), assQuestion::QTIMaterialToString(), saveToDb(), assQuestion::setAuthor(), assQuestion::setComment(), assQuestion::setEstimatedWorkingTime(), setJavaArchive(), setJavaCode(), setJavaCodebase(), setJavaHeight(), setJavaWidth(), assQuestion::setObjId(), assQuestion::setOwner(), assQuestion::setPoints(), setQuestion(), assQuestion::setSuggestedSolution(), and assQuestion::setTitle().

        {
                global $ilUser;

                // empty session variable for imported xhtml mobs
                unset($_SESSION["import_mob_xhtml"]);
                $presentation = $item->getPresentation(); 
                $duration = $item->getDuration();
                $now = getdate();
                $applet = NULL;
                $maxpoints = 0;
                $javacode = "";
                $javacodebase = "";
                $javaarchive = "";
                $params = array();
                $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
                $answers = array();
                foreach ($presentation->order as $entry)
                {
                        switch ($entry["type"])
                        {
                                case "material":
                                        $material = $presentation->material[$entry["index"]];
                                        for ($i = 0; $i < $material->getMaterialCount(); $i++)
                                        {
                                                $mat = $material->getMaterial($i);
                                                if (strcmp($mat["type"], "mattext") == 0)
                                                {
                                                        $mattext = $mat["material"];
                                                        if ((strlen($mattext->getLabel()) == 0) && (strlen($this->QTIMaterialToString($item->getQuestiontext())) == 0))
                                                        {
                                                                $item->setQuestiontext($mattext->getContent());
                                                        }
                                                        if (strcmp($mattext->getLabel(), "points") == 0)
                                                        {
                                                                $maxpoints = $mattext->getContent();
                                                        }
                                                        else if (strcmp($mattext->getLabel(), "java_code") == 0)
                                                        {
                                                                $javacode = $mattext->getContent();
                                                        }
                                                        else if (strcmp($mattext->getLabel(), "java_codebase") == 0)
                                                        {
                                                                $javacodebase = $mattext->getContent();
                                                        }
                                                        else if (strcmp($mattext->getLabel(), "java_archive") == 0)
                                                        {
                                                                $javaarchive = $mattext->getContent();
                                                        }
                                                        else if (strlen($mattext->getLabel()) > 0)
                                                        {
                                                                array_push($params, array("key" => $mattext->getLabel(), "value" => $mattext->getContent()));
                                                        }
                                                }
                                                elseif (strcmp($mat["type"], "matapplet") == 0)
                                                {
                                                        $applet = $mat["material"];
                                                }
                                        }
                                        break;
                        }
                }

                $this->setTitle($item->getTitle());
                $this->setComment($item->getComment());
                $this->setAuthor($item->getAuthor());
                $this->setOwner($ilUser->getId());
                $this->setQuestion($this->QTIMaterialToString($item->getQuestiontext()));
                $this->setObjId($questionpool_id);
                $this->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
                $this->javaapplet_filename = $applet->getUri();
                $this->setJavaWidth($applet->getWidth());
                $this->setJavaHeight($applet->getHeight());
                $this->setJavaCode($javacode);
                $this->setJavaCodebase($javacodebase);
                $this->setJavaArchive($javaarchive);
                $this->setPoints($maxpoints);
                foreach ($params as $pair)
                {
                        $this->addParameter($pair["key"], $pair["value"]);
                }
                $this->saveToDb();
                if (count($item->suggested_solutions))
                {
                        foreach ($item->suggested_solutions as $suggested_solution)
                        {
                                $this->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
                        }
                        $this->saveToDb();
                }
                $javaapplet =& base64_decode($applet->getContent());
                $javapath = $this->getJavaPath();
                if (!file_exists($javapath))
                {
                        include_once "./classes/class.ilUtil.php";
                        ilUtil::makeDirParents($javapath);
                }
                $javapath .=  $this->javaapplet_filename;
                $fh = fopen($javapath, "wb");
                if ($fh == false)
                {
//                                                                      global $ilErr;
//                                                                      $ilErr->raiseError($this->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
//                                                                      return;
                }
                else
                {
                        $javafile = fwrite($fh, $javaapplet);
                        fclose($fh);
                }
                // handle the import of media objects in XHTML code
                if (is_array($_SESSION["import_mob_xhtml"]))
                {
                        include_once "./content/classes/Media/class.ilObjMediaObject.php";
                        include_once "./Services/RTE/classes/class.ilRTE.php";
                        foreach ($_SESSION["import_mob_xhtml"] as $mob)
                        {
                                if ($tst_id > 0)
                                {
                                        include_once "./assessment/classes/class.ilObjTest.php";
                                        $importfile = ilObjTest::_getImportDirectory() . "/" . $_SESSION["tst_import_subdir"] . "/" . $mob["uri"];
                                }
                                else
                                {
                                        include_once "./assessment/classes/class.ilObjQuestionPool.php";
                                        $importfile = ilObjQuestionPool::_getImportDirectory() . "/" . $_SESSION["qpl_import_subdir"] . "/" . $mob["uri"];
                                }
                                $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                                ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->getId());
                                $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getQuestion()), 1));
                        }
                        $this->saveToDb();
                }
                if ($tst_id > 0)
                {
                        $q_1_id = $this->getId();
                        $question_id = $this->duplicate(true);
                        $tst_object->questions[$question_counter++] = $question_id;
                        $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
                }
                else
                {
                        $import_mapping[$item->getIdent()] = array("pool" => $this->getId(), "test" => 0);
                }
                //$ilLog->write(strftime("%D %T") . ": finished import multiple choice question (single response)");
        }

Here is the call graph for this function:

assJavaApplet::getAdditionalTableName (  ) 

Returns the name of the additional question data table in the database.

Returns the name of the additional question data table in the database

Returns:
string The additional table name public

Reimplemented from assQuestion.

Definition at line 1355 of file class.assJavaApplet.php.

        {
                return "qpl_question_javaapplet";
        }

assJavaApplet::getJavaAppletFilename (  ) 

Gets the java applet file name.

Gets the java applet file name

Returns:
string The java applet file of the assJavaApplet object public
See also:
$javaapplet_filename

Definition at line 1248 of file class.assJavaApplet.php.

Referenced by copyApplet(), deleteJavaAppletFilename(), duplicateApplet(), and to_xml().

        {
                return $this->javaapplet_filename;
        }

Here is the caller graph for this function:

assJavaApplet::getJavaArchive (  ) 

Returns the java applet archive parameter.

Returns the java applet archive parameter

Returns:
string java applet archive parameter public

Definition at line 917 of file class.assJavaApplet.php.

Referenced by isComplete().

        {
                return $this->java_archive;
        }

Here is the caller graph for this function:

assJavaApplet::getJavaCode (  ) 

Returns the java applet code parameter.

Returns the java applet code parameter

Returns:
string java applet code parameter public

Definition at line 891 of file class.assJavaApplet.php.

        {
                return $this->java_code;
        }

assJavaApplet::getJavaCodebase (  ) 

Returns the java applet codebase parameter.

Returns the java applet codebase parameter

Returns:
string java applet codebase parameter public

Definition at line 904 of file class.assJavaApplet.php.

Referenced by isComplete().

        {
                return $this->java_codebase;
        }

Here is the caller graph for this function:

assJavaApplet::getJavaHeight (  ) 

Returns the java applet height parameter.

Returns the java applet height parameter

Returns:
integer java applet height parameter public

Definition at line 995 of file class.assJavaApplet.php.

Referenced by to_xml().

        {
                return $this->java_height;
        }

Here is the caller graph for this function:

assJavaApplet::getJavaWidth (  ) 

Returns the java applet width parameter.

Returns the java applet width parameter

Returns:
integer java applet width parameter public

Definition at line 969 of file class.assJavaApplet.php.

Referenced by to_xml().

        {
                return $this->java_width;
        }

Here is the caller graph for this function:

assJavaApplet::getMaximumPoints (  ) 

Returns the maximum points, a learner can reach answering the question.

Returns the maximum points, a learner can reach answering the question

public

See also:
$points

Reimplemented from assQuestion.

Definition at line 878 of file class.assJavaApplet.php.

Referenced by isComplete().

        {
                return $this->points;
        }

Here is the caller graph for this function:

assJavaApplet::getParameter ( index  ) 

Returns the paramter at a given index.

Returns the paramter at a given index

Parameters:
intege $index The index value of the parameter
Returns:
array The parameter at the given index public
See also:
$parameters

Definition at line 1165 of file class.assJavaApplet.php.

        {
                if (($index < 0) or ($index >= count($this->parameters)))
                {
                        return undef;
                }
                return $this->parameters[$index];
        }

assJavaApplet::getParameterCount (  ) 

Returns the number of additional applet parameters.

Returns the number of additional applet parameters

Returns:
integer The number of additional applet parameters public
See also:
$parameters

Definition at line 1205 of file class.assJavaApplet.php.

        {
                return count($this->parameters);
        }

assJavaApplet::getParameterIndex ( name  ) 

Returns the index of an applet parameter.

Returns the index of an applet parameter

Parameters:
string $name The name of the parameter value
Returns:
integer The index of the applet parameter or -1 if the parameter wasn't found private
See also:
$parameters

Definition at line 1184 of file class.assJavaApplet.php.

References $key.

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:

assJavaApplet::getQuestion (  ) 

Gets the multiple choice question.

Gets the question string of the assJavaApplet object

Returns:
string The question string of the assJavaApplet object public
See also:
$question

Definition at line 851 of file class.assJavaApplet.php.

Referenced by fromXML(), and to_xml().

        {
                return $this->question;
        }

Here is the caller graph for this function:

assJavaApplet::getQuestionType (  ) 

Returns the question type of the question.

Returns the question type of the question

Returns:
integer The question type of the question public

Definition at line 1342 of file class.assJavaApplet.php.

Referenced by saveToDb().

        {
                return 7;
        }

Here is the caller graph for this function:

assJavaApplet::getReachedInformation ( active_id,
pass = NULL 
)

Returns the evaluation data, a learner has entered to answer the question.

Returns the evaluation data, a learner has entered to answer the question

Parameters:
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 1058 of file class.assJavaApplet.php.

References $counter, $data, $query, $result, assQuestion::getId(), and assQuestion::getSolutionMaxPass().

        {
                global $ilDB;
                
                $found_values = array();
                if (is_null($pass))
                {
                        $pass = $this->getSolutionMaxPass($active_id);
                }
                $query = sprintf("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
                        $ilDB->quote($active_id . ""),
                        $ilDB->quote($this->getId() . ""),
                        $ilDB->quote($pass . "")
                );
                $result = $ilDB->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:

assJavaApplet::isComplete (  ) 

Returns true, if a imagemap question is complete for use.

Returns true, if a imagemap question is complete for use

Returns:
boolean True, if the imagemap question is complete for use, otherwise false public

Reimplemented from assQuestion.

Definition at line 564 of file class.assJavaApplet.php.

References getJavaArchive(), getJavaCodebase(), and getMaximumPoints().

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->getMaximumPoints() > 0))
                {
                        return true;
                }
                else if (($this->title) and ($this->author) and ($this->question) and ($this->getJavaArchive()) and ($this->getJavaCodebase()) and ($this->java_width) and ($this->java_height) and ($this->getMaximumPoints() > 0))
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

assJavaApplet::loadFromDb ( question_id  ) 

Loads a assJavaApplet object from a database.

Loads a assJavaApplet object from a database (experimental)

Parameters:
object $db A pear DB object
integer $question_id A unique key which defines the multiple choice test in the database public

Reimplemented from assQuestion.

Definition at line 692 of file class.assJavaApplet.php.

References $data, $query, $result, ilRTE::_replaceMediaObjectImageSrc(), assQuestion::setEstimatedWorkingTime(), and splitParams().

        {
                global $ilDB;

    $query = sprintf("SELECT qpl_questions.*, qpl_question_javaapplet.* FROM qpl_questions, qpl_question_javaapplet WHERE question_id = %s AND qpl_questions.question_id = qpl_question_javaapplet.question_fi",
                        $ilDB->quote($question_id)
                );
                $result = $ilDB->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;
                                include_once("./Services/RTE/classes/class.ilRTE.php");
                                $this->question = ilRTE::_replaceMediaObjectImageSrc($data->question_text, 1);
                                $this->solution_hint = $data->solution_hint;
                                $this->splitParams($data->params);
                                $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:

assJavaApplet::removeParameter ( name  ) 

Removes a parameter value from the parameter list.

Removes a parameter value from the parameter list

Parameters:
string $name The name of the parameter value public
See also:
$parameters

Definition at line 1143 of file class.assJavaApplet.php.

References $key.

        {
                foreach ($this->parameters as $key => $value)
                {
                        if (strcmp($name, $value["name"]) == 0)
                        {
                                array_splice($this->parameters, $key, 1);
                                return;
                        }
                }
        }

assJavaApplet::saveToDb ( original_id = ""  ) 

Saves a assJavaApplet object to a database.

Saves a assJavaApplet object to a database (experimental)

Parameters:
object $db A pear DB object public

Reimplemented from assQuestion.

Definition at line 589 of file class.assJavaApplet.php.

References $query, $result, ilRTE::_cleanupMediaObjectUsage(), ilRTE::_replaceMediaObjectImageSrc(), buildParams(), assQuestion::createPageObject(), assQuestion::getEstimatedWorkingTime(), assQuestion::getId(), getQuestionType(), assQuestion::getTestId(), assQuestion::insertIntoTest(), and isComplete().

Referenced by fromXML().

        {
                global $ilDB;

                $complete = 0;
                if ($this->isComplete())
                {
                        $complete = 1;
                }

                $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 = $ilDB->quote($original_id);
                }
                else
                {
                        $original_id = "NULL";
                }

                // cleanup RTE images which are not inserted into the question text
                include_once("./Services/RTE/classes/class.ilRTE.php");
                ilRTE::_cleanupMediaObjectUsage($this->question, "qpl:html",
                        $this->getId());

                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, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
                                $ilDB->quote($question_type . ""),
                                $ilDB->quote($this->obj_id . ""),
                                $ilDB->quote($this->title . ""),
                                $ilDB->quote($this->comment . ""),
                                $ilDB->quote($this->author . ""),
                                $ilDB->quote($this->owner . ""),
                                $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->question, 0)),
                                $ilDB->quote($this->points . ""),
                                $ilDB->quote($estw_time . ""),
                                $ilDB->quote($complete . ""),
                                $ilDB->quote($created . ""),
                                $original_id
                        );

                        $result = $ilDB->query($query);
                        if ($result == DB_OK)
                        {
                                $this->id = $ilDB->getLastInsertId();
                                $query = sprintf("INSERT INTO qpl_question_javaapplet (question_fi, image_file, params) VALUES (%s, %s, %s)",
                                        $ilDB->quote($this->id . ""),
                                        $ilDB->quote($this->javaapplet_filename . ""),
                                        $ilDB->quote($params . "")
                                );
                                $ilDB->query($query);

                                // create page object of question
                                $this->createPageObject();

                                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, complete = %s WHERE question_id = %s",
                                $ilDB->quote($this->obj_id. ""),
                                $ilDB->quote($this->title . ""),
                                $ilDB->quote($this->comment . ""),
                                $ilDB->quote($this->author . ""),
                                $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->question, 0)),
                                $ilDB->quote($this->points . ""),
                                $ilDB->quote($estw_time . ""),
                                $ilDB->quote($complete . ""),
                                $ilDB->quote($this->id . "")
                        );
                        $result = $ilDB->query($query);
                        $query = sprintf("UPDATE qpl_question_javaapplet SET image_file = %s, params = %s WHERE question_fi = %s",
                                $ilDB->quote($this->javaapplet_filename . ""),
                                $ilDB->quote($params . ""),
                                $ilDB->quote($this->id . "")
                        );
                        $result = $ilDB->query($query);
                }
                parent::saveToDb($original_id);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

assJavaApplet::saveWorkingData ( active_id,
pass = NULL 
)

Saves the learners input of the question to the database.

Saves the learners input of the question to the database

Parameters:
integer $test_id The database id of the test containing this question
Returns:
boolean Indicates the save status (true if saved successful, false otherwise) public
See also:
$answers

Reimplemented from assQuestion.

Definition at line 1233 of file class.assJavaApplet.php.

        {
    parent::saveWorkingData($active_id, $pass);
                return true;
  }

assJavaApplet::setJavaAppletFilename ( javaapplet_filename,
javaapplet_tempfilename = "" 
)

Sets the java applet file name.

Sets the java applet file name

Parameters:
string $javaapplet_file. public
See also:
$javaapplet_filename

Definition at line 1262 of file class.assJavaApplet.php.

References $javaapplet_filename, assQuestion::getJavaPath(), ilUtil::makeDirParents(), ilUtil::moveUploadedFile(), setJavaArchive(), and setJavaCodebase().

        {
                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!!!! ";
                        }
                        else
                        {
                                $this->setJavaCodebase();
                                $this->setJavaArchive();
                        }
                }
        }

Here is the call graph for this function:

assJavaApplet::setJavaArchive ( java_archive = ""  ) 

Sets the java applet archive parameter.

Sets the java applet archive parameter

Parameters:
string java applet archive parameter public

Definition at line 956 of file class.assJavaApplet.php.

References $java_archive.

Referenced by fromXML(), and setJavaAppletFilename().

        {
                $this->java_archive = $java_archive;
        }

Here is the caller graph for this function:

assJavaApplet::setJavaCode ( java_code = ""  ) 

Sets the java applet code parameter.

Sets the java applet code parameter

Parameters:
string java applet code parameter public

Definition at line 930 of file class.assJavaApplet.php.

References $java_code.

Referenced by fromXML().

        {
                $this->java_code = $java_code;
        }

Here is the caller graph for this function:

assJavaApplet::setJavaCodebase ( java_codebase = ""  ) 

Sets the java applet codebase parameter.

Sets the java applet codebase parameter

Parameters:
string java applet codebase parameter public

Definition at line 943 of file class.assJavaApplet.php.

References $java_codebase.

Referenced by fromXML(), and setJavaAppletFilename().

        {
                $this->java_codebase = $java_codebase;
        }

Here is the caller graph for this function:

assJavaApplet::setJavaHeight ( java_height = ""  ) 

Sets the java applet height parameter.

Sets the java applet height parameter

Parameters:
integer java applet height parameter public

Definition at line 1008 of file class.assJavaApplet.php.

References $java_height.

Referenced by fromXML().

        {
                $this->java_height = $java_height;
        }

Here is the caller graph for this function:

assJavaApplet::setJavaWidth ( java_width = ""  ) 

Sets the java applet width parameter.

Sets the java applet width parameter

Parameters:
integer java applet width parameter public

Definition at line 982 of file class.assJavaApplet.php.

References $java_width.

Referenced by fromXML().

        {
                $this->java_width = $java_width;
        }

Here is the caller graph for this function:

assJavaApplet::setQuestion ( question = ""  ) 

Sets the question text.

Sets the question string of the assJavaApplet object

Parameters:
string $question A string containing the question text public
See also:
$question

Definition at line 865 of file class.assJavaApplet.php.

References $question.

Referenced by fromXML().

        {
                $this->question = $question;
        }

Here is the caller graph for this function:

assJavaApplet::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

Parameters:
string $params All applet parameters in a list public

Definition at line 455 of file class.assJavaApplet.php.

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_codebase" :
                                                $this->java_codebase = $matches[2];
                                                break;
                                        case "java_archive" :
                                                $this->java_archive = $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:

assJavaApplet::syncWithOriginal (  ) 

Reimplemented from assQuestion.

Definition at line 1295 of file class.assJavaApplet.php.

References $query, $result, buildParams(), assQuestion::getEstimatedWorkingTime(), and isComplete().

        {
                global $ilDB;
                
                if ($this->original_id)
                {
                        $complete = 0;
                        if ($this->isComplete())
                        {
                                $complete = 1;
                        }
        
                        $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, complete = %s WHERE question_id = %s",
                                $ilDB->quote($this->obj_id. ""),
                                $ilDB->quote($this->title . ""),
                                $ilDB->quote($this->comment . ""),
                                $ilDB->quote($this->author . ""),
                                $ilDB->quote($this->question . ""),
                                $ilDB->quote($this->points . ""),
                                $ilDB->quote($estw_time . ""),
                                $ilDB->quote($complete . ""),
                                $ilDB->quote($this->original_id . "")
                        );
                        $result = $ilDB->query($query);
                        $params = $this->buildParams();
                        $query = sprintf("UPDATE qpl_question_javaapplet SET image_file = %s, params = %s WHERE question_fi = %s",
                                $ilDB->quote($this->javaapplet_filename . ""),
                                $ilDB->quote($params . ""),
                                $ilDB->quote($this->original_id . "")
                        );
                        $result = $ilDB->query($query);

                        parent::syncWithOriginal();
                }
        }

Here is the call graph for this function:

assJavaApplet::to_xml ( a_include_header = true,
a_include_binary = true,
a_shuffle = false,
test_output = false,
force_image_references = 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

Returns:
string The QTI xml representation of the question public

Definition at line 310 of file class.assJavaApplet.php.

References $key, $pos, assQuestion::addQTIMaterial(), buildParamsOnly(), assQuestion::getAuthor(), assQuestion::getComment(), assQuestion::getEstimatedWorkingTime(), getJavaAppletFilename(), getJavaHeight(), assQuestion::getJavaPath(), getJavaWidth(), assQuestion::getPoints(), getQuestion(), assQuestion::getSuggestedSolution(), and assQuestion::getTitle().

        {
                include_once("./classes/class.ilXmlWriter.php");
                $a_xml_writer = new ilXmlWriter;
                // set xml header
                $a_xml_writer->xmlHeader();
                $a_xml_writer->xmlStartTag("questestinterop");
                $attrs = array(
                        "ident" => "il_".IL_INST_ID."_qst_".$this->getId(),
                        "title" => $this->getTitle()
                );
                $a_xml_writer->xmlStartTag("item", $attrs);
                // add question description
                $a_xml_writer->xmlElement("qticomment", NULL, $this->getComment());
                // add estimated working time
                $workingtime = $this->getEstimatedWorkingTime();
                $duration = sprintf("P0Y0M0DT%dH%dM%dS", $workingtime["h"], $workingtime["m"], $workingtime["s"]);
                $a_xml_writer->xmlElement("duration", NULL, $duration);
                // add ILIAS specific metadata
                $a_xml_writer->xmlStartTag("itemmetadata");
                $a_xml_writer->xmlStartTag("qtimetadata");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "ILIAS_VERSION");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->ilias->getSetting("ilias_version"));
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "QUESTIONTYPE");
                $a_xml_writer->xmlElement("fieldentry", NULL, JAVAAPPLET_QUESTION_IDENTIFIER);
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "AUTHOR");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor());
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlEndTag("qtimetadata");
                $a_xml_writer->xmlEndTag("itemmetadata");

                // PART I: qti presentation
                $attrs = array(
                        "label" => $this->getTitle()
                );
                $a_xml_writer->xmlStartTag("presentation", $attrs);
                // add flow to presentation
                $a_xml_writer->xmlStartTag("flow");
                // add material with question text to presentation
                $this->addQTIMaterial($a_xml_writer, $this->getQuestion());
                $solution = $this->getSuggestedSolution(0);
                if (count($solution))
                {
                        if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
                        {
                                $a_xml_writer->xmlStartTag("material");
                                $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
                                if (strcmp($matches[1], "") != 0)
                                {
                                        $intlink = $solution["internal_link"];
                                }
                                $attrs = array(
                                        "label" => "suggested_solution"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $intlink);
                                $a_xml_writer->xmlEndTag("material");
                        }
                }

                $a_xml_writer->xmlStartTag("material");
                $attrs = array(
                        "label" => "applet data",
                        "uri" => $this->getJavaAppletFilename(),
                        "height" => $this->getJavaHeight(),
                        "width" => $this->getJavaWidth(),
                        "embedded" => "base64"
                );
                $javapath = $this->getJavaPath() . $this->getJavaAppletFilename();
                $fh = @fopen($javapath, "rb");
                if ($fh == false)
                {
                        return;
                }
                $javafile = fread($fh, filesize($javapath));
                fclose($fh);
                $base64 = base64_encode($javafile);
                $a_xml_writer->xmlElement("matapplet", $attrs, $base64);

                if ($this->buildParamsOnly())
                {
                        if ($this->java_code)
                        {
                                $attrs = array(
                                        "label" => "java_code"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $this->java_code);
                        }
                        if ($this->java_codebase)
                        {
                                $attrs = array(
                                        "label" => "java_codebase"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $this->java_codebase);
                        }
                        if ($this->java_archive)
                        {
                                $attrs = array(
                                        "label" => "java_archive"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $this->java_archive);
                        }
                        foreach ($this->parameters as $key => $value)
                        {
                                $attrs = array(
                                        "label" => $value["name"]
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $value["value"]);
                        }
                }
                $a_xml_writer->xmlEndTag("material");
                $a_xml_writer->xmlStartTag("material");
                $attrs = array(
                        "label" => "points"
                );
                $a_xml_writer->xmlElement("mattext", $attrs, $this->getPoints());
                $a_xml_writer->xmlEndTag("material");

                $a_xml_writer->xmlEndTag("flow");
                $a_xml_writer->xmlEndTag("presentation");
                
                $a_xml_writer->xmlEndTag("item");
                $a_xml_writer->xmlEndTag("questestinterop");

                $xml = $a_xml_writer->xmlDumpMem(FALSE);
                if (!$a_include_header)
                {
                        $pos = strpos($xml, "?>");
                        $xml = substr($xml, $pos + 2);
                }
                return $xml;
        }

Here is the call graph for this function:


Field Documentation

assJavaApplet::$java_archive

Definition at line 81 of file class.assJavaApplet.php.

Referenced by setJavaArchive().

assJavaApplet::$java_code

Definition at line 63 of file class.assJavaApplet.php.

Referenced by setJavaCode().

assJavaApplet::$java_codebase

Definition at line 72 of file class.assJavaApplet.php.

Referenced by setJavaCodebase().

assJavaApplet::$java_height

Definition at line 99 of file class.assJavaApplet.php.

Referenced by setJavaHeight().

assJavaApplet::$java_width

Definition at line 90 of file class.assJavaApplet.php.

Referenced by setJavaWidth().

assJavaApplet::$javaapplet_filename

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

Referenced by assJavaApplet(), and setJavaAppletFilename().

assJavaApplet::$parameters

Definition at line 108 of file class.assJavaApplet.php.

assJavaApplet::$question

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

Referenced by assJavaApplet(), and setQuestion().


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