ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 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, $a_question_id)
 
 updateLeveledOrdering ($a_index, $a_answer_text, $a_depth)
 
 getOperators ($expression)
 Get all available operations for a specific question. More...
 
 getExpressionTypes ()
 Get all available expression types for a specific question. More...
 
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option. More...
 
- 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 from given hour, minute and second. More...
 
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string. 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...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question 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...
 
 buildImagePath ($questionId, $parentObjectId)
 
 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...
 
 _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 ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 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...
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 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, $unique=false)
 
 _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...
 
 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 ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 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...
 
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass. More...
 

Data Fields

 $answers
 
 $ordering_type
 
 $thumb_geometry = 100
 
 $element_height
 
 $old_ordering_depth = array()
 
 $leveled_ordering = array()
 
- Data Fields inherited from assQuestion
const IMG_MIME_TYPE_JPG = 'image/jpeg'
 
const IMG_MIME_TYPE_PNG = 'image/png'
 
const IMG_MIME_TYPE_GIF = 'image/gif'
 
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 = 0
 
 $questionActionCmd = 'handleQuestionAction'
 
- Data Fields inherited from iQuestionCondition
const StringResultExpression = '~TEXT~'
 
const PercentageResultExpression = '%n%'
 
const NumericResultExpression = '#n#'
 
const MatchingResultExpression = ';n:m;'
 
const OrderingResultExpression = '$n,m,o,p$'
 
const NumberOfResultExpression = '+n+'
 
const ExclusiveResultExpression = '*n,m,o,p*'
 
const EmptyAnswerExpression = "?"
 

Protected Member Functions

 getRandomID ()
 
 cleanImagefiles ()
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 generateThumbForFile ($path, $file)
 
 getSolutionSubmit ()
 
 calculateReachedPointsForSolution ($user_order, $nested_solution)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 {} More...
 
- Protected Member Functions inherited from assQuestion
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 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...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 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)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 buildQuestionDataQuery ()
 
 getSelfAssessmentFormatter ()
 

Private Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier ($contentTypeString)
 
static getAllowedFileExtensionsForMimeType ($mimeType)
 
static isAllowedImageFileExtension ($mimeType, $fileExtension)
 
static getAllowedImageFileExtensions ()
 
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 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static isFileAvailable ($file)
 
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 setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords ($activeId, $pass, $questionId)
 returns the number of 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
 
 $db
 
 $outputType
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $imageSourceFixReplaceMap
 

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 24 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 74 of file class.assOrderingQuestion.php.

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

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

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 416 of file class.assOrderingQuestion.php.

References getRandomID().

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

◆ afterSyncWithOriginal()

assOrderingQuestion::afterSyncWithOriginal (   $origQuestionId,
  $dupQuestionId,
  $origParentObjId,
  $dupParentObjId 
)
protected

{}

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

References duplicateImages().

1589  {
1590  parent::afterSyncWithOriginal($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId);
1591  $this->duplicateImages($dupQuestionId, $dupParentObjId, $origQuestionId, $origParentObjId);
1592  }
duplicateImages($src_question_id, $src_object_id, $dest_question_id, $dest_object_id)
+ 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 580 of file class.assOrderingQuestion.php.

References $data, $ilDB, $pass, assQuestion\$points, $result, calculateReachedPointsForSolution(), and assQuestion\getSolutionMaxPass().

Referenced by getExpressionTypes().

581  {
582  if( $returndetails )
583  {
584  throw new ilTestException('return details not implemented for '.__METHOD__);
585  }
586 
587  global $ilDB;
588 
589  $found_value1 = array();
590  $found_value2 = array();
591  if (is_null($pass))
592  {
593  $pass = $this->getSolutionMaxPass($active_id);
594  }
595  $result = $this->getCurrentSolutionResultSet($active_id, $pass);
596  $user_order = array();
597  $nested_solution = false;
598  while ($data = $ilDB->fetchAssoc($result))
599  {
600  if ((strcmp($data["value1"], "") != 0) && (strcmp($data["value2"], "") != 0))
601  {
602  if(strchr( $data['value2'],':') == true)
603  {
604 // //i.e. "61463:0" = "random_id:depth"
605  $current_solution = explode(':', $data['value2']);
606 
607  $user_order[$current_solution[0]]['index'] = $data["value1"];
608  $user_order[$current_solution[0]]['depth'] = $current_solution[1];
609  $user_order[$current_solution[0]]['random_id'] = $current_solution[0];
610 
611  $nested_solution = true;
612  }
613  else
614  {
615  $user_order[$data["value2"]] = $data["value1"];
616  $nested_solution = false;
617  }
618  }
619  }
620 
621  $points = $this->calculateReachedPointsForSolution($user_order, $nested_solution);
622 
623  return $points;
624  }
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
calculateReachedPointsForSolution($user_order, $nested_solution)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsForSolution()

assOrderingQuestion::calculateReachedPointsForSolution (   $user_order,
  $nested_solution 
)
protected
Parameters
$user_order
$nested_solution
Returns
int

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

References assQuestion\$points, getOrderingType(), assQuestion\getPoints(), OQ_NESTED_PICTURES, and OQ_NESTED_TERMS.

Referenced by calculateReachedPoints(), and calculateReachedPointsFromPreviewSession().

1284  {
1285  if($this->getOrderingType() != OQ_NESTED_PICTURES && $this->getOrderingType() != OQ_NESTED_TERMS)
1286  {
1287  ksort($user_order);
1288  $user_order = array_values($user_order);
1289  }
1290 
1291  $points = 0;
1292  $correctcount = 0;
1293 
1294  foreach($this->answers as $index => $answer)
1295  {
1296  if($nested_solution == true)
1297  {
1298  $random_id = $answer->getRandomID();
1299 
1300  if($random_id == $user_order[$random_id]['random_id'] && $answer->getOrderingDepth() == $user_order[$random_id]['depth'] && $index == $user_order[$random_id]['index'])
1301  {
1302  $correctcount++;
1303  }
1304  } else
1305  {
1306  if($index == $user_order[$index])
1307  {
1308  $correctcount++;
1309  }
1310  }
1311  }
1312 
1313  if($correctcount == count($this->answers))
1314  {
1315  $points = $this->getPoints();
1316  return $points;
1317  }
1318  return $points;
1319  }
getPoints()
Returns the maximum available points for the question.
getOrderingType()
Returns the ordering question type.
const OQ_NESTED_TERMS
const OQ_NESTED_PICTURES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateReachedPointsFromPreviewSession()

assOrderingQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

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

References calculateReachedPointsForSolution(), and ilAssQuestionPreviewSession\getParticipantsSolution().

627  {
628  $user_order = array();
629  $nested_solution = false;
630  foreach($previewSession->getParticipantsSolution() as $val1 => $val2)
631  {
632  if ((strcmp($val1, "") != 0) && (strcmp($val2, "") != 0))
633  {
634  if(strchr( $val2,':') == true)
635  {
636  $current_solution = explode(':', $val2);
637 
638  $user_order[$current_solution[0]]['index'] = $val1;
639  $user_order[$current_solution[0]]['depth'] = $current_solution[1];
640  $user_order[$current_solution[0]]['random_id'] = $current_solution[0];
641 
642  $nested_solution = true;
643  }
644  else
645  {
646  $user_order[$val2] = $val1;
647  $nested_solution = false;
648  }
649  }
650  }
651 
652  return $this->calculateReachedPointsForSolution($user_order, $nested_solution);
653  }
calculateReachedPointsForSolution($user_order, $nested_solution)
+ 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 777 of file class.assOrderingQuestion.php.

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

Referenced by savePreviewData(), and saveWorkingData().

778  {
779  $result = true;
780  if ($this->getOutputType() == OUTPUT_JAVASCRIPT)
781  {
782  if (strlen($_POST["orderresult"]))
783  {
784  return $result;
785  }
786  else if(strlen($_POST['answers_ordering']))
787  {
788  $answers_ordering = $_POST['answers_ordering'];
789  $new_hierarchy = json_decode($answers_ordering);
790  $with_random_id = true;
791  $this->setLeveledOrdering($new_hierarchy, $with_random_id);
792 
793  //return value as "random_id:depth"
794  return serialize($this->leveled_ordering);
795  }
796  }
797  $order_values = array();
798  foreach ($_POST as $key => $value)
799  {
800  if (preg_match("/^order_(\d+)/", $key, $matches))
801  {
802  if (strcmp($value, "") != 0)
803  {
804  array_push($order_values, $value);
805  }
806  }
807  }
808  $check_order = array_flip($order_values);
809  if (count($check_order) != count($order_values))
810  {
811  // duplicate order values!!!
812  $result = false;
813  ilUtil::sendInfo($this->lng->txt("duplicate_order_values_entered"), TRUE);
814  }
815  return $result;
816  }
$_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 684 of file class.assOrderingQuestion.php.

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

Referenced by savePreviewData().

685  {
686  if ($this->getOrderingType() == OQ_PICTURES)
687  {
688  if (@file_exists($this->getImagePath()))
689  {
690  $contents = ilUtil::getDir($this->getImagePath());
691  foreach ($contents as $f)
692  {
693  if (strcmp($f['type'], 'file') == 0)
694  {
695  $found = false;
696  foreach ($this->getAnswers() as $answer)
697  {
698  if (strcmp($f['entry'], $answer->getAnswertext()) == 0) $found = true;
699  if (strcmp($f['entry'], $this->getThumbPrefix() . $answer->getAnswertext()) == 0) $found = true;
700  }
701  if (!$found)
702  {
703  if (@file_exists($this->getImagePath() . $f['entry'])) @unlink($this->getImagePath() . $f['entry']);
704  }
705  }
706  }
707  }
708  }
709  else
710  {
711  if (@file_exists($this->getImagePath()))
712  {
713  ilUtil::delDir($this->getImagePath());
714  }
715  }
716  }
& 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 349 of file class.assOrderingQuestion.php.

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

350  {
351  global $ilLog;
352  if ($this->getOrderingType() == OQ_PICTURES)
353  {
354  $imagepath = $this->getImagePath();
355  $imagepath_original = str_replace("/$this->id/images", "/$question_id/images", $imagepath);
356  $imagepath_original = str_replace("/$this->obj_id/", "/$source_questionpool/", $imagepath_original);
357  if (!file_exists($imagepath)) {
358  ilUtil::makeDirParents($imagepath);
359  }
360  foreach ($this->answers as $answer)
361  {
362  $filename = $answer->getAnswertext();
363  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
364  {
365  $ilLog->write("Ordering Question image could not be copied: $imagepath_original$filename");
366  }
367  if (@file_exists($imagepath_original. $this->getThumbPrefix(). $filename))
368  {
369  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
370  {
371  $ilLog->write("Ordering Question image thumbnail could not be copied: $imagepath_original" . $this->getThumbPrefix() . $filename);
372  }
373  }
374  }
375  }
376  }
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 250 of file class.assOrderingQuestion.php.

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

251  {
252  if ($this->id <= 0)
253  {
254  // The question has not been saved. It cannot be duplicated
255  return;
256  }
257  // duplicate the question in database
258  $clone = $this;
259  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
261  $clone->id = -1;
262  $source_questionpool_id = $this->getObjId();
263  $clone->setObjId($target_questionpool_id);
264  if ($title)
265  {
266  $clone->setTitle($title);
267  }
268 
269  $clone->saveToDb();
270 
271  // copy question page content
272  $clone->copyPageOfQuestion($original_id);
273  // copy XHTML media objects
274  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
275  // duplicate the image
276  $clone->copyImages($original_id, $source_questionpool_id);
277 
278  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
279 
280  return $clone->id;
281  }
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 283 of file class.assOrderingQuestion.php.

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

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

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

◆ deleteImagefile()

assOrderingQuestion::deleteImagefile (   $filename)

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

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

Referenced by removeAnswerImage(), and setImageFile().

725  {
726  $deletename = $$filename;
727  $result = @unlink($this->getImagePath().$deletename);
728  $result = $result & @unlink($this->getImagePath().$this->getThumbPrefix() . $deletename);
729  return $result;
730  }
$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 191 of file class.assOrderingQuestion.php.

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

192  {
193  if ($this->id <= 0)
194  {
195  // The question has not been saved. It cannot be duplicated
196  return;
197  }
198  // duplicate the question in database
199  $this_id = $this->getId();
200  $thisObjId = $this->getObjId();
201 
202  $clone = $this;
203  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
205  $clone->id = -1;
206 
207  if( (int)$testObjId > 0 )
208  {
209  $clone->setObjId($testObjId);
210  }
211 
212  if ($title)
213  {
214  $clone->setTitle($title);
215  }
216  if ($author)
217  {
218  $clone->setAuthor($author);
219  }
220  if ($owner)
221  {
222  $clone->setOwner($owner);
223  }
224  if ($for_test)
225  {
226  $clone->saveToDb($original_id);
227  }
228  else
229  {
230  $clone->saveToDb();
231  }
232 
233  // copy question page content
234  $clone->copyPageOfQuestion($this_id);
235  // copy XHTML media objects
236  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
237  // duplicate the image
238  $clone->duplicateImages($this_id, $thisObjId, $clone->getId(), $testObjId);
239 
240  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
241 
242  return $clone->id;
243  }
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 320 of file class.assOrderingQuestion.php.

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

Referenced by afterSyncWithOriginal().

321  {
322  global $ilLog;
323  if ($this->getOrderingType() == OQ_PICTURES || $this->getOrderingType() == OQ_NESTED_PICTURES)
324  {
325  $imagepath_original = $this->getImagePath($src_question_id, $src_object_id);
326  $imagepath = $this->getImagePath($dest_question_id, $dest_object_id);
327 
328  if (!file_exists($imagepath)) {
329  ilUtil::makeDirParents($imagepath);
330  }
331  foreach ($this->answers as $answer)
332  {
333  $filename = $answer->getAnswertext();
334  if (!@copy($imagepath_original . $filename, $imagepath . $filename))
335  {
336  $ilLog->write("image could not be duplicated!!!!");
337  }
338  if (@file_exists($imagepath_original. $this->getThumbPrefix(). $filename))
339  {
340  if (!@copy($imagepath_original . $this->getThumbPrefix() . $filename, $imagepath . $this->getThumbPrefix() . $filename))
341  {
342  $ilLog->write("image thumbnail could not be duplicated!!!!");
343  }
344  }
345  }
346  }
347  }
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
const OQ_NESTED_PICTURES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flushAnswers()

assOrderingQuestion::flushAnswers ( )

Deletes all answers.

public

See also
$answers

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

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

◆ generateThumbForFile()

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

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

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

Referenced by rebuildThumbnails().

1125  {
1126  $filename = $path . $file;
1127  if (@file_exists($filename))
1128  {
1129  $thumbpath = $path . $this->getThumbPrefix() . $file;
1130  $path_info = @pathinfo($filename);
1131  $ext = "";
1132  switch (strtoupper($path_info['extension']))
1133  {
1134  case 'PNG':
1135  $ext = 'PNG';
1136  break;
1137  case 'GIF':
1138  $ext = 'GIF';
1139  break;
1140  default:
1141  $ext = 'JPEG';
1142  break;
1143  }
1144  ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbGeometry());
1145  }
1146  }
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 966 of file class.assOrderingQuestion.php.

Referenced by loadFromDb(), and savePreviewData().

967  {
968  return "qpl_qst_ordering";
969  }
+ 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 480 of file class.assOrderingQuestion.php.

Referenced by getAvailableAnswerOptions().

481  {
482  if ($index < 0) return NULL;
483  if (count($this->answers) < 1) return NULL;
484  if ($index >= count($this->answers)) return NULL;
485  return $this->answers[$index];
486  }
+ Here is the caller graph for this function:

◆ 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 539 of file class.assOrderingQuestion.php.

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

◆ getAnswers()

& assOrderingQuestion::getAnswers ( )

Returns the answers array.

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

References $answers.

Referenced by cleanImagefiles(), getAvailableAnswerOptions(), getExpressionTypes(), getRandomID(), getSolutionSubmit(), rebuildThumbnails(), setExportDetailsXLS(), and toJSON().

1001  {
1002  return $this->answers;
1003  }
+ 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 977 of file class.assOrderingQuestion.php.

978  {
979  return "qpl_a_ordering";
980  }

◆ getAvailableAnswerOptions()

assOrderingQuestion::getAvailableAnswerOptions (   $index = null)

If index is null, the function returns an array with all anwser options Else it returns the specific answer option.

Parameters
null | int$index
Returns
array|ASS_AnswerSimple

Implements iQuestionCondition.

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

References getAnswer(), and getAnswers().

1574  {
1575  if($index !== null)
1576  {
1577  return $this->getAnswer($index);
1578  }
1579  else
1580  {
1581  return $this->getAnswers();
1582  }
1583  }
& getAnswers()
Returns the answers array.
getAnswer($index=0)
Returns an ordering answer with a given index.
+ Here is the call graph for this function:

◆ getDepthRecursive()

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

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

Referenced by setLeveledOrdering().

1327  {
1328  if($with_random_id == true)
1329  {
1330  // for test ouput
1331  if(is_array($child->children))
1332  {
1333  foreach($child->children as $grand_child)
1334  {
1335  $ordering_depth++;
1336  $this->leveled_ordering[$child->id] = $ordering_depth;
1337  $this->getDepthRecursive($grand_child, $ordering_depth, true);
1338  }
1339  }
1340  else
1341  {
1342  $ordering_depth++;
1343  $this->leveled_ordering[$child->id] = $ordering_depth;
1344  }
1345  }
1346  else
1347  {
1348  if(is_array($child->children))
1349  {
1350  foreach($child->children as $grand_child)
1351  {
1352  $ordering_depth++;
1353  $this->leveled_ordering[] = $ordering_depth;
1354  $this->getDepthRecursive($grand_child, $ordering_depth);
1355  }
1356  }
1357  else
1358  {
1359  $ordering_depth++;
1360  $this->leveled_ordering[] = $ordering_depth;
1361  }
1362  }
1363  }
getDepthRecursive($child, $ordering_depth, $with_random_id=false)
+ Here is the caller graph for this function:

◆ getElementHeight()

assOrderingQuestion::getElementHeight ( )

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

References $element_height.

Referenced by savePreviewData().

1091  {
1092  return $this->element_height;
1093  }
+ Here is the caller graph for this function:

◆ getEncryptedFilename()

assOrderingQuestion::getEncryptedFilename (   $filename)

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

References $filename.

675  {
676  $extension = "";
677  if (preg_match("/.*\\.(\\w+)$/", $filename, $matches))
678  {
679  $extension = $matches[1];
680  }
681  return md5($filename) . "." . $extension;
682  }
$filename
Definition: buildRTE.php:89

◆ getExpressionTypes()

◆ getLeveledOrdering()

assOrderingQuestion::getLeveledOrdering ( )

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

References $leveled_ordering.

1412  {
1413  return $this->leveled_ordering;
1414  }

◆ getMaximumPoints()

assOrderingQuestion::getMaximumPoints ( )

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

Returns
double Points
See also
$points

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

References assQuestion\getPoints().

Referenced by getExpressionTypes(), and isComplete().

662  {
663  return $this->getPoints();
664  }
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 550 of file class.assOrderingQuestion.php.

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

◆ getOldLeveledOrdering()

assOrderingQuestion::getOldLeveledOrdering ( )

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

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

1417  {
1418  global $ilDB;
1419 
1420  $res = $ilDB->queryF('SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC',
1421  array('integer'), array($this->getId()));
1422  while($row = $ilDB->fetchAssoc($res))
1423  {
1424  $this->old_ordering_depth[] = $row['depth'];
1425  }
1427  }
getId()
Gets the id of the assQuestion object.
global $ilDB
+ Here is the call graph for this function:

◆ getOperators()

assOrderingQuestion::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
string$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

1481  {
1482  require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
1484  }
+ 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 397 of file class.assOrderingQuestion.php.

References $ordering_type.

Referenced by calculateReachedPointsForSolution(), cleanImagefiles(), copyImages(), duplicateImages(), getExpressionTypes(), getSolutionSubmit(), rebuildThumbnails(), savePreviewData(), and toJSON().

398  {
399  return $this->ordering_type;
400  }
+ 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 955 of file class.assOrderingQuestion.php.

Referenced by toJSON().

956  {
957  return "assOrderingQuestion";
958  }
+ Here is the caller graph for this function:

◆ getRandomID()

assOrderingQuestion::getRandomID ( )
protected

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

References getAnswers().

Referenced by addAnswer().

453  {
454  $random_number = mt_rand(1, 100000);
455  $found = true;
456  while ($found)
457  {
458  $found = false;
459  foreach ($this->getAnswers() as $answer)
460  {
461  if ($answer->getRandomID() == $random_number)
462  {
463  $found = true;
464  $random_number++;
465  }
466  }
467  }
468  return $random_number;
469  }
& 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 986 of file class.assOrderingQuestion.php.

987  {
988  $text = parent::getRTETextWithMediaObjects();
989  foreach ($this->answers as $index => $answer)
990  {
991  $answer_obj = $this->answers[$index];
992  $text .= $answer_obj->getAnswertext();
993  }
994  return $text;
995  }

◆ getSolutionSubmit()

assOrderingQuestion::getSolutionSubmit ( )
protected
Returns
array

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

References $_POST, getAnswers(), getOrderingType(), OQ_NESTED_PICTURES, OQ_NESTED_TERMS, and setLeveledOrdering().

Referenced by savePreviewData(), and saveWorkingData().

1208  {
1209  $solutionSubmit = array();
1210 
1211  if(array_key_exists("orderresult", $_POST))
1212  {
1213  $orderresult = $_POST["orderresult"];
1214  if(strlen($orderresult))
1215  {
1216  $orderarray = explode(":", $orderresult);
1217  $ordervalue = 1;
1218  foreach($orderarray as $index)
1219  {
1220  $idmatch = null;
1221  if(preg_match("/id_(\\d+)/", $index, $idmatch))
1222  {
1223  $randomid = $idmatch[1];
1224  foreach($this->getAnswers() as $answeridx => $answer)
1225  {
1226  if($answer->getRandomID() == $randomid)
1227  {
1228  $solutionSubmit[$answeridx] = $ordervalue;
1229  $ordervalue++;
1230  }
1231  }
1232  }
1233  }
1234  }
1235  }
1236  else if($this->getOrderingType() == OQ_NESTED_TERMS || $this->getOrderingType() == OQ_NESTED_PICTURES)
1237  {
1238  $answers_ordering = $_POST['answers_ordering__participant'];
1239  $user_solution_hierarchy = json_decode($answers_ordering);
1240  $with_random_id = true;
1241  $this->setLeveledOrdering($user_solution_hierarchy, $with_random_id);
1242 
1243  $index = 0;
1244  foreach($this->leveled_ordering as $random_id => $depth)
1245  {
1246  $value_2 = implode(':', array($random_id, $depth));
1247  $solutionSubmit[$index] = $value_2;
1248  $index++;
1249  }
1250  }
1251  else
1252  {
1253  foreach($_POST as $key => $value)
1254  {
1255  $matches = null;
1256  if(preg_match("/^order_(\d+)/", $key, $matches))
1257  {
1258  if(!(preg_match("/initial_value_\d+/", $value)))
1259  {
1260  if(strlen($value))
1261  {
1262  foreach($this->getAnswers() as $answeridx => $answer)
1263  {
1264  if($answer->getRandomID() == $matches[1])
1265  {
1266  $solutionSubmit[$answeridx] = $value;
1267  }
1268  }
1269  }
1270  }
1271  }
1272  }
1273  }
1274 
1275  return $solutionSubmit;
1276  }
$_POST['username']
Definition: cron.php:12
& getAnswers()
Returns the answers array.
getOrderingType()
Returns the ordering question type.
const OQ_NESTED_TERMS
setLeveledOrdering($new_hierarchy, $with_random_id=false)
const OQ_NESTED_PICTURES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getThumbGeometry()

assOrderingQuestion::getThumbGeometry ( )

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

References $thumb_geometry.

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

1066  {
1067  return $this->thumb_geometry;
1068  }
+ Here is the caller graph for this function:

◆ getThumbPrefix()

assOrderingQuestion::getThumbPrefix ( )

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

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

1120  {
1121  return "thumb.";
1122  }
+ Here is the caller graph for this function:

◆ getThumbSize()

assOrderingQuestion::getThumbSize ( )

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

References getThumbGeometry().

1071  {
1072  return $this->getThumbGeometry();
1073  }
+ 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 93 of file class.assOrderingQuestion.php.

References getMaximumPoints().

94  {
95  if (
96  strlen($this->title) &&
97  $this->author &&
98  $this->question &&
99  count($this->answers) &&
100  $this->getMaximumPoints() > 0
101  )
102  {
103  return true;
104  }
105  return false;
106  }
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 132 of file class.assOrderingQuestion.php.

References $data, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), 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().

133  {
134  global $ilDB;
135 
136  $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",
137  array("integer"),
138  array($question_id)
139  );
140  if ($result->numRows() == 1)
141  {
142  $data = $ilDB->fetchAssoc($result);
143  $this->setId($question_id);
144  $this->setObjId($data["obj_fi"]);
145  $this->setTitle($data["title"]);
146  $this->setComment($data["description"]);
147  $this->setOriginalId($data["original_id"]);
148  $this->setAuthor($data["author"]);
149  $this->setNrOfTries($data['nr_of_tries']);
150  $this->setPoints($data["points"]);
151  $this->setOwner($data["owner"]);
152  include_once("./Services/RTE/classes/class.ilRTE.php");
153  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
154  $this->ordering_type = strlen($data["ordering_type"]) ? $data["ordering_type"] : OQ_TERMS;
155  $this->thumb_geometry = $data["thumb_geometry"];
156  $this->element_height = $data["element_height"];
157  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
158 
159  try
160  {
161  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
162  }
164  {
165  }
166  }
167 
168  $result = $ilDB->queryF("SELECT * FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC",
169  array('integer'),
170  array($question_id)
171  );
172 
173  include_once "./Modules/TestQuestionPool/classes/class.assAnswerOrdering.php";
174  if ($result->numRows() > 0)
175  {
176  while ($data = $ilDB->fetchAssoc($result))
177  {
178  include_once("./Services/RTE/classes/class.ilRTE.php");
179  $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
180  array_push($this->answers, new ASS_AnswerOrdering($data["answertext"], $data["random_id"], $data['depth'] ? $data['depth'] : 0));
181  }
182  }
183  parent::loadFromDb($question_id);
184  }
$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 from given hour, minute and second. ...
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setAuthor($author="")
Sets the authors name of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
const OQ_TERMS
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
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,
  $a_question_id 
)

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

References $ilDB, $res, and $row.

1450  {
1451  global $ilDB;
1452 
1453  $res = $ilDB->queryF('SELECT answertext FROM qpl_a_ordering WHERE random_id = %s AND question_fi = %s',
1454  array('integer', 'integer'), array($a_random_id, $a_question_id));
1455  $row = $ilDB->fetchAssoc($res);
1456 
1457  return $row['answertext'];
1458  }
global $ilDB

◆ lookupSolutionOrderByRandomid()

assOrderingQuestion::lookupSolutionOrderByRandomid (   $a_random_id)

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

References $ilDB, $res, and $row.

1434  {
1435  global $ilDB;
1436 
1437  $res = $ilDB->queryF('SELECT solution_order FROM qpl_a_ordering WHERE random_id = %s',
1438  array('integer'), array($a_random_id));
1439  $row = $ilDB->fetchAssoc($res);
1440 
1441  return $row['solution_order'];
1442  }
global $ilDB

◆ moveAnswerDown()

assOrderingQuestion::moveAnswerDown (   $position)

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

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

◆ moveAnswerUp()

assOrderingQuestion::moveAnswerUp (   $position)

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

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

◆ rebuildThumbnails()

assOrderingQuestion::rebuildThumbnails ( )

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

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

Referenced by savePreviewData().

1109  {
1110  if ($this->getOrderingType() == OQ_PICTURES || $this->getOrderingType() == OQ_NESTED_PICTURES)
1111  {
1112  foreach ($this->getAnswers() as $answer)
1113  {
1114  $this->generateThumbForFile($this->getImagePath(), $answer->getAnswertext());
1115  }
1116  }
1117  }
& 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 1195 of file class.assOrderingQuestion.php.

References deleteImagefile().

1196  {
1197  $answer = $this->answers[$index];
1198  if (is_object($answer))
1199  {
1200  $this->deleteImagefile($answer->getAnswertext());
1201  $answer->setAnswertext('');
1202  }
1203  }
+ 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 944 of file class.assOrderingQuestion.php.

945  {
946  // nothing to rework!
947  }

◆ savePreviewData()

◆ saveToDb()

assOrderingQuestion::saveToDb (   $original_id = "")

Saves a assOrderingQuestion object to a database.

Parameters
string$original_id

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

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

116  {
117  global $ilDB;
118 
122  parent::saveToDb($original_id);
123  }
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="")
global $ilDB
+ 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 826 of file class.assOrderingQuestion.php.

References $pass, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), checkSaveData(), assQuestion\getId(), assQuestion\getProcessLocker(), getSolutionSubmit(), and assQuestion\logAction().

827  {
828  $saveWorkingDataResult = $this->checkSaveData();
829  if ($saveWorkingDataResult)
830  {
831  if (is_null($pass))
832  {
833  include_once "./Modules/Test/classes/class.ilObjTest.php";
834  $pass = ilObjTest::_getPass($active_id);
835  }
836 
837  $this->getProcessLocker()->requestUserSolutionUpdateLock();
838 
839  $affectedRows = $this->removeCurrentSolution($active_id, $pass);
840 
841  $entered_values = 0;
842  foreach($this->getSolutionSubmit() as $val1 => $val2)
843  {
844  $this->saveCurrentSolution($active_id, $pass, $val1, trim($val2));
845  $entered_values++;
846  }
847 
848  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
849  }
850  if ($entered_values)
851  {
852  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
854  {
855  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
856  }
857  }
858  else
859  {
860  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
862  {
863  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
864  }
865  }
866 
867  return $saveWorkingDataResult;
868  }
getId()
Gets the id of the assQuestion object.
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
checkSaveData()
Checks the data to be saved for consistency.
_getLogLanguage()
retrieve the log language for assessment logging
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 1100 of file class.assOrderingQuestion.php.

1101  {
1102  $this->element_height = ($a_height < 20) ? "" : $a_height;
1103  }

◆ 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 1033 of file class.assOrderingQuestion.php.

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

1034  {
1035  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1036  $solutions = $this->getSolutionValues($active_id, $pass);
1037  $sol = array();
1038  foreach ($solutions as $solution)
1039  {
1040  $sol[$solution["value1"]] = $solution["value2"];
1041  }
1042  asort($sol);
1043  $sol = array_keys($sol);
1044  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1045  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1046  $i = 1;
1047  $answers = $this->getAnswers();
1048  foreach ($sol as $idx)
1049  {
1050  foreach ($solutions as $solution)
1051  {
1052  if ($solution["value1"] == $idx) $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($solution["value2"]));
1053  }
1054  $worksheet->writeString($startrow + $i, 1, ilExcelUtils::_convert_text($answers[$idx]->getAnswertext()));
1055  $i++;
1056  }
1057  return $startrow + $i + 1;
1058  }
& 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 740 of file class.assOrderingQuestion.php.

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

741  {
742  $result = TRUE;
743  if (strlen($image_tempfilename))
744  {
745  $image_filename = str_replace(" ", "_", $image_filename);
746  $imagepath = $this->getImagePath();
747  if (!file_exists($imagepath))
748  {
749  ilUtil::makeDirParents($imagepath);
750  }
751  $savename = $image_filename;
752  if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath.$savename))
753  {
754  $result = FALSE;
755  }
756  else
757  {
758  // create thumbnail file
759  $thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
760  ilUtil::convertImage($imagepath.$savename, $thumbpath, "JPEG", $this->getThumbGeometry());
761  }
762  if ($result && (strcmp($image_filename, $previous_filename) != 0) && (strlen($previous_filename)))
763  {
764  $this->deleteImagefile($previous_filename);
765  }
766  }
767  return $result;
768  }
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 1369 of file class.assOrderingQuestion.php.

References assQuestion\$id, and getDepthRecursive().

Referenced by checkSaveData(), and getSolutionSubmit().

1370  {
1371  if($with_random_id == true)
1372  {
1373  //for test output
1374  if(is_array($new_hierarchy))
1375  {
1376  foreach($new_hierarchy as $id)
1377  {
1378  $ordering_depth = 0;
1379  $this->leveled_ordering[$id->id] = $ordering_depth;
1380 
1381  if(is_array($id->children))
1382  {
1383  foreach($id->children as $child)
1384  {
1385  $this->getDepthRecursive($child, $ordering_depth, true);
1386  }
1387  }
1388  }
1389  }
1390  }
1391  else
1392  {
1393  if(is_array($new_hierarchy))
1394  {
1395  foreach($new_hierarchy as $id)
1396  {
1397  $ordering_depth = 0;
1398  $this->leveled_ordering[] = $ordering_depth;
1399 
1400  if(is_array($id->children))
1401  {
1402  foreach($id->children as $child)
1403  {
1404  $this->getDepthRecursive($child, $ordering_depth, $with_random_id);
1405  }
1406  }
1407  }
1408  }
1409  }
1410  }
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 385 of file class.assOrderingQuestion.php.

References $ordering_type.

386  {
387  $this->ordering_type = $ordering_type;
388  }

◆ setThumbGeometry()

assOrderingQuestion::setThumbGeometry (   $a_geometry)

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

1081  {
1082  $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1083  }

◆ 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 1011 of file class.assOrderingQuestion.php.

1012  {
1013  return TRUE;
1014  }

◆ supportsNonJsOutput()

assOrderingQuestion::supportsNonJsOutput ( )

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

1017  {
1018  return false;
1019  }

◆ toJSON()

assOrderingQuestion::toJSON ( )

Returns a JSON representation of the question.

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

1152  {
1153  include_once("./Services/RTE/classes/class.ilRTE.php");
1154  $result = array();
1155  $result['id'] = (int) $this->getId();
1156  $result['type'] = (string) $this->getQuestionType();
1157  $result['title'] = (string) $this->getTitle();
1158  $result['question'] = $this->formatSAQuestion($this->getQuestion());
1159  $result['nr_of_tries'] = (int) $this->getNrOfTries();
1160  $result['shuffle'] = (bool) true;
1161  $result['points'] = $this->getPoints();
1162  $result['feedback'] = array(
1163  'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
1164  'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
1165  );
1166  if ($this->getOrderingType() == OQ_PICTURES)
1167  {
1168  $result['path'] = $this->getImagePathWeb();
1169  }
1170 
1171  $counter = 1;
1172  $answers = array();
1173  foreach ($this->getAnswers() as $answer_obj)
1174  {
1175  $answers[$counter] = $answer_obj->getAnswertext();
1176  $counter++;
1177  }
1178  $answers = $this->pcArrayShuffle($answers);
1179  $arr = array();
1180  foreach ($answers as $order => $answer)
1181  {
1182  array_push($arr, array(
1183  "answertext" => (string) $answer,
1184  "order" => (int) $order
1185  ));
1186  }
1187  $result['answers'] = $arr;
1188 
1189  $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
1190  $result['mobs'] = $mobs;
1191 
1192  return json_encode($result);
1193  }
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.
const OQ_PICTURES
Ordering question constants.
$mobs
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 1460 of file class.assOrderingQuestion.php.

References $ilDB.

1461  {
1462  global $ilDB;
1463 
1464  $ilDB->update('qpl_a_ordering',
1465  array('solution_order'=> array('integer', $a_index),
1466  'depth' => array('integer', $a_depth)),
1467  array('answertext' => array('text', $a_answer_text)));
1468 
1469  return true;
1470  }
global $ilDB

Field Documentation

◆ $answers

assOrderingQuestion::$answers

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

Referenced by getAnswers().

◆ $element_height

assOrderingQuestion::$element_height

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

Referenced by getElementHeight().

◆ $leveled_ordering

assOrderingQuestion::$leveled_ordering = array()

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

Referenced by getLeveledOrdering().

◆ $old_ordering_depth

assOrderingQuestion::$old_ordering_depth = array()

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

Referenced by getOldLeveledOrdering().

◆ $ordering_type

assOrderingQuestion::$ordering_type

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

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

◆ $thumb_geometry

assOrderingQuestion::$thumb_geometry = 100

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

Referenced by getThumbGeometry().


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