Public Member Functions | Data Fields

ASS_JavaApplet Class Reference

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, $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 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.
 copyObject ($target_questionpool, $title="")
 Copies an ASS_JavaApplet 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.
 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, $pass=NULL)
 Returns the points, a learner has reached answering the question.
 getReachedInformation ($user_id, $test_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 ($test_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.
 syncWithOriginal ()
 getQuestionType ()
 Returns the question type of the question.

Data Fields

 $question
 $javaapplet_filename
 $java_code
 $java_width
 $java_height
 $parameters

Detailed Description

Class for Java Applet Questions.

ASS_JavaApplet is a class for Java Applet Questions.

Author:
Helmut Schottmüller <helmut.schottmueller@mac.com>
Version:
Id:
class.assJavaApplet.php 14645 2007-09-04 09:59:24Z hschottm

class.assJavaApplet.php Assessment

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


Member Function Documentation

ASS_JavaApplet::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 917 of file class.assJavaApplet.php.

References getParameterIndex().

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

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

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 941 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.

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:
ASS_Question:ASS_Question()

Definition at line 107 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

Returns:
string All applet parameters public

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

References $key.

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

Returns:
string All additional applet parameters public

Definition at line 401 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");
                }
                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,
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 817 of file class.assJavaApplet.php.

References $data, ASS_Question::$points, $query, $result, $row, ASS_Question::$test_id, $user_id, ASS_Question::getId(), getMaximumPoints(), and ASS_Question::getSolutionMaxPass().

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

Definition at line 672 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);
                $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:

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

Copies an ASS_JavaApplet object.

Copies an ASS_JavaApplet object

public

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

References ASS_Question::$title, ASS_Question::_getOriginalId(), and ASS_Question::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 = ASS_Question::_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);

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

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 581 of file class.assJavaApplet.php.

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

        {
                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 = 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($this_id);

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

Here is the call graph for this function:

ASS_JavaApplet::duplicateApplet ( question_id  ) 

Definition at line 658 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

See also:
$parameters

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

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

ASS_JavaApplet::getJavaAppletFilename (  ) 

Gets the java applet file name.

Gets the java applet file name

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

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

Referenced by copyApplet(), 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

Returns:
string java applet code parameter public

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

        {
                return $this->java_code;
        }

ASS_JavaApplet::getJavaHeight (  ) 

Returns the java applet height parameter.

Returns the java applet height parameter

Returns:
integer java applet height parameter public

Definition at line 788 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

Returns:
integer java applet width parameter public

Definition at line 762 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

See also:
$points

Reimplemented from ASS_Question.

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

Referenced by calculateReachedPoints(), and isComplete().

        {
                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

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

Definition at line 977 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

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

Definition at line 1017 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

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

ASS_JavaApplet::getQuestion (  ) 

Gets the multiple choice question.

Gets the question string of the ASS_JavaApplet object

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

Definition at line 696 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

Returns:
integer The question type of the question public

Definition at line 1139 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,
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 871 of file class.assJavaApplet.php.

References $counter, $data, $query, $result, ASS_Question::$test_id, $user_id, ASS_Question::getId(), and ASS_Question::getSolutionMaxPass().

Referenced by to_xml().

        {
                $found_values = array();
                if (is_null($pass))
                {
                        $pass = $this->getSolutionMaxPass($user_id, $test_id);
                }
                $query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
                        $this->ilias->db->quote($user_id . ""),
                        $this->ilias->db->quote($test_id . ""),
                        $this->ilias->db->quote($this->getId() . ""),
                        $this->ilias->db->quote($pass . "")
                );
                $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

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

Reimplemented from ASS_Question.

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

References 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
                {
                        return false;
                }
        }

Here is the call graph for this function:

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)

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 ASS_Question.

Definition at line 540 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

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

Definition at line 955 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;
                        }
                }
        }

ASS_JavaApplet::saveToDb ( original_id = ""  ) 

Saves a ASS_JavaApplet object to a database.

Saves a ASS_JavaApplet object to a database (experimental)

Parameters:
object $db A pear DB object public

Reimplemented from ASS_Question.

Definition at line 445 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().

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

ASS_JavaApplet::saveWorkingData ( test_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 ASS_Question.

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

References ASS_Question::$test_id.

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

ASS_JavaApplet::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 1074 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

Parameters:
string java applet code parameter public

Definition at line 749 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

Parameters:
integer java applet height parameter public

Definition at line 801 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

Parameters:
integer java applet width parameter public

Definition at line 775 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

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

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

References $question.

        {
                $this->question = $question;
        }

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

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

Definition at line 331 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 1096 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,
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 132 of file class.assJavaApplet.php.

References $_COOKIE, $ilUser, $key, $pos, $user_id, $xml, ilObjTest::_getHidePreviousResults(), ilObjTest::_getPass(), ilObjTest::_getTestType(), buildParamsOnly(), 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::getSolutionMaxPass(), ASS_Question::getSuggestedSolution(), ASS_Question::getTitle(), and ilUtil::removeTrailingPathSeparators().

        {
                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
                $a_xml_writer->xmlStartTag("material");
                $a_xml_writer->xmlElement("mattext", NULL, $this->getQuestion());
                $a_xml_writer->xmlEndTag("material");
                $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);
                        }
                        foreach ($this->parameters as $key => $value)
                        {
                                $attrs = array(
                                        "label" => $value["name"]
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $value["value"]);
                        }
                        if ($test_output)
                        {
                                include_once "./assessment/classes/class.ilObjTest.php";
                                $attrs = array(
                                        "label" => "test_type"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, ilObjTest::_getTestType($test_output));
                                $attrs = array(
                                        "label" => "test_id"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $test_output);
                                $attrs = array(
                                        "label" => "question_id"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $this->getId());
                                $attrs = array(
                                        "label" => "user_id"
                                );
                                global $ilUser;
                                $a_xml_writer->xmlElement("mattext", $attrs, $ilUser->id);
                                $attrs = array(
                                        "label" => "points_max"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $this->getPoints());
                                $attrs = array(
                                        "label" => "session_id"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, $_COOKIE["PHPSESSID"]);
                                $attrs = array(
                                        "label" => "client"
                                );
                                $a_xml_writer->xmlElement("mattext", $attrs, CLIENT_ID);
                                include_once "./assessment/classes/class.ilObjTest.php";
                                $attrs = array(
                                        "label" => "pass"
                                );
                                $pass = ilObjTest::_getPass($ilUser->id, $test_output);
                                $a_xml_writer->xmlElement("mattext", $attrs, $pass);
                                $attrs = array(
                                        "label" => "post_url"
                                );
//                              $a_xml_writer->xmlElement("mattext", $attrs, "http://localhost/ilias36x/assessment/save_java_question_result.php");
                                $a_xml_writer->xmlElement("mattext", $attrs, ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/assessment/save_java_question_result.php");

                                $info = array();
                                if (ilObjTest::_getHidePreviousResults($test_output, true))
                                {
                                        $info = $this->getReachedInformation($ilUser->id, $test_output, $pass);
                                }
                                else
                                {
                                        $pass = $this->getSolutionMaxPass($user_id, $test_output);
                                        $info = $this->getReachedInformation($ilUser->id, $test_output, $pass);
                                }
                                foreach ($info as $kk => $infodata)
                                {
                                        $attrs = array(
                                                "label" => "value_" . $infodata["order"] . "_1"
                                        );
                                        $a_xml_writer->xmlElement("mattext", $attrs, $infodata["value1"]);
                                        $attrs = array(
                                                "label" => "value_" . $infodata["order"] . "_2"
                                        );
                                        $a_xml_writer->xmlElement("mattext", $attrs, $infodata["value2"]);
                                }
                        }
                }
                $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

ASS_JavaApplet::$java_code

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

Referenced by setJavaCode().

ASS_JavaApplet::$java_height

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

Referenced by setJavaHeight().

ASS_JavaApplet::$java_width

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

Referenced by setJavaWidth().

ASS_JavaApplet::$javaapplet_filename

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

Referenced by ASS_JavaApplet(), and setJavaAppletFilename().

ASS_JavaApplet::$parameters

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

ASS_JavaApplet::$question

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

Referenced by ASS_JavaApplet(), and setQuestion().


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