Public Member Functions | Data Fields

ASS_TextQuestion Class Reference

Class for text questions. More...

Inheritance diagram for ASS_TextQuestion:
Collaboration diagram for ASS_TextQuestion:

Public Member Functions

 ASS_TextQuestion ($title="", $comment="", $author="", $owner=-1, $question="")
 ASS_TextQuestion constructor.
 isComplete ()
 Returns true, if a multiple choice question is complete for use.
 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.
 saveToDb ($original_id="")
 Saves a ASS_TextQuestion object to a database.
 loadFromDb ($question_id)
 Loads a ASS_TextQuestion object from a database.
 duplicate ($for_test=true, $title="", $author="", $owner="")
 Duplicates an ASS_TextQuestion.
 copyObject ($target_questionpool, $title="")
 Copies an ASS_TextQuestion object.
 get_question ()
 Gets the text question.
 set_question ($question="")
 Sets the text question.
 getMaxNumOfChars ()
 Gets the maximum number of characters for the text solution.
 setMaxNumOfChars ($maxchars=0)
 Sets the maximum number of characters for the text solution.
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 setReachedPoints ($user_id, $test_id, $points, $pass=NULL)
 Sets the points, a learner has reached answering the question.
 _setReachedPoints ($user_id, $test_id, $question_id, $points, $maxpoints, $pass=NULL)
 Sets the points, a learner has reached answering the question Additionally objective results are updated.
 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.
 saveWorkingData ($test_id, $pass=NULL)
 Saves the learners input of the question to the database.
 syncWithOriginal ()
 createRandomSolution ($test_id, $user_id)
 getQuestionType ()
 Returns the question type of the question.

Data Fields

 $question
 $maxNumOfChars

Detailed Description

Class for text questions.

ASS_TextQuestion is a class for text questions

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

class.assTextQuestion.php Assessment

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


Member Function Documentation

ASS_TextQuestion::_setReachedPoints ( user_id,
test_id,
question_id,
points,
maxpoints,
pass = NULL 
)

Sets the points, a learner has reached answering the question Additionally objective results are updated.

Sets the points, a learner has reached answering the question

Parameters:
integer $user_id The database ID of the learner
integer $test_id The database Id of the test containing the question
integer $points The points the user has reached answering the question
Returns:
boolean true on success, otherwise false public

Definition at line 570 of file class.assTextQuestion.php.

References ASS_Question::$points, $query, $result, ASS_Question::$test_id, $user_id, ASS_Question::_getSolutionMaxPass(), and ilCourseObjectiveResult::_updateUserResult().

Referenced by ilTestEvaluationGUI::evalSelectedUsers().

        {
                global $ilDB;
                
                if ($points <= $maxpoints)
                {
                        if (is_null($pass))
                        {
                                include_once "./assessment/classes/class.assQuestion.php";
                                $pass = ASS_Question::_getSolutionMaxPass($question_id, $user_id, $test_id);
                        }
                        $query = sprintf("UPDATE tst_test_result SET points = %s WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
                                $ilDB->quote($points . ""),
                                $ilDB->quote($user_id . ""),
                                $ilDB->quote($test_id . ""),
                                $ilDB->quote($question_id . ""),
                                $ilDB->quote($pass . "")
                        );
                        $result = $this->ilias->db->query($query);

                        // finally update objective result
                        include_once 'course/classes/class.ilCourseObjectiveResult.php';
                        ilCourseObjectiveResult::_updateUserResult($user_id,$question_id,$points);

                        return true;
                }
                        else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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

ASS_TextQuestion constructor.

The constructor takes possible arguments an creates an instance of the ASS_TextQuestion 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 text question public
See also:
ASS_Question:ASS_Question()

Definition at line 69 of file class.assTextQuestion.php.

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

        {
                $this->ASS_Question($title, $comment, $author, $owner);
                $this->question = $question;
                $this->maxNumOfChars = 0;
                $this->points = 0;
        }

Here is the call graph for this function:

ASS_TextQuestion::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 613 of file class.assTextQuestion.php.

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

        {
                global $ilDB;

                $points = 0;
                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);
                if ($result->numRows() == 1)
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        if ($row["points"])
                        {
                                $points = $row["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_TextQuestion::copyObject ( target_questionpool,
title = "" 
)

Copies an ASS_TextQuestion object.

Copies an ASS_TextQuestion object

public

Definition at line 421 of file class.assTextQuestion.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);

                return $clone->id;
        }

Here is the call graph for this function:

ASS_TextQuestion::createRandomSolution ( test_id,
user_id 
)

Reimplemented from ASS_Question.

Definition at line 788 of file class.assTextQuestion.php.

        {
        }

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

Duplicates an ASS_TextQuestion.

Duplicates an ASS_TextQuestion

public

Definition at line 372 of file class.assTextQuestion.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);

                return $clone->id;
        }

Here is the call graph for this function:

ASS_TextQuestion::get_question (  ) 

Gets the text question.

Gets the question string of the ASS_TextQuestion object

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

Definition at line 456 of file class.assTextQuestion.php.

Referenced by to_xml().

        {
                return $this->question;
        }

Here is the caller graph for this function:

ASS_TextQuestion::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 518 of file class.assTextQuestion.php.

Referenced by calculateReachedPoints(), and isComplete().

        {
                return $this->points;
        }

Here is the caller graph for this function:

ASS_TextQuestion::getMaxNumOfChars (  ) 

Gets the maximum number of characters for the text solution.

Gets the maximum number of characters for the text solution

Returns:
integer The maximum number of characters for the text solution public
See also:
$maxNumOfChars

Definition at line 484 of file class.assTextQuestion.php.

Referenced by saveToDb(), saveWorkingData(), and to_xml().

        {
                if (strcmp($this->maxNumOfChars, "") == 0)
                {
                        return 0;
                }
                else
                {
                        return $this->maxNumOfChars;
                }
        }

Here is the caller graph for this function:

ASS_TextQuestion::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 800 of file class.assTextQuestion.php.

Referenced by saveToDb().

        {
                return 8;
        }

Here is the caller graph for this function:

ASS_TextQuestion::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 670 of file class.assTextQuestion.php.

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

        {
                $found_values = array();
                $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);
                $user_result = array();
                while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $user_result = array(
                                "value" => $data->value1
                        );
                }
                return $user_result;
        }

Here is the call graph for this function:

ASS_TextQuestion::isComplete (  ) 

Returns true, if a multiple choice question is complete for use.

Returns true, if a multiple choice question is complete for use

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

Reimplemented from ASS_Question.

Definition at line 91 of file class.assTextQuestion.php.

References getMaximumPoints().

Referenced by saveToDb(), and syncWithOriginal().

        {
                if (($this->title) and ($this->author) and ($this->question) 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_TextQuestion::loadFromDb ( question_id  ) 

Loads a ASS_TextQuestion object from a database.

Loads a ASS_TextQuestion object from a database

Parameters:
object $db A pear DB object
integer $question_id A unique key which defines the text question in the database public

Reimplemented from ASS_Question.

Definition at line 335 of file class.assTextQuestion.php.

References $data, ASS_Question::$ilias, $query, $result, and ASS_Question::setEstimatedWorkingTime().

        {
                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->solution_hint = $data->solution_hint;
                                $this->original_id = $data->original_id;
                                $this->obj_id = $data->obj_fi;
                                $this->author = $data->author;
                                $this->owner = $data->owner;
                                $this->question = $data->question_text;
                                $this->maxNumOfChars = $data->maxNumOfChars;
                                $this->points = $data->points;
                                $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_TextQuestion::saveToDb ( original_id = ""  ) 

Saves a ASS_TextQuestion object to a database.

Saves a ASS_TextQuestion object to a database

Parameters:
object $db A pear DB object public

Reimplemented from ASS_Question.

Definition at line 246 of file class.assTextQuestion.php.

References ASS_Question::$ilias, $query, $result, ASS_Question::createPageObject(), ASS_Question::getEstimatedWorkingTime(), getMaxNumOfChars(), ASS_Question::getPoints(), getQuestionType(), ASS_Question::getTestId(), ASS_Question::insertIntoTest(), and isComplete().

        {
                global $ilias;

                $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']);

                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, points, question_text, working_time, maxNumOfChars, complete, created, original_id, TIMESTAMP) VALUES (NULL, %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->getPoints() . ""),
                                $db->quote($this->question),
                                $db->quote($estw_time),
                                $db->quote($this->getMaxNumOfChars()),
                                $db->quote("$complete"),
                                $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, points = %s, question_text = %s, working_time=%s, maxNumOfChars = %s, complete = %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->getPoints() . ""),
                                $db->quote($this->question),
                                $db->quote($estw_time),
                                $db->quote($this->getMaxNumOfChars()),
                                $db->quote("$complete"),
                                $db->quote($this->id)
                        );
                        $result = $db->query($query);
                }
                parent::saveToDb($original_id);
        }

Here is the call graph for this function:

ASS_TextQuestion::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 700 of file class.assTextQuestion.php.

References $_POST, $ilUser, $query, $result, ASS_Question::$test_id, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), ilObjTest::_getPass(), ASS_Question::getId(), getMaxNumOfChars(), ASS_Question::logAction(), and ilUtil::stripSlashes().

        {
                global $ilDB;
                global $ilUser;

                $db =& $ilDB->db;

                include_once "./assessment/classes/class.ilObjTest.php";
                $activepass = ilObjTest::_getPass($ilUser->id, $test_id);
                
                $query = sprintf("DELETE FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
                        $db->quote($ilUser->id . ""),
                        $db->quote($test_id . ""),
                        $db->quote($this->getId() . ""),
                        $db->quote($activepass . "")
                );
                $result = $db->query($query);

                $text = ilUtil::stripSlashes($_POST["TEXT"]);
                if ($this->getMaxNumOfChars())
                {
                        $text = substr($text, 0, $this->getMaxNumOfChars()); 
                }
                $entered_values = 0;
                if (strlen($text))
                {
                        $query = sprintf("INSERT INTO tst_solutions (solution_id, user_fi, test_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL, %s, NULL)",
                                $db->quote($ilUser->id . ""),
                                $db->quote($test_id . ""),
                                $db->quote($this->getId() . ""),
                                $db->quote($text . ""),
                                $db->quote($activepass . "")
                        );
                        $result = $db->query($query);
                        $entered_values++;
                }
                if ($entered_values)
                {
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $test_id, $this->getId());
                        }
                }
                else
                {
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $test_id, $this->getId());
                        }
                }
    parent::saveWorkingData($test_id, $pass);
                return true;
        }

Here is the call graph for this function:

ASS_TextQuestion::set_question ( question = ""  ) 

Sets the text question.

Sets the question string of the ASS_TextQuestion object

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

Definition at line 470 of file class.assTextQuestion.php.

References $question.

        {
                $this->question = $question;
        }

ASS_TextQuestion::setMaxNumOfChars ( maxchars = 0  ) 

Sets the maximum number of characters for the text solution.

Sets the maximum number of characters for the text solution

Parameters:
integer $maxchars The maximum number of characters for the text solution public
See also:
$maxNumOfChars

Definition at line 505 of file class.assTextQuestion.php.

        {
                $this->maxNumOfChars = $maxchars;
        }

ASS_TextQuestion::setReachedPoints ( user_id,
test_id,
points,
pass = NULL 
)

Sets the points, a learner has reached answering the question.

Sets the points, a learner has reached answering the question

Parameters:
integer $user_id The database ID of the learner
integer $test_id The database Id of the test containing the question
integer $points The points the user has reached answering the question
Returns:
boolean true on success, otherwise false public

Definition at line 534 of file class.assTextQuestion.php.

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

        {
                if (($points > 0) && ($points <= $this->getPoints()))
                {
                        if (is_null($pass))
                        {
                                $pass = $this->getSolutionMaxPass($user_id, $test_id);
                        }
                        $query = sprintf("UPDATE tst_test_result SET points = %s WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
                                $this->ilias->db->quote($points . ""),
                                $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);
                        return true;
                }
                        else
                {
                        return false;
                }
        }

Here is the call graph for this function:

ASS_TextQuestion::syncWithOriginal (  ) 

Reimplemented from ASS_Question.

Definition at line 756 of file class.assTextQuestion.php.

References ASS_Question::$ilias, $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, working_time=%s, maxNumOfChars = %s, complete = %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($estw_time. ""),
                                $db->quote($this->maxNumOfChars. ""),
                                $db->quote($complete. ""),
                                $db->quote($this->original_id. "")
                        );
                        $result = $db->query($query);

                        parent::syncWithOriginal();
                }
        }

Here is the call graph for this function:

ASS_TextQuestion::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 112 of file class.assTextQuestion.php.

References $pos, $xml, get_question(), ASS_Question::getAuthor(), ASS_Question::getComment(), ASS_Question::getEstimatedWorkingTime(), getMaxNumOfChars(), ASS_Question::getPoints(), ASS_Question::getSuggestedSolution(), and ASS_Question::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, TEXT_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->get_question());
                $a_xml_writer->xmlEndTag("material");
                // add information on response rendering
                $attrs = array(
                        "ident" => "TEXT",
                        "rcardinality" => "Ordered"
                );
                $a_xml_writer->xmlStartTag("response_str", $attrs);
                $attrs = array(
                        "fibtype" => "String",
                        "prompt" => "Box"
                );
                if ($this->getMaxNumOfChars() > 0)
                {
                        $attrs["maxchars"] = $this->getMaxNumOfChars();
                }
                $a_xml_writer->xmlStartTag("render_fib", $attrs);
                $attrs = array(
                        "ident" => "A"
                );
                $a_xml_writer->xmlStartTag("response_label", $attrs);
                $a_xml_writer->xmlEndTag("response_label");
                $a_xml_writer->xmlEndTag("render_fib");

                $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->xmlEndTag("response_str");
                $a_xml_writer->xmlEndTag("flow");
                $a_xml_writer->xmlEndTag("presentation");

                // PART II: qti resprocessing
                $attrs = array(
                        "scoremodel" => "HumanRater"
                );
                $a_xml_writer->xmlStartTag("resprocessing", $attrs);
                $a_xml_writer->xmlStartTag("outcomes");
                $attrs = array(
                        "varname" => "WritingScore",
                        "vartype" => "Integer",
                        "minvalue" => "0",
                        "maxvalue" => $this->getPoints()
                );
                $a_xml_writer->xmlStartTag("decvar", $attrs);
                $a_xml_writer->xmlEndTag("decvar");
                $a_xml_writer->xmlEndTag("outcomes");

                $a_xml_writer->xmlStartTag("respcondition");
                $a_xml_writer->xmlStartTag("conditionvar");
                $a_xml_writer->xmlElement("other", NULL, "tutor_rated");
                $a_xml_writer->xmlEndTag("conditionvar");
                $a_xml_writer->xmlEndTag("respcondition");
                $a_xml_writer->xmlEndTag("resprocessing");

                $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_TextQuestion::$maxNumOfChars

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

ASS_TextQuestion::$question

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

Referenced by ASS_TextQuestion(), and set_question().


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