ILIAS  release_4-4 Revision
assOrderingQuestion Class Reference

Class for ordering questions. More...

+ Inheritance diagram for assOrderingQuestion:
+ Collaboration diagram for assOrderingQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="", $ordering_type=OQ_TERMS)
 assOrderingQuestion constructor More...
 
 isComplete ()
 Returns true, if a ordering question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assOrderingQuestion object to a database. More...
 
 loadFromDb ($question_id)
 Loads a assOrderingQuestion object from a database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assOrderingQuestion. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assOrderingQuestion object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 duplicateImages ($src_question_id, $src_object_id, $dest_question_id, $dest_object_id)
 
 copyImages ($question_id, $source_questionpool)
 
 setOrderingType ($ordering_type=OQ_TERMS)
 Sets the ordering question type. More...
 
 getOrderingType ()
 Returns the ordering question type. More...
 
 addAnswer ($answertext="", $solution_order=-1, $depth=0)
 Adds an answer for an ordering choice question. More...
 
 moveAnswerUp ($position)
 
 moveAnswerDown ($position)
 
 getAnswer ($index=0)
 Returns an ordering answer with a given index. More...
 
 deleteAnswer ($index=0)
 Deletes an answer with a given index. More...
 
 flushAnswers ()
 Deletes all answers. More...
 
 getAnswerCount ()
 Returns the number of answers. More...
 
 getMaxSolutionOrder ()
 Returns the maximum solution order of all ordering answers. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getEncryptedFilename ($filename)
 
 deleteImagefile ($filename)
 
 setImageFile ($image_tempfilename, $image_filename, $previous_filename)
 Sets the image file and uploads the image to the object's image directory. More...
 
 checkSaveData ()
 Checks the data to be saved for consistency. More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
getAnswers ()
 Returns the answers array. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 getThumbGeometry ()
 
 getThumbSize ()
 
 setThumbGeometry ($a_geometry)
 
 getElementHeight ()
 
 setElementHeight ($a_height)
 
 rebuildThumbnails ()
 
 getThumbPrefix ()
 
 toJSON ()
 Returns a JSON representation of the question. More...
 
 removeAnswerImage ($index)
 
 setLeveledOrdering ($new_hierarchy, $with_random_id=false)
 
 getLeveledOrdering ()
 
 getOldLeveledOrdering ()
 
 lookupSolutionOrderByRandomid ($a_random_id)
 
 lookupAnswerTextByRandomId ($a_random_id)
 
 updateLeveledOrdering ($a_index, $a_answer_text, $a_depth)
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($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. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. More...
 
 getReachedPoints ($active_id, $pass=NULL)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=NULL)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=NULL, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=NULL, $obligationsEnabled=false)
 persists the working state for current testactive and testpass More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getFlashPath ()
 Returns the image path for web accessable flash files of a question. More...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
getSolutionValues ($active_id, $pass=NULL)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="")
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=NULL)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 createNewImageFileName ($image_filename)
 
 _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 _questionExistsInTest ($question_id, $test_id)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not More...
 
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
- Public Member Functions inherited from ilObjQuestionScoringAdjustable
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjAnswerScoringAdjustable
 saveAnswerSpecificDataToDb ()
 Saves the answer specific records into a question types answer table. More...
 

Data Fields

 $answers
 
 $ordering_type
 
 $thumb_geometry = 100
 
 $element_height
 
 $old_ordering_depth = array()
 
 $leveled_ordering = array()
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject" More...
 
 $feedbackOBJ = null
 
 $prevent_rte_usage = false
 
 $selfassessmenteditingmode = false
 
 $defaultnroftries = false
 

Protected Member Functions

 getRandomID ()
 
 cleanImagefiles ()
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 generateThumbForFile ($path, $file)
 
- Protected Member Functions inherited from assQuestion
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 onSyncWithOriginal ($originalQuestionId, $duplicateQuestionId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 

Private Member Functions

 getDepthRecursive ($child, $ordering_depth, $with_random_id=false)
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question. More...
 
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution. More...
 
static _getOriginalId ($question_id)
 Returns the original id of a question. More...
 
static originalQuestionExists ($questionId)
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instantiateQuestion ($question_id)
 
static _isWorkedThrough ($active_id, $question_id, $pass=NULL)
 Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value. More...
 
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not. More...
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static getGuiClassNameByQuestionType ($questionType)
 
static getObjectClassNameByQuestionType ($questionType)
 
static getFeedbackClassNameByQuestionType ($questionType)
 
static isCoreQuestionType ($questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static includePluginClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id. More...
 
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id. More...
 
static lookupParentObjId ($questionId)
 ilDB $ilDB More...
 
static lookupOriginalParentObjId ($originalQuestionId)
 returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too) More...
 
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
- Static Protected Member Functions inherited from assQuestion
static doesSolutionRecordsExist ($activeId, $pass, $questionId)
 checks wether there are existing solution records for the given test active / pass and given question id More...
 
- Protected Attributes inherited from assQuestion
 $id
 
 $title
 
 $comment
 
 $owner
 
 $author
 
 $question
 
 $points
 
 $est_working_time
 
 $shuffle
 
 $test_id
 
 $obj_id
 
 $ilias
 
 $tpl
 
 $lng
 
 $outputType
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 

Detailed Description

Class for ordering questions.

assOrderingQuestion is a class for ordering questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 22 of file class.assOrderingQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

assOrderingQuestion::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "",
  $ordering_type = OQ_TERMS 
)

assOrderingQuestion constructor

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

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator
string$questionThe question string of the ordering test
int$ordering_type

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

References assQuestion\$author, assQuestion\$comment, $ordering_type, assQuestion\$owner, assQuestion\$question, and assQuestion\$title.

80  {
81  parent::__construct($title, $comment, $author, $owner, $question);
82  $this->answers = array();
83  $this->ordering_type = $ordering_type;
84  }

Member Function Documentation

◆ addAnswer()

assOrderingQuestion::addAnswer (   $answertext = "",
  $solution_order = -1,
  $depth = 0 
)

Adds an answer for an ordering choice question.

The students have to fill in an order for the answer. The answer is an ASS_AnswerOrdering object that will be created and assigned to the array $this->answers.

Parameters
string$answertextThe answer text
double$pointsThe points for selecting the answer (even negative points can be used)
integer$orderA possible display order of the answer
integer$solution_orderAn unique integer value representing the correct order of that answer in the solution of a question
integer$depthrepresents the depth of that answer public
See also
$answers
ASS_AnswerOrdering

Definition at line 414 of file class.assOrderingQuestion.php.

References getRandomID().

415  {
416  include_once "./Modules/TestQuestionPool/classes/class.assAnswerOrdering.php";
417  $answer = new ASS_AnswerOrdering($answertext, $this->getRandomID(), $depth);
418  if (($solution_order >= 0) && ($solution_order < count($this->answers)))
419  {
420  $part1 = array_slice($this->answers, 0, $solution_order);
421  $part2 = array_slice($this->answers, $solution_order);
422  $this->answers = array_merge($part1, array($answer), $part2);
423  }
424  else
425  {
426  array_push($this->answers, $answer);
427  }
428  }
Class for ordering question answers.
+ Here is the call graph for this function:

◆ calculateReachedPoints()

assOrderingQuestion::calculateReachedPoints (   $active_id,
  $pass = NULL,
  $returndetails = FALSE 
)

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

The points are calculated from the given answers.

public

Parameters
integer$active_id
integer$pass
boolean$returndetails(deprecated !!)
Returns
integer/array $points/$details (array $details is deprecated !!)

Definition at line 578 of file class.assOrderingQuestion.php.

References $data, $pass, assQuestion\$points, $result, ilDB\fetchAssoc(), assQuestion\getId(), getOrderingType(), assQuestion\getPoints(), assQuestion\getSolutionMaxPass(), OQ_NESTED_PICTURES, and OQ_NESTED_TERMS.

579  {
580  if( $returndetails )
581  {
582  throw new ilTestException('return details not implemented for '.__METHOD__);
583  }
584 
585  global $ilDB;
586 
587  $found_value1 = array();
588  $found_value2 = array();
589  if (is_null($pass))
590  {
591  $pass = $this->getSolutionMaxPass($active_id);
592  }
593  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
594  array('integer','integer','integer'),
595  array($active_id, $this->getId(), $pass)
596  );
597  $user_order = array();
598  $nested_solution = false;
599  while ($data = $ilDB->fetchAssoc($result))
600  {
601  if ((strcmp($data["value1"], "") != 0) && (strcmp($data["value2"], "") != 0))
602  {
603  if(strchr( $data['value2'],':') == true)
604  {
605 // //i.e. "61463:0" = "random_id:depth"
606  $current_solution = explode(':', $data['value2']);
607 
608  $user_order[$current_solution[0]]['index'] = $data["value1"];
609  $user_order[$current_solution[0]]['depth'] = $current_solution[1];
610  $user_order[$current_solution[0]]['random_id'] = $current_solution[0];
611 
612  $nested_solution = true;
613  }
614  else
615  {
616  $user_order[$data["value2"]] = $data["value1"];
617  $nested_solution = false;
618  }
619  }
620  }
621 
622  if($this->getOrderingType() != OQ_NESTED_PICTURES
623  && $this->getOrderingType() != OQ_NESTED_TERMS)
624  {
625  ksort($user_order);
626  $user_order = array_values($user_order);
627  }
628 
629  $points = 0;
630  $correctcount = 0;
631 
632  foreach ($this->answers as $index => $answer)
633  {
634  if($nested_solution == true)
635  {
636  $random_id = $answer->getRandomID();
637 
638  if($random_id == $user_order[$random_id]['random_id']
639  && $answer->getOrderingDepth() == $user_order[$random_id]['depth']
640  && $index == $user_order[$random_id]['index'])
641  {
642  $correctcount++;
643  }
644  }
645  else
646  {
647  if ($index == $user_order[$index])
648  {
649  $correctcount++;
650  }
651  }
652  }
653 
654  if ($correctcount == count($this->answers))
655  {
656  $points = $this->getPoints();
657  }
658 
659  return $points;
660  }
getId()
Gets the id of the assQuestion object.
$result
getPoints()
Returns the maximum available points for the question.
getOrderingType()
Returns the ordering question type.
const OQ_NESTED_TERMS
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
fetchAssoc($a_set)
Fetch row as associative array from result set.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
const OQ_NESTED_PICTURES
+ Here is the call graph for this function:

◆ checkSaveData()

assOrderingQuestion::checkSaveData ( )

Checks the data to be saved for consistency.

Returns
boolean True, if the check was ok, False otherwise public
See also
$answers

Definition at line 784 of file class.assOrderingQuestion.php.

References $_POST, $result, assQuestion\getOutputType(), OUTPUT_JAVASCRIPT, ilUtil\sendInfo(), and setLeveledOrdering().

Referenced by saveWorkingData().

785  {
786  $result = true;
787  if ($this->getOutputType() == OUTPUT_JAVASCRIPT)
788  {
789  if (strlen($_POST["orderresult"]))
790  {
791  return $result;
792  }
793  else if(strlen($_POST['answers_ordering']))
794  {
795  $answers_ordering = $_POST['answers_ordering'];
796  $new_hierarchy = json_decode($answers_ordering);
797  $with_random_id = true;
798  $this->setLeveledOrdering($new_hierarchy, $with_random_id);
799 
800  //return value as "random_id:depth"
801  return serialize($this->leveled_ordering);
802  }
803  }
804  $order_values = array();
805  foreach ($_POST as $key => $value)
806  {
807  if (preg_match("/^order_(\d+)/", $key, $matches))
808  {
809  if (strcmp($value, "") != 0)
810  {
811  array_push($order_values, $value);
812  }
813  }
814  }
815  $check_order = array_flip($order_values);
816  if (count($check_order) != count($order_values))
817  {
818  // duplicate order values!!!
819  $result = false;
820  ilUtil::sendInfo($this->lng->txt("duplicate_order_values_entered"), TRUE);
821  }
822  return $result;
823  }
$_POST['username']
Definition: cron.php:12
$result
const OUTPUT_JAVASCRIPT
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setLeveledOrdering($new_hierarchy, $with_random_id=false)
getOutputType()
Gets the output type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanImagefiles()

assOrderingQuestion::cleanImagefiles ( )
protected

Definition at line 691 of file class.assOrderingQuestion.php.

References ilUtil\delDir(), getAnswers(), ilUtil\getDir(), assQuestion\getImagePath(), getOrderingType(), getThumbPrefix(), and OQ_PICTURES.

Referenced by saveWorkingData().

692  {
693  if ($this->getOrderingType() == OQ_PICTURES)
694  {
695  if (@file_exists($this->getImagePath()))
696  {
697  $contents = ilUtil::getDir($this->getImagePath());
698  foreach ($contents as $f)
699  {
700  if (strcmp($f['type'], 'file') == 0)
701  {
702  $found = false;
703  foreach ($this->getAnswers() as $answer)
704  {
705  if (strcmp($f['entry'], $answer->getAnswertext()) == 0) $found = true;
706  if (strcmp($f['entry'], $this->getThumbPrefix() . $answer->getAnswertext()) == 0) $found = true;
707  }
708  if (!$found)
709  {
710  if (@file_exists($this->getImagePath() . $f['entry'])) @unlink($this->getImagePath() . $f['entry']);
711  }
712  }
713  }
714  }
715  }
716  else
717  {
718  if (@file_exists($this->getImagePath()))
719  {
720  ilUtil::delDir($this->getImagePath());
721  }
722  }
723  }
& getAnswers()
Returns the answers array.
getOrderingType()
Returns the ordering question type.
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
const OQ_PICTURES
Ordering question constants.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyImages()

assOrderingQuestion::copyImages (   $question_id,
  $source_questionpool 
)

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

References $filename, $ilLog, assQuestion\getImagePath(), getOrderingType(), getThumbPrefix(), ilUtil\makeDirParents(), and OQ_PICTURES.

348  {
349  global $ilLog;
350  if ($this->getOrderingType() == OQ_PICTURES)
351  {
352  $imagepath = $this->getImagePath();
353  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
354  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
355  if (!file_exists($imagepath)) {
356  ilUtil::makeDirParents($imagepath);
357  }
358  foreach ($this->answers as $answer)
359  {
360  $filename = $answer->getAnswertext();
361  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
362  {
363  $ilLog->write("Ordering Question image could not be copied: $imagepath_original$filename");
364  }
365  if (@file_exists($imagepath_original. $this->getThumbPrefix(). $filename))
366  {
367  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
368  {
369  $ilLog->write("Ordering Question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
370  }
371  }
372  }
373  }
374  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getOrderingType()
Returns the ordering question type.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
const OQ_PICTURES
Ordering question constants.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ copyObject()

assOrderingQuestion::copyObject (   $target_questionpool_id,
  $title = "" 
)

Copies an assOrderingQuestion object.

public

Definition at line 248 of file class.assOrderingQuestion.php.

References assQuestion\$original_id, assQuestion\$title, assQuestion\_getOriginalId(), and assQuestion\getObjId().

249  {
250  if ($this->id <= 0)
251  {
252  // The question has not been saved. It cannot be duplicated
253  return;
254  }
255  // duplicate the question in database
256  $clone = $this;
257  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
259  $clone->id = -1;
260  $source_questionpool_id = $this->getObjId();
261  $clone->setObjId($target_questionpool_id);
262  if ($title)
263  {
264  $clone->setTitle($title);
265  }
266 
267  $clone->saveToDb();
268 
269  // copy question page content
270  $clone->copyPageOfQuestion($original_id);
271  // copy XHTML media objects
272  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
273  // duplicate the image
274  $clone->copyImages($original_id, $source_questionpool_id);
275 
276  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
277 
278  return $clone->id;
279  }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

assOrderingQuestion::createNewOriginalFromThisDuplicate (   $targetParentId,
  $targetQuestionTitle = "" 
)

Definition at line 281 of file class.assOrderingQuestion.php.

References assQuestion\$id, and assQuestion\getObjId().

282  {
283  if ($this->id <= 0)
284  {
285  // The question has not been saved. It cannot be duplicated
286  return;
287  }
288 
289  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
290 
291  $sourceQuestionId = $this->id;
292  $sourceParentId = $this->getObjId();
293 
294  // duplicate the question in database
295  $clone = $this;
296  $clone->id = -1;
297 
298  $clone->setObjId($targetParentId);
299 
300  if ($targetQuestionTitle)
301  {
302  $clone->setTitle($targetQuestionTitle);
303  }
304 
305  $clone->saveToDb();
306  // copy question page content
307  $clone->copyPageOfQuestion($sourceQuestionId);
308  // copy XHTML media objects
309  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
310  // duplicate the image
311  $clone->copyImages($sourceQuestionId, $sourceParentId);
312 
313  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
314 
315  return $clone->id;
316  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteAnswer()

assOrderingQuestion::deleteAnswer (   $index = 0)

Deletes 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$indexA nonnegative index of the n-th answer public
See also
$answers

Definition at line 494 of file class.assOrderingQuestion.php.

495  {
496  if ($index < 0)
497  {
498  return;
499  }
500  if (count($this->answers) < 1)
501  {
502  return;
503  }
504  if ($index >= count($this->answers))
505  {
506  return;
507  }
508  unset($this->answers[$index]);
509  $this->answers = array_values($this->answers);
510  for ($i = 0; $i < count($this->answers); $i++)
511  {
512  if ($this->answers[$i]->getOrder() > $index)
513  {
514  $this->answers[$i]->setOrder($i);
515  }
516  }
517  }

◆ deleteImagefile()

assOrderingQuestion::deleteImagefile (   $filename)

Definition at line 731 of file class.assOrderingQuestion.php.

References $filename, $result, assQuestion\getImagePath(), and getThumbPrefix().

Referenced by removeAnswerImage(), and setImageFile().

732  {
733  $deletename = $$filename;
734  $result = @unlink($this->getImagePath().$deletename);
735  $result = $result & @unlink($this->getImagePath().$this->getThumbPrefix() . $deletename);
736  return $result;
737  }
$result
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

assOrderingQuestion::duplicate (   $for_test = true,
  $title = "",
  $author = "",
  $owner = "",
  $testObjId = null 
)

Duplicates an assOrderingQuestion.

public

Definition at line 189 of file class.assOrderingQuestion.php.

References assQuestion\$author, assQuestion\$original_id, assQuestion\$owner, assQuestion\$title, assQuestion\_getOriginalId(), assQuestion\getId(), and assQuestion\getObjId().

190  {
191  if ($this->id <= 0)
192  {
193  // The question has not been saved. It cannot be duplicated
194  return;
195  }
196  // duplicate the question in database
197  $this_id = $this->getId();
198  $thisObjId = $this->getObjId();
199 
200  $clone = $this;
201  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
203  $clone->id = -1;
204 
205  if( (int)$testObjId > 0 )
206  {
207  $clone->setObjId($testObjId);
208  }
209 
210  if ($title)
211  {
212  $clone->setTitle($title);
213  }
214  if ($author)
215  {
216  $clone->setAuthor($author);
217  }
218  if ($owner)
219  {
220  $clone->setOwner($owner);
221  }
222  if ($for_test)
223  {
224  $clone->saveToDb($original_id);
225  }
226  else
227  {
228  $clone->saveToDb();
229  }
230 
231  // copy question page content
232  $clone->copyPageOfQuestion($this_id);
233  // copy XHTML media objects
234  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
235  // duplicate the image
236  $clone->duplicateImages($this_id, $thisObjId, $clone->getId(), $testObjId);
237 
238  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
239 
240  return $clone->id;
241  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ duplicateImages()

assOrderingQuestion::duplicateImages (   $src_question_id,
  $src_object_id,
  $dest_question_id,
  $dest_object_id 
)

Definition at line 318 of file class.assOrderingQuestion.php.

References $filename, $ilLog, assQuestion\getImagePath(), getOrderingType(), getThumbPrefix(), ilUtil\makeDirParents(), and OQ_PICTURES.

319  {
320  global $ilLog;
321  if ($this->getOrderingType() == OQ_PICTURES)
322  {
323  $imagepath_original = $this->getImagePath($src_question_id, $src_object_id);
324  $imagepath = $this->getImagePath($dest_question_id, $dest_object_id);
325 
326  if (!file_exists($imagepath)) {
327  ilUtil::makeDirParents($imagepath);
328  }
329  foreach ($this->answers as $answer)
330  {
331  $filename = $answer->getAnswertext();
332  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
333  {
334  $ilLog->write("image could not be duplicated!!!!");
335  }
336  if (@file_exists($imagepath_original. $this->getThumbPrefix(). $filename))
337  {
338  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
339  {
340  $ilLog->write("image thumbnail could not be duplicated!!!!");
341  }
342  }
343  }
344  }
345  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getOrderingType()
Returns the ordering question type.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
const OQ_PICTURES
Ordering question constants.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ flushAnswers()

assOrderingQuestion::flushAnswers ( )

Deletes all answers.

public

See also
$answers

Definition at line 525 of file class.assOrderingQuestion.php.

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

◆ generateThumbForFile()

assOrderingQuestion::generateThumbForFile (   $path,
  $file 
)
protected

Definition at line 1216 of file class.assOrderingQuestion.php.

References $file, $filename, $path, ilUtil\convertImage(), getThumbGeometry(), and getThumbPrefix().

Referenced by rebuildThumbnails().

1217  {
1218  $filename = $path . $file;
1219  if (@file_exists($filename))
1220  {
1221  $thumbpath = $path . $this->getThumbPrefix() . $file;
1222  $path_info = @pathinfo($filename);
1223  $ext = "";
1224  switch (strtoupper($path_info['extension']))
1225  {
1226  case 'PNG':
1227  $ext = 'PNG';
1228  break;
1229  case 'GIF':
1230  $ext = 'GIF';
1231  break;
1232  default:
1233  $ext = 'JPEG';
1234  break;
1235  }
1236  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbGeometry());
1237  }
1238  }
print $file
$filename
Definition: buildRTE.php:89
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
$path
Definition: index.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalTableName()

assOrderingQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name public

Definition at line 1058 of file class.assOrderingQuestion.php.

Referenced by loadFromDb(), and saveWorkingData().

1059  {
1060  return "qpl_qst_ordering";
1061  }
+ Here is the caller graph for this function:

◆ getAnswer()

assOrderingQuestion::getAnswer (   $index = 0)

Returns an ordering 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$indexA nonnegative index of the n-th answer
Returns
object ASS_AnswerOrdering-Object public
See also
$answers

Definition at line 478 of file class.assOrderingQuestion.php.

479  {
480  if ($index < 0) return NULL;
481  if (count($this->answers) < 1) return NULL;
482  if ($index >= count($this->answers)) return NULL;
483  return $this->answers[$index];
484  }

◆ getAnswerCount()

assOrderingQuestion::getAnswerCount ( )

Returns the number of answers.

Returns
integer The number of answers of the ordering question public
See also
$answers

Definition at line 537 of file class.assOrderingQuestion.php.

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

◆ getAnswers()

& assOrderingQuestion::getAnswers ( )

Returns the answers array.

Definition at line 1092 of file class.assOrderingQuestion.php.

References $answers.

Referenced by cleanImagefiles(), getRandomID(), rebuildThumbnails(), saveWorkingData(), setExportDetailsXLS(), and toJSON().

1093  {
1094  return $this->answers;
1095  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assOrderingQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

Definition at line 1069 of file class.assOrderingQuestion.php.

1070  {
1071  return "qpl_a_ordering";
1072  }

◆ getDepthRecursive()

assOrderingQuestion::getDepthRecursive (   $child,
  $ordering_depth,
  $with_random_id = false 
)
private

Definition at line 1302 of file class.assOrderingQuestion.php.

Referenced by setLeveledOrdering().

1303  {
1304  if($with_random_id == true)
1305  {
1306  // for test ouput
1307  if(is_array($child->children))
1308  {
1309  foreach($child->children as $grand_child)
1310  {
1311  $ordering_depth++;
1312  $this->leveled_ordering[$child->id] = $ordering_depth;
1313  $this->getDepthRecursive($grand_child, $ordering_depth, true);
1314  }
1315  }
1316  else
1317  {
1318  $ordering_depth++;
1319  $this->leveled_ordering[$child->id] = $ordering_depth;
1320  }
1321  }
1322  else
1323  {
1324  if(is_array($child->children))
1325  {
1326  foreach($child->children as $grand_child)
1327  {
1328  $ordering_depth++;
1329  $this->leveled_ordering[] = $ordering_depth;
1330  $this->getDepthRecursive($grand_child, $ordering_depth);
1331  }
1332  }
1333  else
1334  {
1335  $ordering_depth++;
1336  $this->leveled_ordering[] = $ordering_depth;
1337  }
1338  }
1339  }
getDepthRecursive($child, $ordering_depth, $with_random_id=false)
+ Here is the caller graph for this function:

◆ getElementHeight()

assOrderingQuestion::getElementHeight ( )

Definition at line 1182 of file class.assOrderingQuestion.php.

References $element_height.

Referenced by saveWorkingData().

1183  {
1184  return $this->element_height;
1185  }
+ Here is the caller graph for this function:

◆ getEncryptedFilename()

assOrderingQuestion::getEncryptedFilename (   $filename)

Definition at line 681 of file class.assOrderingQuestion.php.

References $filename.

682  {
683  $extension = "";
684  if (preg_match("/.*\\.(\\w+)$/", $filename, $matches))
685  {
686  $extension = $matches[1];
687  }
688  return md5($filename) . "." . $extension;
689  }
$filename
Definition: buildRTE.php:89

◆ getLeveledOrdering()

assOrderingQuestion::getLeveledOrdering ( )

Definition at line 1381 of file class.assOrderingQuestion.php.

References $leveled_ordering.

1382  {
1383  return $this->leveled_ordering;
1384  }

◆ getMaximumPoints()

assOrderingQuestion::getMaximumPoints ( )

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

Returns
double Points
See also
$points

Definition at line 668 of file class.assOrderingQuestion.php.

References assQuestion\getPoints().

Referenced by isComplete().

669  {
670  return $this->getPoints();
671  }
getPoints()
Returns the maximum available points for the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxSolutionOrder()

assOrderingQuestion::getMaxSolutionOrder ( )

Returns the maximum solution order of all ordering answers.

Returns
integer The maximum solution order of all ordering answers public

Definition at line 548 of file class.assOrderingQuestion.php.

549  {
550  if (count($this->answers) == 0)
551  {
552  $max = 0;
553  }
554  else
555  {
556  $max = $this->answers[0]->getSolutionOrder();
557  }
558  foreach ($this->answers as $key => $value)
559  {
560  if ($value->getSolutionOrder() > $max)
561  {
562  $max = $value->getSolutionOrder();
563  }
564  }
565  return $max;
566  }

◆ getOldLeveledOrdering()

assOrderingQuestion::getOldLeveledOrdering ( )

Definition at line 1386 of file class.assOrderingQuestion.php.

References $old_ordering_depth, $res, $row, and assQuestion\getId().

1387  {
1388  global $ilDB;
1389 
1390  $res = $ilDB->queryF('SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC',
1391  array('integer'), array($this->getId()));
1392  while($row = $ilDB->fetchAssoc($res))
1393  {
1394  $this->old_ordering_depth[] = $row['depth'];
1395  }
1397  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:

◆ getOrderingType()

assOrderingQuestion::getOrderingType ( )

Returns the ordering question type.

Returns
integer The ordering question type public
See also
$ordering_type

Definition at line 395 of file class.assOrderingQuestion.php.

References $ordering_type.

Referenced by calculateReachedPoints(), cleanImagefiles(), copyImages(), duplicateImages(), rebuildThumbnails(), saveWorkingData(), and toJSON().

396  {
397  return $this->ordering_type;
398  }
+ Here is the caller graph for this function:

◆ getQuestionType()

assOrderingQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 1047 of file class.assOrderingQuestion.php.

Referenced by toJSON().

1048  {
1049  return "assOrderingQuestion";
1050  }
+ Here is the caller graph for this function:

◆ getRandomID()

assOrderingQuestion::getRandomID ( )
protected

Definition at line 450 of file class.assOrderingQuestion.php.

References getAnswers().

Referenced by addAnswer().

451  {
452  $random_number = mt_rand(1, 100000);
453  $found = true;
454  while ($found)
455  {
456  $found = false;
457  foreach ($this->getAnswers() as $answer)
458  {
459  if ($answer->getRandomID() == $random_number)
460  {
461  $found = true;
462  $random_number++;
463  }
464  }
465  }
466  return $random_number;
467  }
& getAnswers()
Returns the answers array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assOrderingQuestion::getRTETextWithMediaObjects ( )

Collects all text in the question which could contain media objects which were created with the Rich Text Editor.

Definition at line 1078 of file class.assOrderingQuestion.php.

1079  {
1080  $text = parent::getRTETextWithMediaObjects();
1081  foreach ($this->answers as $index => $answer)
1082  {
1083  $answer_obj = $this->answers[$index];
1084  $text .= $answer_obj->getAnswertext();
1085  }
1086  return $text;
1087  }

◆ getThumbGeometry()

assOrderingQuestion::getThumbGeometry ( )

Definition at line 1157 of file class.assOrderingQuestion.php.

References $thumb_geometry.

Referenced by generateThumbForFile(), getThumbSize(), and saveWorkingData().

1158  {
1159  return $this->thumb_geometry;
1160  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assOrderingQuestion::getThumbPrefix ( )

Definition at line 1211 of file class.assOrderingQuestion.php.

Referenced by cleanImagefiles(), copyImages(), deleteImagefile(), duplicateImages(), generateThumbForFile(), and setImageFile().

1212  {
1213  return "thumb.";
1214  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assOrderingQuestion::getThumbSize ( )

Definition at line 1162 of file class.assOrderingQuestion.php.

References getThumbGeometry().

1163  {
1164  return $this->getThumbGeometry();
1165  }
+ Here is the call graph for this function:

◆ isComplete()

assOrderingQuestion::isComplete ( )

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

Returns
boolean True, if the ordering question is complete for use, otherwise false

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

References getMaximumPoints().

92  {
93  if (
94  strlen($this->title) &&
95  $this->author &&
96  $this->question &&
97  count($this->answers) &&
98  $this->getMaximumPoints() > 0
99  )
100  {
101  return true;
102  }
103  return false;
104  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ loadFromDb()

assOrderingQuestion::loadFromDb (   $question_id)

Loads a assOrderingQuestion object from a database.

Parameters
object$dbA pear DB object
integer$question_idA unique key which defines the multiple choice test in the database public

Definition at line 130 of file class.assOrderingQuestion.php.

References $data, $result, ilRTE\_replaceMediaObjectImageSrc(), ilDB\fetchAssoc(), getAdditionalTableName(), OQ_TERMS, assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), and assQuestion\setTitle().

131  {
132  global $ilDB;
133 
134  $result = $ilDB->queryF("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
135  array("integer"),
136  array($question_id)
137  );
138  if ($result->numRows() == 1)
139  {
140  $data = $ilDB->fetchAssoc($result);
141  $this->setId($question_id);
142  $this->setObjId($data["obj_fi"]);
143  $this->setTitle($data["title"]);
144  $this->setComment($data["description"]);
145  $this->setOriginalId($data["original_id"]);
146  $this->setAuthor($data["author"]);
147  $this->setNrOfTries($data['nr_of_tries']);
148  $this->setPoints($data["points"]);
149  $this->setOwner($data["owner"]);
150  include_once("./Services/RTE/classes/class.ilRTE.php");
151  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
152  $this->ordering_type = strlen($data["ordering_type"]) ? $data["ordering_type"] : OQ_TERMS;
153  $this->thumb_geometry = $data["thumb_geometry"];
154  $this->element_height = $data["element_height"];
155  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
156 
157  try
158  {
159  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
160  }
162  {
163  }
164  }
165 
166  $result = $ilDB->queryF("SELECT * FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC",
167  array('integer'),
168  array($question_id)
169  );
170 
171  include_once "./Modules/TestQuestionPool/classes/class.assAnswerOrdering.php";
172  if ($result->numRows() > 0)
173  {
174  while ($data = $ilDB->fetchAssoc($result))
175  {
176  include_once("./Services/RTE/classes/class.ilRTE.php");
177  $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
178  array_push($this->answers, new ASS_AnswerOrdering($data["answertext"], $data["random_id"], $data['depth'] ? $data['depth'] : 0));
179  }
180  }
181  parent::loadFromDb($question_id);
182  }
$result
Class for ordering question answers.
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
const OQ_TERMS
setQuestion($question="")
Sets the question string of the question object.
setOriginalId($original_id)
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ lookupAnswerTextByRandomId()

assOrderingQuestion::lookupAnswerTextByRandomId (   $a_random_id)

Definition at line 1418 of file class.assOrderingQuestion.php.

References $res, and $row.

1419  {
1420  global $ilDB;
1421 
1422  $res = $ilDB->queryF('SELECT answertext FROM qpl_a_ordering WHERE random_id = %s',
1423  array('integer'), array($a_random_id));
1424  $row = $ilDB->fetchAssoc($res);
1425 
1426  return $row['answertext'];
1427  }

◆ lookupSolutionOrderByRandomid()

assOrderingQuestion::lookupSolutionOrderByRandomid (   $a_random_id)

Definition at line 1403 of file class.assOrderingQuestion.php.

References $res, and $row.

1404  {
1405  global $ilDB;
1406 
1407  $res = $ilDB->queryF('SELECT solution_order FROM qpl_a_ordering WHERE random_id = %s',
1408  array('integer'), array($a_random_id));
1409  $row = $ilDB->fetchAssoc($res);
1410 
1411  return $row['solution_order'];
1412  }

◆ moveAnswerDown()

assOrderingQuestion::moveAnswerDown (   $position)

Definition at line 440 of file class.assOrderingQuestion.php.

441  {
442  if ($position < count($this->answers)-1)
443  {
444  $temp = $this->answers[$position+1];
445  $this->answers[$position+1] = $this->answers[$position];
446  $this->answers[$position] = $temp;
447  }
448  }

◆ moveAnswerUp()

assOrderingQuestion::moveAnswerUp (   $position)

Definition at line 430 of file class.assOrderingQuestion.php.

431  {
432  if ($position > 0)
433  {
434  $temp = $this->answers[$position-1];
435  $this->answers[$position-1] = $this->answers[$position];
436  $this->answers[$position] = $temp;
437  }
438  }

◆ rebuildThumbnails()

assOrderingQuestion::rebuildThumbnails ( )

Definition at line 1200 of file class.assOrderingQuestion.php.

References generateThumbForFile(), getAnswers(), assQuestion\getImagePath(), getOrderingType(), OQ_NESTED_PICTURES, and OQ_PICTURES.

Referenced by saveWorkingData().

1201  {
1202  if ($this->getOrderingType() == OQ_PICTURES || $this->getOrderingType() == OQ_NESTED_PICTURES)
1203  {
1204  foreach ($this->getAnswers() as $answer)
1205  {
1206  $this->generateThumbForFile($this->getImagePath(), $answer->getAnswertext());
1207  }
1208  }
1209  }
& getAnswers()
Returns the answers array.
getOrderingType()
Returns the ordering question type.
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
const OQ_PICTURES
Ordering question constants.
const OQ_NESTED_PICTURES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAnswerImage()

assOrderingQuestion::removeAnswerImage (   $index)

Definition at line 1287 of file class.assOrderingQuestion.php.

References deleteImagefile().

1288  {
1289  $answer = $this->answers[$index];
1290  if (is_object($answer))
1291  {
1292  $this->deleteImagefile($answer->getAnswertext());
1293  $answer->setAnswertext('');
1294  }
1295  }
+ Here is the call graph for this function:

◆ reworkWorkingData()

assOrderingQuestion::reworkWorkingData (   $active_id,
  $pass,
  $obligationsAnswered 
)
protected

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

Definition at line 1036 of file class.assOrderingQuestion.php.

1037  {
1038  // nothing to rework!
1039  }

◆ saveToDb()

assOrderingQuestion::saveToDb (   $original_id = "")

Saves a assOrderingQuestion object to a database.

Parameters
string$original_id

Definition at line 113 of file class.assOrderingQuestion.php.

References assQuestion\$original_id, ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and assQuestion\saveQuestionDataToDb().

114  {
115  global $ilDB;
116 
120  parent::saveToDb($original_id);
121  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

assOrderingQuestion::saveWorkingData (   $active_id,
  $pass = NULL 
)

Saves the learners input of the question to the database.

public

Parameters
integer$active_idActive id of the user
integer$passTest pass
Returns
boolean $status

Definition at line 833 of file class.assOrderingQuestion.php.

References $_POST, $ilUser, $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), checkSaveData(), cleanImagefiles(), getAdditionalTableName(), getAnswers(), getElementHeight(), assQuestion\getId(), getOrderingType(), assQuestion\getProcessLocker(), getThumbGeometry(), assQuestion\logAction(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, OQ_PICTURES, rebuildThumbnails(), ilObjQuestionScoringAdjustable\saveAdditionalQuestionDataToDb(), ilObjAnswerScoringAdjustable\saveAnswerSpecificDataToDb(), and setLeveledOrdering().

834  {
835  global $ilDB;
836  global $ilUser;
837 
838  $saveWorkingDataResult = $this->checkSaveData();
839  $entered_values = 0;
840  if ($saveWorkingDataResult)
841  {
842  if (is_null($pass))
843  {
844  include_once "./Modules/Test/classes/class.ilObjTest.php";
845  $pass = ilObjTest::_getPass($active_id);
846  }
847 
848  $this->getProcessLocker()->requestUserSolutionUpdateLock();
849 
850  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
851  array('integer','integer','integer'),
852  array($active_id, $this->getId(), $pass)
853  );
854  if (array_key_exists("orderresult", $_POST))
855  {
856  $orderresult = $_POST["orderresult"];
857  if (strlen($orderresult))
858  {
859  $orderarray = explode(":", $orderresult);
860  $ordervalue = 1;
861  foreach ($orderarray as $index)
862  {
863  if (preg_match("/id_(\\d+)/", $index, $idmatch))
864  {
865  $randomid = $idmatch[1];
866  foreach ($this->getAnswers() as $answeridx => $answer)
867  {
868  if ($answer->getRandomID() == $randomid)
869  {
870  $next_id = $ilDB->nextId('tst_solutions');
871  $affectedRows = $ilDB->insert("tst_solutions", array(
872  "solution_id" => array("integer", $next_id),
873  "active_fi" => array("integer", $active_id),
874  "question_fi" => array("integer", $this->getId()),
875  "value1" => array("clob", $answeridx),
876  "value2" => array("clob", trim($ordervalue)),
877  "pass" => array("integer", $pass),
878  "tstamp" => array("integer", time())
879  ));
880  $ordervalue++;
881  $entered_values++;
882  }
883  }
884  }
885  }
886  }
887  }
888  else if($this->getOrderingType() == OQ_NESTED_TERMS
889  ||$this->getOrderingType() == OQ_NESTED_PICTURES)
890  {
891  $answers_ordering = $_POST['answers_ordering__participant'];
892  $user_solution_hierarchy = json_decode($answers_ordering);
893  $with_random_id = true;
894  $this->setLeveledOrdering($user_solution_hierarchy, $with_random_id);
895 
896  $index = 0;
897  foreach($this->leveled_ordering as $random_id=>$depth)
898  {
899  $value_2 = implode(':',array($random_id,$depth));
900  $next_id = $ilDB->nextId('tst_solutions');
901 
902  $affectedRows = $ilDB->insert("tst_solutions", array(
903  "solution_id" => array("integer", $next_id),
904  "active_fi" => array("integer", $active_id),
905  "question_fi" => array("integer", $this->getId()),
906  "value1" => array("clob", $index),
907  "value2" => array("clob", $value_2),
908  "pass" => array("integer", $pass),
909  "tstamp" => array("integer", time())
910  ));
911  $index++;
912  $entered_values++;
913  }
914  }
915  else
916  {
917  foreach ($_POST as $key => $value)
918  {
919  if (preg_match("/^order_(\d+)/", $key, $matches))
920  {
921  if (!(preg_match("/initial_value_\d+/", $value)))
922  {
923  if (strlen($value))
924  {
925  foreach ($this->getAnswers() as $answeridx => $answer)
926  {
927  if ($answer->getRandomID() == $matches[1])
928  {
929  $next_id = $ilDB->nextId('tst_solutions');
930  $affectedRows = $ilDB->insert("tst_solutions", array(
931  "solution_id" => array("integer", $next_id),
932  "active_fi" => array("integer", $active_id),
933  "question_fi" => array("integer", $this->getId()),
934  "value1" => array("clob", $answeridx),
935  "value2" => array("clob", $value),
936  "pass" => array("integer", $pass),
937  "tstamp" => array("integer", time())
938  ));
939  $entered_values++;
940  }
941  }
942  }
943  }
944  }
945  }
946  }
947 
948  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
949  }
950  if ($entered_values)
951  {
952  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
954  {
955  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
956  }
957  }
958  else
959  {
960  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
962  {
963  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
964  }
965  }
966 
967  return $saveWorkingDataResult;
968  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
& getAnswers()
Returns the answers array.
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getOrderingType()
Returns the ordering question type.
const OQ_NESTED_TERMS
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
checkSaveData()
Checks the data to be saved for consistency.
setLeveledOrdering($new_hierarchy, $with_random_id=false)
_getLogLanguage()
retrieve the log language for assessment logging
global $ilUser
Definition: imgupload.php:15
const OQ_NESTED_PICTURES
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
+ Here is the call graph for this function:

◆ setElementHeight()

assOrderingQuestion::setElementHeight (   $a_height)

Definition at line 1192 of file class.assOrderingQuestion.php.

1193  {
1194  $this->element_height = ($a_height < 20) ? "" : $a_height;
1195  }

◆ setExportDetailsXLS()

assOrderingQuestion::setExportDetailsXLS ( $worksheet,
  $startrow,
  $active_id,
  $pass,
$format_title,
$format_bold 
)

Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
object$format_titleExcel title format
object$format_boldExcel bold format
Returns
object

Definition at line 1125 of file class.assOrderingQuestion.php.

References $pass, ilExcelUtils\_convert_text(), getAnswers(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

1126  {
1127  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1128  $solutions = $this->getSolutionValues($active_id, $pass);
1129  $sol = array();
1130  foreach ($solutions as $solution)
1131  {
1132  $sol[$solution["value1"]] = $solution["value2"];
1133  }
1134  asort($sol);
1135  $sol = array_keys($sol);
1136  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1137  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1138  $i = 1;
1139  $answers = $this->getAnswers();
1140  foreach ($sol as $idx)
1141  {
1142  foreach ($solutions as $solution)
1143  {
1144  if ($solution["value1"] == $idx) $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($solution["value2"]));
1145  }
1146  $worksheet->writeString($startrow + $i, 1, ilExcelUtils::_convert_text($answers[$idx]->getAnswertext()));
1147  $i++;
1148  }
1149  return $startrow + $i + 1;
1150  }
& getAnswers()
Returns the answers array.
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
_convert_text($a_text, $a_target="has been removed")
getTitle()
Gets the title string of the assQuestion object.
+ Here is the call graph for this function:

◆ setImageFile()

assOrderingQuestion::setImageFile (   $image_tempfilename,
  $image_filename,
  $previous_filename 
)

Sets the image file and uploads the image to the object's image directory.

Parameters
string$image_filenameName of the original image file
string$image_tempfilenameName of the temporary uploaded image file
Returns
integer An errorcode if the image upload fails, 0 otherwise public

Definition at line 747 of file class.assOrderingQuestion.php.

References $result, ilUtil\convertImage(), deleteImagefile(), assQuestion\getImagePath(), getThumbPrefix(), ilUtil\makeDirParents(), and ilUtil\moveUploadedFile().

748  {
749  $result = TRUE;
750  if (strlen($image_tempfilename))
751  {
752  $image_filename = str_replace(" ", "_", $image_filename);
753  $imagepath = $this->getImagePath();
754  if (!file_exists($imagepath))
755  {
756  ilUtil::makeDirParents($imagepath);
757  }
758  $savename = $image_filename;
759  if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath.$savename))
760  {
761  $result = FALSE;
762  }
763  else
764  {
765  // create thumbnail file
766  $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
767  ilUtil::convertImage($imagepath.$savename, $thumbpath, "JPEG", $this->getThumbGeometry());
768  }
769  if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename)))
770  {
771  $this->deleteImagefile($previous_filename);
772  }
773  }
774  return $result;
775  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$result
getImagePath($question_id=null, $object_id=null)
Returns the image path for web accessable images of a question.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
+ Here is the call graph for this function:

◆ setLeveledOrdering()

assOrderingQuestion::setLeveledOrdering (   $new_hierarchy,
  $with_random_id = false 
)

Definition at line 1345 of file class.assOrderingQuestion.php.

References assQuestion\$id, and getDepthRecursive().

Referenced by checkSaveData(), and saveWorkingData().

1346  {
1347  if($with_random_id == true)
1348  {
1349  //for test output
1350  foreach($new_hierarchy as $id)
1351  {
1352  $ordering_depth = 0;
1353  $this->leveled_ordering[$id->id] = $ordering_depth;
1354 
1355  if(is_array($id->children))
1356  {
1357  foreach($id->children as $child)
1358  {
1359  $this->getDepthRecursive($child, $ordering_depth, true);
1360 }
1361  }
1362  }
1363  }
1364  else
1365  {
1366  foreach($new_hierarchy as $id)
1367  {
1368  $ordering_depth = 0;
1369  $this->leveled_ordering[] = $ordering_depth;
1370 
1371  if(is_array($id->children))
1372  {
1373  foreach($id->children as $child)
1374  {
1375  $this->getDepthRecursive($child, $ordering_depth, $with_random_id);
1376  }
1377  }
1378  }
1379  }
1380  }
getDepthRecursive($child, $ordering_depth, $with_random_id=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOrderingType()

assOrderingQuestion::setOrderingType (   $ordering_type = OQ_TERMS)

Sets the ordering question type.

Parameters
integer$ordering_typeThe question ordering type public
See also
$ordering_type

Definition at line 383 of file class.assOrderingQuestion.php.

References $ordering_type.

384  {
385  $this->ordering_type = $ordering_type;
386  }

◆ setThumbGeometry()

assOrderingQuestion::setThumbGeometry (   $a_geometry)

Definition at line 1172 of file class.assOrderingQuestion.php.

1173  {
1174  $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1175  }

◆ supportsJavascriptOutput()

assOrderingQuestion::supportsJavascriptOutput ( )

Returns true if the question type supports JavaScript output.

Returns
boolean TRUE if the question type supports JavaScript output, FALSE otherwise public

Definition at line 1103 of file class.assOrderingQuestion.php.

1104  {
1105  return TRUE;
1106  }

◆ supportsNonJsOutput()

assOrderingQuestion::supportsNonJsOutput ( )

Definition at line 1108 of file class.assOrderingQuestion.php.

1109  {
1110  return false;
1111  }

◆ toJSON()

assOrderingQuestion::toJSON ( )

Returns a JSON representation of the question.

Definition at line 1243 of file class.assOrderingQuestion.php.

References $mobs, $result, ilObjMediaObject\_getMobsOfObject(), assQuestion\formatSAQuestion(), getAnswers(), assQuestion\getId(), assQuestion\getImagePathWeb(), assQuestion\getNrOfTries(), getOrderingType(), assQuestion\getPoints(), assQuestion\getQuestion(), getQuestionType(), assQuestion\getTitle(), OQ_PICTURES, and assQuestion\pcArrayShuffle().

1244  {
1245  include_once("./Services/RTE/classes/class.ilRTE.php");
1246  $result = array();
1247  $result['id'] = (int) $this->getId();
1248  $result['type'] = (string) $this->getQuestionType();
1249  $result['title'] = (string) $this->getTitle();
1250  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1251  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1252  $result['shuffle'] = (bool) true;
1253  $result['points'] = (bool) $this->getPoints();
1254  $result['feedback'] = array(
1255  "onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false),
1256  "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)
1257  );
1258  if ($this->getOrderingType() == OQ_PICTURES)
1259  {
1260  $result['path'] = $this->getImagePathWeb();
1261  }
1262 
1263  $counter = 1;
1264  $answers = array();
1265  foreach ($this->getAnswers() as $answer_obj)
1266  {
1267  $answers[$counter] = $answer_obj->getAnswertext();
1268  $counter++;
1269  }
1270  $answers = $this->pcArrayShuffle($answers);
1271  $arr = array();
1272  foreach ($answers as $order => $answer)
1273  {
1274  array_push($arr, array(
1275  "answertext" => (string) $answer,
1276  "order" => (int) $order
1277  ));
1278  }
1279  $result['answers'] = $arr;
1280 
1281  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1282  $result['mobs'] = $mobs;
1283 
1284  return json_encode($result);
1285  }
getId()
Gets the id of the assQuestion object.
formatSAQuestion($a_q)
Format self assessment question.
$result
getPoints()
Returns the maximum available points for the question.
& getAnswers()
Returns the answers array.
getOrderingType()
Returns the ordering question type.
getQuestionType()
Returns the question type of the question.
getImagePathWeb()
Returns the web image path for web accessable images of a question.
$mobs
const OQ_PICTURES
Ordering question constants.
getQuestion()
Gets the question string of the question object.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
getTitle()
Gets the title string of the assQuestion object.
pcArrayShuffle($array)
Shuffles the values of a given array.
+ Here is the call graph for this function:

◆ updateLeveledOrdering()

assOrderingQuestion::updateLeveledOrdering (   $a_index,
  $a_answer_text,
  $a_depth 
)

Definition at line 1429 of file class.assOrderingQuestion.php.

1430  {
1431  global $ilDB;
1432 
1433  $ilDB->update('qpl_a_ordering',
1434  array('solution_order'=> array('integer', $a_index),
1435  'depth' => array('integer', $a_depth)),
1436  array('answertext' => array('text', $a_answer_text)));
1437 
1438  return true;
1439  }

Field Documentation

◆ $answers

assOrderingQuestion::$answers

Definition at line 31 of file class.assOrderingQuestion.php.

Referenced by getAnswers().

◆ $element_height

assOrderingQuestion::$element_height

Definition at line 55 of file class.assOrderingQuestion.php.

Referenced by getElementHeight().

◆ $leveled_ordering

assOrderingQuestion::$leveled_ordering = array()

Definition at line 58 of file class.assOrderingQuestion.php.

Referenced by getLeveledOrdering().

◆ $old_ordering_depth

assOrderingQuestion::$old_ordering_depth = array()

Definition at line 57 of file class.assOrderingQuestion.php.

Referenced by getOldLeveledOrdering().

◆ $ordering_type

assOrderingQuestion::$ordering_type

Definition at line 41 of file class.assOrderingQuestion.php.

Referenced by __construct(), getOrderingType(), and setOrderingType().

◆ $thumb_geometry

assOrderingQuestion::$thumb_geometry = 100

Definition at line 48 of file class.assOrderingQuestion.php.

Referenced by getThumbGeometry().


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