Public Member Functions | Data Fields

ASS_ImagemapQuestion Class Reference

Class for image map questions. More...

Inheritance diagram for ASS_ImagemapQuestion:
Collaboration diagram for ASS_ImagemapQuestion:

Public Member Functions

 ASS_ImagemapQuestion ($title="", $comment="", $author="", $owner=-1, $question="", $imagemap_filename="", $image_filename="")
 ASS_ImagemapQuestion constructor.
 isComplete ()
 Returns true, if a imagemap question is complete for use.
 saveToDb ($original_id="")
 Saves a ASS_ImagemapQuestion object to a database.
 duplicate ($for_test=true, $title="", $author="", $owner="")
 Duplicates an ASS_ImagemapQuestion.
 copyObject ($target_questionpool, $title="")
 Copies an ASS_ImagemapQuestion object.
 duplicateImage ($question_id)
 copyImage ($question_id, $source_questionpool)
 loadFromDb ($question_id)
 Loads a ASS_ImagemapQuestion object from a database.
 addAnswer ($answertext, $points, $answerorder, $correctness, $coords, $area)
 Adds an answer to the question.
 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.
 get_question ()
 Gets the imagemap question.
 set_question ($question="")
 Sets the imagemap question.
 get_imagemap_filename ()
 Gets the imagemap file name.
 set_imagemap_filename ($imagemap_filename, $imagemap_tempfilename="")
 Sets the imagemap file name.
 get_image_filename ()
 Gets the image file name.
 set_image_filename ($image_filename, $image_tempfilename="")
 Sets the image file name.
 get_imagemap_contents ($href="#")
 Gets the imagemap file contents.
 add_answer ($answertext="", $points=0.0, $status=0, $order=0, $coords="", $area="")
 Adds a possible answer for a imagemap question.
 get_answer_count ()
 Returns the number of answers.
 get_answer ($index=0)
 Returns an answer.
 deleteArea ($index=0)
 Deletes an answer.
 flush_answers ()
 Deletes all answers.
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 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 ()
 getQuestionType ()
 Returns the question type of the question.

Data Fields

 $question
 $answers
 $imagemap_filename
 $image_filename
 $imagemap_contents
 $coords

Detailed Description

Class for image map questions.

ASS_ImagemapQuestion is a class for imagemap question.

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

class.assImagemapQuestion.php Assessment

Definition at line 37 of file class.assImagemapQuestion.php.


Member Function Documentation

ASS_ImagemapQuestion::add_answer ( answertext = "",
points = 0.0,
status = 0,
order = 0,
coords = "",
area = "" 
)

Adds a possible answer for a imagemap question.

Adds a possible answer for a imagemap question. A ASS_AnswerImagemap object will be created and assigned to the array $this->answers.

Parameters:
string $answertext The answer text
double $points The points for selecting the answer (even negative points can be used)
integer $status The state of the answer (set = 1 or unset = 0)
integer $order A possible display order of the answer public
See also:
$answers
ASS_AnswerImagemap

Definition at line 832 of file class.assImagemapQuestion.php.

References $coords, ASS_Question::$points, and $status.

Referenced by set_imagemap_filename().

  {
                include_once "./assessment/classes/class.assAnswerImagemap.php";
    if (array_key_exists($order, $this->answers)) 
                {
      // Antwort einf�gen
      $answer = new ASS_AnswerImagemap($answertext, $points, $order, $status, $coords, $area);
                        for ($i = count($this->answers) - 1; $i >= $order; $i--) 
                        {
                                $this->answers[$i+1] = $this->answers[$i];
                                $this->answers[$i+1]->set_order($i+1);
                        }
                        $this->answers[$order] = $answer;
    }
                else 
                {
      // Anwort anh�ngen
      $answer = new ASS_AnswerImagemap($answertext, $points, count($this->answers), $status, $coords, $area);
      array_push($this->answers, $answer);
    }
  }

Here is the caller graph for this function:

ASS_ImagemapQuestion::addAnswer ( answertext,
points,
answerorder,
correctness,
coords,
area 
)

Adds an answer to the question.

Adds an answer to the question

public

Definition at line 426 of file class.assImagemapQuestion.php.

References $coords, and ASS_Question::$points.

        {
                include_once "./assessment/classes/class.assAnswerImagemap.php";
                array_push($this->answers, new ASS_AnswerImagemap($answertext, $points, $answerorder, $correctness, $coords, $area));
        }

ASS_ImagemapQuestion::ASS_ImagemapQuestion ( title = "",
comment = "",
author = "",
owner = -1,
question = "",
imagemap_filename = "",
image_filename = "" 
)

ASS_ImagemapQuestion constructor.

The constructor takes possible arguments an creates an instance of the ASS_ImagemapQuestion 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 $imagemap_file The imagemap file name of the imagemap question
string $image_file The image file name of the imagemap question
string $question The question string of the imagemap question public

Definition at line 100 of file class.assImagemapQuestion.php.

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

  {
    $this->ASS_Question($title, $comment, $author, $owner);
    $this->question = $question;
    $this->imagemap_filename = $imagemap_filename;
    $this->image_filename = $image_filename;
    $this->answers = array();
                $this->coords = array();
  }

Here is the call graph for this function:

ASS_ImagemapQuestion::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 957 of file class.assImagemapQuestion.php.

References $data, $key, 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);
                while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if (strcmp($data->value1, "") != 0)
                        {
                                array_push($found_values, $data->value1);
                        }
                }
                $points = 0;
                if (count($found_values) > 0)
                {
                        foreach ($this->answers as $key => $answer)
                        {
                                if ($answer->isStateChecked())
                                {
                                        if (in_array($key, $found_values))
                                        {
                                                $points += $answer->get_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_ImagemapQuestion::copyImage ( question_id,
source_questionpool 
)

Definition at line 347 of file class.assImagemapQuestion.php.

References get_image_filename(), ASS_Question::getImagePath(), and ilUtil::makeDirParents().

        {
                $imagepath = $this->getImagePath();
                $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
                $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
                if (!file_exists($imagepath)) 
                {
                        ilUtil::makeDirParents($imagepath);
                }
                $filename = $this->get_image_filename();
                if (!copy($imagepath_original . $filename, $imagepath . $filename)) 
                {
                        print "image could not be copied!!!! ";
                }
        }

Here is the call graph for this function:

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

Copies an ASS_ImagemapQuestion object.

Copies an ASS_ImagemapQuestion object

public

Definition at line 306 of file class.assImagemapQuestion.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->copyImage($original_id, $source_questionpool);
                return $clone->id;
        }

Here is the call graph for this function:

ASS_ImagemapQuestion::deleteArea ( index = 0  ) 

Deletes an answer.

Deletes an area with a given index. The index of the first area is 0, the index of the second area is 1 and so on.

Parameters:
integer $index A nonnegative index of the n-th answer public
See also:
$answers

Definition at line 902 of file class.assImagemapQuestion.php.

                                  {
    if ($index < 0) return;
    if (count($this->answers) < 1) return;
    if ($index >= count($this->answers)) return;
    unset($this->answers[$index]);
    $this->answers = array_values($this->answers);
    for ($i = 0; $i < count($this->answers); $i++) {
      if ($this->answers[$i]->get_order() > $index) {
        $this->answers[$i]->set_order($i);
      }
    }
  }

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

Duplicates an ASS_ImagemapQuestion.

Duplicates an ASS_ImagemapQuestion

public

Definition at line 257 of file class.assImagemapQuestion.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->duplicateImage($this_id);
                return $clone->id;
        }

Here is the call graph for this function:

ASS_ImagemapQuestion::duplicateImage ( question_id  ) 

Definition at line 334 of file class.assImagemapQuestion.php.

References get_image_filename(), ASS_Question::getImagePath(), and ilUtil::makeDirParents().

        {
                $imagepath = $this->getImagePath();
                $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
                if (!file_exists($imagepath)) {
                        ilUtil::makeDirParents($imagepath);
                }
                $filename = $this->get_image_filename();
                if (!copy($imagepath_original . $filename, $imagepath . $filename)) {
                        print "image could not be duplicated!!!! ";
                }
        }

Here is the call graph for this function:

ASS_ImagemapQuestion::flush_answers (  ) 

Deletes all answers.

Deletes all answers

public

See also:
$answers

Definition at line 923 of file class.assImagemapQuestion.php.

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

ASS_ImagemapQuestion::get_answer ( index = 0  ) 

Returns an answer.

Returns an answer with a given index. The index of the first answer is 0, the index of the second answer is 1 and so on.

Parameters:
integer $index A nonnegative index of the n-th answer
Returns:
object ASS_AnswerImagemap-Object containing the answer public
See also:
$answers

Definition at line 885 of file class.assImagemapQuestion.php.

                                  {
    if ($index < 0) return NULL;
    if (count($this->answers) < 1) return NULL;
    if ($index >= count($this->answers)) return NULL;
    return $this->answers[$index];
  }

ASS_ImagemapQuestion::get_answer_count (  ) 

Returns the number of answers.

Returns the number of answers

Returns:
integer The number of answers of the multiple choice question public
See also:
$answers

Definition at line 870 of file class.assImagemapQuestion.php.

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

ASS_ImagemapQuestion::get_image_filename (  ) 

Gets the image file name.

Gets the image file name

Returns:
string The image file name of the ASS_ImagemapQuestion object public
See also:
$image_filename

Definition at line 764 of file class.assImagemapQuestion.php.

Referenced by copyImage(), duplicateImage(), and to_xml().

                                {
    return $this->image_filename;
  }

Here is the caller graph for this function:

ASS_ImagemapQuestion::get_imagemap_contents ( href = "#"  ) 

Gets the imagemap file contents.

Gets the imagemap file contents

Returns:
string The imagemap file contents of the ASS_ImagemapQuestion object public
See also:
$imagemap_contents

Definition at line 806 of file class.assImagemapQuestion.php.

References $imagemap_contents.

                                              {
                $imagemap_contents = "<map name=\"".$this->title."\"> ";
                for ($i = 0; $i < count($this->answers); $i++) {
                        $imagemap_contents .= "<area alt=\"".$this->answers[$i]->get_answertext()."\" ";
                        $imagemap_contents .= "shape=\"".$this->answers[$i]->get_area()."\" ";
                        $imagemap_contents .= "coords=\"".$this->answers[$i]->get_coords()."\" ";
                        $imagemap_contents .= "href=\"$href&selimage=" . $this->answers[$i]->get_order() . "\" /> ";
                }
                $imagemap_contents .= "</map>";
    return $imagemap_contents;
  }

ASS_ImagemapQuestion::get_imagemap_filename (  ) 

Gets the imagemap file name.

Gets the imagemap file name

Returns:
string The imagemap file of the ASS_ImagemapQuestion object public
See also:
$imagemap_filename

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

                                   {
    return $this->imagemap_filename;
  }

ASS_ImagemapQuestion::get_question (  ) 

Gets the imagemap question.

Gets the question string of the ASS_ImagemapQuestion object

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

Definition at line 697 of file class.assImagemapQuestion.php.

Referenced by to_xml().

                          {
    return $this->question;
  }

Here is the caller graph for this function:

ASS_ImagemapQuestion::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 935 of file class.assImagemapQuestion.php.

References $key, and ASS_Question::$points.

Referenced by calculateReachedPoints(), isComplete(), saveToDb(), and syncWithOriginal().

                              {
                $points = array("set" => 0, "unset" => 0);
                foreach ($this->answers as $key => $value) {
                        if ($value->get_points() > $points["set"])
                        {
                                $points["set"] = $value->get_points();
                        }
                }
                return $points["set"];
  }

Here is the caller graph for this function:

ASS_ImagemapQuestion::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 1191 of file class.assImagemapQuestion.php.

Referenced by saveToDb().

        {
                return 6;
        }

Here is the caller graph for this function:

ASS_ImagemapQuestion::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 1027 of file class.assImagemapQuestion.php.

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

        {
    $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);
                while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        array_push($found_values, $data->value1);
                }
                $counter = 1;
                $user_result = array();
                foreach ($found_values as $key => $value)
                {
                        $solution = array(
                                "order" => "$counter",
                                "points" => 0,
                                "true" => 0,
                                "value" => "",
                                );
                        if (strlen($value) > 0)
                        {
                                $solution["value"] = $value;
                                $solution["points"] = $this->answers[$value]->get_points();
                                if ($this->answers[$value]->isStateChecked())
                                {
                                        $solution["true"] = 1;
                                }
                        }
                        $counter++;
                        array_push($user_result, $solution);
                }
                return $user_result;
  }

Here is the call graph for this function:

ASS_ImagemapQuestion::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 127 of file class.assImagemapQuestion.php.

References getMaximumPoints().

Referenced by saveToDb(), and syncWithOriginal().

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

Loads a ASS_ImagemapQuestion object from a database.

Loads a ASS_ImagemapQuestion 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 372 of file class.assImagemapQuestion.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->obj_id = $data->obj_fi;
        $this->title = $data->title;
        $this->comment = $data->comment;
        $this->author = $data->author;
                                $this->original_id = $data->original_id;
                                $this->solution_hint = $data->solution_hint;
        $this->owner = $data->owner;
        $this->question = $data->question_text;
        $this->image_filename = $data->image_file;
        $this->points = $data->points;
        $this->setEstimatedWorkingTime(substr($data->working_time, 0, 2), substr($data->working_time, 3, 2), substr($data->working_time, 6, 2));
      }
      $query = sprintf("SELECT * FROM qpl_answers WHERE question_fi = %s ORDER BY aorder ASC",
        $db->quote($question_id)
      );
      $result = $db->query($query);
                        include_once "./assessment/classes/class.assAnswerImagemap.php";
      if (strcmp(strtolower(get_class($result)), db_result) == 0) 
                        {
        while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) 
                                {
                                        if ($data->correctness == 0)
                                        {
                                                // fix for older single response answers where points could be given for unchecked answers
                                                $data->correctness = 1;
                                                $data->points = 0;
                                        }
          array_push($this->answers, new ASS_AnswerImagemap($data->answertext, $data->points, $data->aorder, $data->correctness, $data->coords, $data->area));
        }
      }
    }
                parent::loadFromDb($question_id);
  }

Here is the call graph for this function:

ASS_ImagemapQuestion::saveToDb ( original_id = ""  ) 

Saves a ASS_ImagemapQuestion object to a database.

Saves a ASS_ImagemapQuestion object to a database (experimental)

Parameters:
object $db A pear DB object public

Reimplemented from ASS_Question.

Definition at line 147 of file class.assImagemapQuestion.php.

References ASS_Question::$ilias, $key, $query, $result, ASS_Question::createPageObject(), ASS_Question::getEstimatedWorkingTime(), getMaximumPoints(), 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, question_text, working_time, points, image_file, 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->question),
                                $db->quote($estw_time),
                                $db->quote($this->getMaximumPoints() . ""),
                                $db->quote($this->image_filename),
                                $db->quote("$complete"),
                                $db->quote($created),
                                $original_id
                        );
                        $result = $db->query($query);
                        if ($result == DB_OK)
                        {
                                $this->id = $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, working_time = %s, points = %s, image_file = %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->getMaximumPoints() . ""),
                                $db->quote($this->image_filename),
                                $db->quote("$complete"),
                                $db->quote($this->id)
                        );
                        $result = $db->query($query);
                }

                if ($result == DB_OK)
                {
                        $query = sprintf("DELETE FROM qpl_answers WHERE question_fi = %s",
                                $db->quote($this->id)
                        );
                        $result = $db->query($query);
                        // Anworten wegschreiben
                        foreach ($this->answers as $key => $value)
                        {
                                $answer_obj = $this->answers[$key];
                                //print "id:".$this->id." answer tex:".$answer_obj->get_answertext()." answer_obj->get_order():".$answer_obj->get_order()." answer_obj->get_coords():".$answer_obj->get_coords()." answer_obj->get_area():".$answer_obj->get_area();
                                $query = sprintf("INSERT INTO qpl_answers (answer_id, question_fi, answertext, points, aorder, correctness, coords, area, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, NULL)",
                                        $db->quote($this->id),
                                        $db->quote($answer_obj->get_answertext() . ""),
                                        $db->quote($answer_obj->get_points() . ""),
                                        $db->quote($answer_obj->get_order() . ""),
                                        $db->quote($answer_obj->getState() . ""),
                                        $db->quote($answer_obj->get_coords() . ""),
                                        $db->quote($answer_obj->get_area() . "")
                                        );
                                $answer_result = $db->query($query);
                                }
                }
                parent::saveToDb($original_id);
        }

Here is the call graph for this function:

ASS_ImagemapQuestion::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 1080 of file class.assImagemapQuestion.php.

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

        {
    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);

                if (strlen($_GET["selImage"]))
                {
                        $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($_GET["selImage"]),
                                $db->quote($activepass . "")
                        );
                        $result = $db->query($query);

                        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_ImagemapQuestion::set_image_filename ( image_filename,
image_tempfilename = "" 
)

Sets the image file name.

Sets the image file name

Parameters:
string $image_file name. public
See also:
$image_filename

Definition at line 777 of file class.assImagemapQuestion.php.

References $image_filename, ASS_Question::getImagePath(), ilUtil::makeDirParents(), and ilUtil::moveUploadedFile().

                                                                         {

    if (!empty($image_filename)) 
                {
                        $image_filename = str_replace(" ", "_", $image_filename);
      $this->image_filename = $image_filename;
    }
                if (!empty($image_tempfilename)) {
                        $imagepath = $this->getImagePath();
                        if (!file_exists($imagepath)) {
                                ilUtil::makeDirParents($imagepath);
                        }
                        
                        if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $imagepath.$image_filename))
                        {
                                $this->ilias->raiseError("The image could not be uploaded!", $this->ilias->error_obj->MESSAGE);
                        }
                }
  }

Here is the call graph for this function:

ASS_ImagemapQuestion::set_imagemap_filename ( imagemap_filename,
imagemap_tempfilename = "" 
)

Sets the imagemap file name.

Sets the imagemap file name

Parameters:
string $imagemap_file. public
See also:
$imagemap_filename

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

References $coords, $imagemap_filename, and add_answer().

                                                                                  {
    if (!empty($imagemap_filename)) {
      $this->imagemap_filename = $imagemap_filename;
    }
    if (!empty($imagemap_tempfilename)) {
            $fp = fopen($imagemap_tempfilename, "r");
            $contents = fread($fp, filesize($imagemap_tempfilename));
      fclose($fp);
                        if (preg_match_all("/<area(.+)>/siU", $contents, $matches)) {
                        for ($i=0; $i< count($matches[1]); $i++) {
                        preg_match("/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
                        preg_match("/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $coords);
                        preg_match("/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
                                        $this->add_answer($alt[1], 0.0, FALSE, count($this->answers), $coords[1], $shape[1]);
                        }
                        }
    }
        }

Here is the call graph for this function:

ASS_ImagemapQuestion::set_question ( question = ""  ) 

Sets the imagemap question.

Sets the question string of the ASS_ImagemapQuestion object

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

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

References $question.

                                        {
    $this->question = $question;
  }

ASS_ImagemapQuestion::syncWithOriginal (  ) 

Reimplemented from ASS_Question.

Definition at line 1126 of file class.assImagemapQuestion.php.

References ASS_Question::$ilias, $key, $query, $result, ASS_Question::getEstimatedWorkingTime(), getMaximumPoints(), 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, points = %s, image_file = %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->getMaximumPoints() . ""),
                                $db->quote($this->image_filename . ""),
                                $db->quote($complete . ""),
                                $db->quote($this->original_id . "")
                        );
                        $result = $db->query($query);

                        if ($result == DB_OK)
                        {
                                // write answers
                                // delete old answers
                                $query = sprintf("DELETE FROM qpl_answers WHERE question_fi = %s",
                                        $db->quote($this->original_id)
                                );
                                $result = $db->query($query);
        
                                foreach ($this->answers as $key => $value)
                                {
                                        $answer_obj = $this->answers[$key];
                                        $query = sprintf("INSERT INTO qpl_answers (answer_id, question_fi, answertext, points, aorder, correctness, coords, area, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, NULL)",
                                                $db->quote($this->original_id . ""),
                                                $db->quote($answer_obj->get_answertext() . ""),
                                                $db->quote($answer_obj->get_points() . ""),
                                                $db->quote($answer_obj->get_order() . ""),
                                                $db->quote($answer_obj->getState() . ""),
                                                $db->quote($answer_obj->get_coords() . ""),
                                                $db->quote($answer_obj->get_area() . "")
                                                );
                                        $answer_result = $db->query($query);
                                }
                        }
                        parent::syncWithOriginal();
                }
        }

Here is the call graph for this function:

ASS_ImagemapQuestion::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 441 of file class.assImagemapQuestion.php.

References $ilErr, $pos, $xml, get_image_filename(), get_question(), ASS_Question::getAuthor(), ASS_Question::getComment(), ASS_Question::getEstimatedWorkingTime(), ASS_Question::getImagePath(), ASS_Question::getImagePathWeb(), 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, IMAGEMAP_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 answers to presentation
                $attrs = array(
                        "ident" => "IM",
                        "rcardinality" => "Single"
                );
                $a_xml_writer->xmlStartTag("response_xy", $attrs);
                $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("render_hotspot");
                $a_xml_writer->xmlStartTag("material");
                $imagetype = "image/jpeg";
                if (preg_match("/.*\.(png|gif)$/", $this->get_image_filename(), $matches))
                {
                        $imagetype = "image/" . $matches[1];
                }
                $attrs = array(
                        "imagtype" => $imagetype,
                        "label" => $this->get_image_filename()
                );
                if ($a_include_binary)
                {
                        if ($force_image_references)
                        {
                                $attrs["uri"] = $this->getImagePathWeb() . $this->get_image_filename();
                                $a_xml_writer->xmlElement("matimage", $attrs);
                        }
                        else
                        {
                                $attrs["embedded"] = "base64";
                                $imagepath = $this->getImagePath() . $this->get_image_filename();
                                $fh = fopen($imagepath, "rb");
                                if ($fh == false)
                                {
                                        global $ilErr;
                                        $ilErr->raiseError($this->lng->txt("error_open_image_file"), $ilErr->MESSAGE);
                                        return;
                                }
                                $imagefile = fread($fh, filesize($imagepath));
                                fclose($fh);
                                $base64 = base64_encode($imagefile);
                                $a_xml_writer->xmlElement("matimage", $attrs, $base64, FALSE, FALSE);
                        }
                }
                else
                {
                        $a_xml_writer->xmlElement("matimage", $attrs);
                }
                $a_xml_writer->xmlEndTag("material");

                // add answers
                foreach ($this->answers as $index => $answer)
                {
                        $rared = "";
                        switch ($answer->get_area())
                        {
                                case "rect":
                                        $rarea = "Rectangle";
                                        break;
                                case "circle":
                                        $rarea = "Ellipse";
                                        break;
                                case "poly":
                                        $rarea = "Bounded";
                                        break;
                        }
                        $attrs = array(
                                "ident" => $index,
                                "rarea" => $rarea
                        );
                        $a_xml_writer->xmlStartTag("response_label", $attrs);
                        $a_xml_writer->xmlData($answer->get_coords());
                        $a_xml_writer->xmlStartTag("material");
                        $a_xml_writer->xmlElement("mattext", NULL, $answer->get_answertext());
                        $a_xml_writer->xmlEndTag("material");
                        $a_xml_writer->xmlEndTag("response_label");
                }
                $a_xml_writer->xmlEndTag("render_hotspot");
                $a_xml_writer->xmlEndTag("response_xy");
                $a_xml_writer->xmlEndTag("flow");
                $a_xml_writer->xmlEndTag("presentation");

                // PART II: qti resprocessing
                $a_xml_writer->xmlStartTag("resprocessing");
                $a_xml_writer->xmlStartTag("outcomes");
                $a_xml_writer->xmlStartTag("decvar");
                $a_xml_writer->xmlEndTag("decvar");
                $a_xml_writer->xmlEndTag("outcomes");
                // add response conditions
                foreach ($this->answers as $index => $answer)
                {
                        $attrs = array(
                                "continue" => "Yes"
                        );
                        $a_xml_writer->xmlStartTag("respcondition", $attrs);
                        // qti conditionvar
                        $a_xml_writer->xmlStartTag("conditionvar");
                        if (!$answer->isStateSet())
                        {
                                $a_xml_writer->xmlStartTag("not");
                        }
                        $areatype = "";
                        switch ($answer->get_area())
                        {
                                case "rect":
                                        $areatype = "Rectangle";
                                        break;
                                case "circle":
                                        $areatype = "Ellipse";
                                        break;
                                case "poly":
                                        $areatype = "Bounded";
                                        break;
                        }
                        $attrs = array(
                                "respident" => "IM",
                                "areatype" => $areatype
                        );
                        $a_xml_writer->xmlElement("varinside", $attrs, $answer->get_coords());
                        if (!$answer->isStateSet())
                        {
                                $a_xml_writer->xmlEndTag("not");
                        }
                        $a_xml_writer->xmlEndTag("conditionvar");
                        // qti setvar
                        $attrs = array(
                                "action" => "Add"
                        );
                        $a_xml_writer->xmlElement("setvar", $attrs, $answer->get_points());
                        // qti displayfeedback
                        if ($answer->isStateChecked())
                        {
                                $linkrefid = "True";
                        }
                          else
                        {
                                $linkrefid = "False_$index";
                        }
                        $attrs = array(
                                "feedbacktype" => "Response",
                                "linkrefid" => $linkrefid
                        );
                        $a_xml_writer->xmlElement("displayfeedback", $attrs);
                        $a_xml_writer->xmlEndTag("respcondition");
                }
                $a_xml_writer->xmlEndTag("resprocessing");

                // PART III: qti itemfeedback
                foreach ($this->answers as $index => $answer)
                {
                        $linkrefid = "";
                        if ($answer->isStateChecked())
                        {
                                $linkrefid = "True";
                        }
                          else
                        {
                                $linkrefid = "False_$index";
                        }
                        $attrs = array(
                                "ident" => $linkrefid,
                                "view" => "All"
                        );
                        $a_xml_writer->xmlStartTag("itemfeedback", $attrs);
                        // qti flow_mat
                        $a_xml_writer->xmlStartTag("flow_mat");
                        $a_xml_writer->xmlStartTag("material");
                        $a_xml_writer->xmlElement("mattext");
                        $a_xml_writer->xmlEndTag("material");
                        $a_xml_writer->xmlEndTag("flow_mat");
                        $a_xml_writer->xmlEndTag("itemfeedback");
                }
                
                $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_ImagemapQuestion::$answers

Definition at line 56 of file class.assImagemapQuestion.php.

ASS_ImagemapQuestion::$coords

Definition at line 84 of file class.assImagemapQuestion.php.

Referenced by add_answer(), addAnswer(), and set_imagemap_filename().

ASS_ImagemapQuestion::$image_filename

Definition at line 74 of file class.assImagemapQuestion.php.

Referenced by ASS_ImagemapQuestion(), and set_image_filename().

ASS_ImagemapQuestion::$imagemap_contents

Definition at line 83 of file class.assImagemapQuestion.php.

Referenced by get_imagemap_contents().

ASS_ImagemapQuestion::$imagemap_filename

Definition at line 65 of file class.assImagemapQuestion.php.

Referenced by ASS_ImagemapQuestion(), and set_imagemap_filename().

ASS_ImagemapQuestion::$question

Definition at line 47 of file class.assImagemapQuestion.php.

Referenced by ASS_ImagemapQuestion(), and set_question().


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