ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
assFormulaQuestion Class Reference

Class for single choice questions assFormulaQuestion is a class for single choice questions. More...

+ Inheritance diagram for assFormulaQuestion:
+ Collaboration diagram for assFormulaQuestion:

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assFormulaQuestion constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestion object. More...
 
 clearVariables ()
 
 getVariables ()
 
 getVariable ($variable)
 
 addVariable ($variable)
 
 clearResults ()
 
 getResults ()
 
 getResult ($result)
 
 addResult ($result)
 
 addResultUnits ($result, $unit_ids)
 
 addResultUnit ($result, $unit)
 
 getResultUnits ($result)
 
 hasResultUnit ($result, $unit_id)
 
 parseQuestionText ()
 
 checkForDuplicateVariables ()
 
 checkForDuplicateResults ()
 
 substituteVariables ($userdata=null, $graphicalOutput=FALSE, $forsolution=FALSE, $result_output=FALSE)
 
 canUseAdvancedRating ($result)
 Check if advanced rating can be used for a result. More...
 
 isComplete ()
 Returns true, if the question is complete for use. More...
 
 saveToDb ($original_id="")
 Saves a assFormulaQuestion object to a database public. More...
 
 loadFromDb ($question_id)
 Loads a assFormulaQuestion object from a database. More...
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assFormulaQuestion public. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assFormulaQuestion object public. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 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. 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...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 getBestSolution ($active_id, $pass)
 Returns the best solution for a given pass of a participant. More...
 
 setId ($id=-1)
 
 __get ($value)
 Object getter. More...
 
 setUnitrepository ($unitrepository)
 
 getUnitrepository ()
 
- 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)
 

Protected Member Functions

 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
- 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 Attributes

 $variables
 
 $results
 
 $resultunits
 
 $unitrepository
 

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...
 
- 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
 
- 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 single choice questions assFormulaQuestion is a class for single choice 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
Version
Id
class.assFormulaQuestion.php 1236 2010-02-15 15:44:16Z hschottm

Definition at line 17 of file class.assFormulaQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

assFormulaQuestion::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

assFormulaQuestion constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestion 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 single choice question public
See also
assQuestion:assQuestion()

Definition at line 39 of file class.assFormulaQuestion.php.

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

46  {
47  parent::__construct($title, $comment, $author, $owner, $question);
48  $this->variables = array();
49  $this->results = array();
50  $this->resultunits = array();
51  $this->unitrepository = new ilUnitConfigurationRepository(0);
52 
53  }
Class ilUnitConfigurationRepository.

Member Function Documentation

◆ __get()

assFormulaQuestion::__get (   $value)

Object getter.

Definition at line 1294 of file class.assFormulaQuestion.php.

References $resultunits.

1295  {
1296  switch($value)
1297  {
1298  case "resultunits":
1299  return $this->resultunits;
1300  break;
1301  default:
1302  return parent::__get($value);
1303  break;
1304  }
1305  }

◆ addResult()

assFormulaQuestion::addResult (   $result)

Definition at line 98 of file class.assFormulaQuestion.php.

References $result.

Referenced by loadFromDb(), and parseQuestionText().

99  {
100  $this->results[$result->getResult()] = $result;
101  }
$result
+ Here is the caller graph for this function:

◆ addResultUnit()

assFormulaQuestion::addResultUnit (   $result,
  $unit 
)

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

References $result.

Referenced by loadFromDb().

114  {
115  if(is_object($result) && is_object($unit))
116  {
117  if(!is_array($this->resultunits[$result->getResult()]))
118  {
119  $this->resultunits[$result->getResult()] = array();
120  }
121  $this->resultunits[$result->getResult()][$unit->getId()] = $unit;
122 
123  }
124  }
$result
+ Here is the caller graph for this function:

◆ addResultUnits()

assFormulaQuestion::addResultUnits (   $result,
  $unit_ids 
)

Definition at line 103 of file class.assFormulaQuestion.php.

References assQuestion\$id, $result, and getUnitrepository().

104  {
105  $this->resultunits[$result->getResult()] = array();
106  if((!is_object($result)) || (!is_array($unit_ids))) return;
107  foreach($unit_ids as $id)
108  {
109  if(is_numeric($id) && ($id > 0)) $this->resultunits[$result->getResult()][$id] = $this->getUnitrepository()->getUnit($id);
110  }
111  }
$result
+ Here is the call graph for this function:

◆ addVariable()

assFormulaQuestion::addVariable (   $variable)

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

Referenced by loadFromDb(), and parseQuestionText().

75  {
76  $this->variables[$variable->getVariable()] = $variable;
77  }
+ Here is the caller graph for this function:

◆ calculateReachedPoints()

assFormulaQuestion::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.

Parameters
integer$user_idThe database ID of the learner
integer$test_idThe database Id of the test containing the question public

Definition at line 920 of file class.assFormulaQuestion.php.

References $pass, assQuestion\$points, $result, getResults(), assQuestion\getSolutionMaxPass(), assQuestion\getSolutionValues(), getVariable(), and getVariables().

921  {
922  if(is_null($pass))
923  {
924  $pass = $this->getSolutionMaxPass($active_id);
925  }
926  $solutions =& $this->getSolutionValues($active_id, $pass);
927  $user_solution = array();
928  foreach($solutions as $idx => $solution_value)
929  {
930  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
931  {
932  $user_solution[$matches[1]] = $solution_value["value2"];
933  $varObj = $this->getVariable($solution_value["value1"]);
934  $varObj->setValue($solution_value["value2"]);
935  }
936  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
937  {
938  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
939  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
940  }
941  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
942  {
943  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
944  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
945  }
946  }
947  $points = 0;
948  foreach($this->getResults() as $result)
949  {
950  if( isset($user_solution[$result->getResult()]["value"]) )
951  {
952  $v = $user_solution[$result->getResult()]["value"];
953  }
954  else
955  {
956  $v = null;
957  }
958 
959  if( isset($user_solution[$result->getResult()]["unit"]) )
960  {
961  $u = $user_solution[$result->getResult()]["unit"];
962  }
963  else
964  {
965  $u = null;
966  }
967 
968  $points += $result->getReachedPoints($this->getVariables(), $this->getResults(), $v, $u, $this->unitrepository->getUnits());
969  }
970 
971  return $points;
972  }
$result
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
+ Here is the call graph for this function:

◆ canUseAdvancedRating()

assFormulaQuestion::canUseAdvancedRating (   $result)

Check if advanced rating can be used for a result.

This is only possible if there is exactly one possible correct unit for the result, otherwise it is impossible to determine wheather the unit is correct or the value.

Returns
boolean True if advanced rating could be used, false otherwise

Definition at line 509 of file class.assFormulaQuestion.php.

References $result, and getResultUnits().

510  {
511  $result_units = $this->getResultUnits($result);
512  $resultunit = $result->getUnit();
513  $similar_units = 0;
514  foreach($result_units as $unit)
515  {
516  if(is_object($resultunit))
517  {
518  if($resultunit->getId() != $unit->getId())
519  {
520  if($resultunit->getBaseUnit() && $unit->getBaseUnit())
521  {
522  if($resultunit->getBaseUnit() == $unit->getBaseUnit()) return false;
523  }
524  if($resultunit->getBaseUnit())
525  {
526  if($resultunit->getBaseUnit() == $unit->getId()) return false;
527  }
528  if($unit->getBaseUnit())
529  {
530  if($unit->getBaseUnit() == $resultunit->getId()) return false;
531  }
532  }
533  }
534  }
535  return true;
536  }
$result
+ Here is the call graph for this function:

◆ checkForDuplicateResults()

assFormulaQuestion::checkForDuplicateResults ( )

Definition at line 183 of file class.assFormulaQuestion.php.

References assQuestion\getQuestion().

184  {
185  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
186  {
187  if((count(array_unique($rmatches[1]))) != count($rmatches[1])) return false;
188  }
189  return true;
190  }
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ checkForDuplicateVariables()

assFormulaQuestion::checkForDuplicateVariables ( )

Definition at line 174 of file class.assFormulaQuestion.php.

References assQuestion\getQuestion().

175  {
176  if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
177  {
178  if((count(array_unique($matches[1]))) != count($matches[1])) return false;
179  }
180  return true;
181  }
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ clearResults()

assFormulaQuestion::clearResults ( )

Definition at line 79 of file class.assFormulaQuestion.php.

Referenced by parseQuestionText().

80  {
81  $this->results = array();
82  }
+ Here is the caller graph for this function:

◆ clearVariables()

assFormulaQuestion::clearVariables ( )

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

Referenced by parseQuestionText().

56  {
57  $this->variables = array();
58  }
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assFormulaQuestion object public.

Definition at line 834 of file class.assFormulaQuestion.php.

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

835  {
836  if ($this->id <= 0)
837  {
838  // The question has not been saved. It cannot be duplicated
839  return;
840  }
841  // duplicate the question in database
842  $clone = $this;
843  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
845  $clone->id = -1;
846  $source_questionpool_id = $this->getObjId();
847  $clone->setObjId($target_questionpool_id);
848  if ($title)
849  {
850  $clone->setTitle($title);
851  }
852  $clone->saveToDb();
853  // copy question page content
854  $clone->copyPageOfQuestion($original_id);
855  // copy XHTML media objects
856  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
857 
858  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
859 
860  return $clone->id;
861  }
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()

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

Definition at line 863 of file class.assFormulaQuestion.php.

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

864  {
865  if ($this->id <= 0)
866  {
867  // The question has not been saved. It cannot be duplicated
868  return;
869  }
870 
871  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
872 
873  $sourceQuestionId = $this->id;
874  $sourceParentId = $this->getObjId();
875 
876  // duplicate the question in database
877  $clone = $this;
878  $clone->id = -1;
879 
880  $clone->setObjId($targetParentId);
881 
882  if ($targetQuestionTitle)
883  {
884  $clone->setTitle($targetQuestionTitle);
885  }
886 
887  $clone->saveToDb();
888  // copy question page content
889  $clone->copyPageOfQuestion($sourceQuestionId);
890  // copy XHTML media objects
891  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
892 
893  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
894 
895  return $clone->id;
896  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteAnswers()

assFormulaQuestion::deleteAnswers (   $question_id)

Deletes datasets from answers tables.

Parameters
integer$question_idThe question id which should be deleted in the answers table public

Definition at line 1123 of file class.assFormulaQuestion.php.

1124  {
1125  global $ilDB;
1126 
1127  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_var WHERE question_fi = %s",
1128  array('integer'),
1129  array($question_id)
1130  );
1131 
1132  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
1133  array('integer'),
1134  array($question_id)
1135  );
1136 
1137  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
1138  array('integer'),
1139  array($question_id)
1140  );
1141  }

◆ duplicate()

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

Duplicates an assFormulaQuestion public.

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

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

778  {
779  if ($this->id <= 0)
780  {
781  // The question has not been saved. It cannot be duplicated
782  return;
783  }
784  // duplicate the question in database
785  $this_id = $this->getId();
786  $thisObjId = $this->getObjId();
787 
788  $clone = $this;
789  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
791  $clone->id = -1;
792 
793  if( (int)$testObjId > 0 )
794  {
795  $clone->setObjId($testObjId);
796  }
797 
798  if ($title)
799  {
800  $clone->setTitle($title);
801  }
802 
803  if ($author)
804  {
805  $clone->setAuthor($author);
806  }
807  if ($owner)
808  {
809  $clone->setOwner($owner);
810  }
811 
812  if ($for_test)
813  {
814  $clone->saveToDb($original_id);
815  }
816  else
817  {
818  $clone->saveToDb();
819  }
820 
821  // copy question page content
822  $clone->copyPageOfQuestion($this_id);
823  // copy XHTML media objects
824  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
825  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
826 
827  return $clone->id;
828  }
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:

◆ getAdditionalTableName()

assFormulaQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name

Definition at line 1104 of file class.assFormulaQuestion.php.

1105  {
1106  return "";
1107  }

◆ getAnswerTableName()

assFormulaQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Definition at line 1113 of file class.assFormulaQuestion.php.

1114  {
1115  return "";
1116  }

◆ getBestSolution()

assFormulaQuestion::getBestSolution (   $active_id,
  $pass 
)

Returns the best solution for a given pass of a participant.

Returns
array An associated array containing the best solution public

Definition at line 1204 of file class.assFormulaQuestion.php.

References $pass, $result, ilMath\_div(), assFormulaQuestionResult\convertDecimalToCoprimeFraction(), getResults(), assQuestion\getSolutionValues(), getVariable(), getVariables(), assFormulaQuestionUnit\lookupUnitFactor(), assFormulaQuestionResult\RESULT_CO_FRAC, and assFormulaQuestionResult\RESULT_FRAC.

1205  {
1206  $user_solution = array();
1207  $user_solution["active_id"] = $active_id;
1208  $user_solution["pass"] = $pass;
1209  $solutions =& $this->getSolutionValues($active_id, $pass);
1210 
1211  foreach($solutions as $idx => $solution_value)
1212  {
1213  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1214  {
1215  $user_solution[$matches[1]] = $solution_value["value2"];
1216  $varObj = $this->getVariable($matches[1]);
1217  $varObj->setValue($solution_value["value2"]);
1218  }
1219  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1220  {
1221  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1222  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1223  }
1224  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1225  {
1226  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1227  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1228  }
1229  }
1230  foreach($this->getResults() as $result)
1231  {
1232  $resVal = $result->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), false);
1233 
1234  if(is_object($result->getUnit()))
1235  {
1236  $user_solution[$result->getResult()]["unit"] = $result->getUnit()->getId();
1237  $user_solution[$result->getResult()]["value"] = $resVal;
1238  }
1239  else if($result->getUnit() == NULL)
1240  {
1241  $unit_factor = 1;
1242  // there is no fix result_unit, any "available unit" is accepted
1243 
1244  $available_units = $result->getAvailableResultUnits(parent::getId());
1245  $result_name = $result->getResult();
1246 
1247  if($available_units[$result_name] != NULL)
1248  {
1249  $check_unit = in_array($user_solution[$result_name]['unit'], $available_units[$result_name]);
1250  }
1251 
1252  if($check_unit == true)
1253  {
1254  //get unit-factor
1255  $unit_factor = assFormulaQuestionUnit::lookupUnitFactor($user_solution[$result_name]['unit']);
1256  $user_solution[$result->getResult()]["value"] = round(ilMath::_div($resVal, $unit_factor), 55);
1257  }
1258  }
1259  if($result->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
1260  || $result->getResultType() == assFormulaQuestionResult::RESULT_FRAC)
1261  {
1263  if(is_array($value))
1264  {
1265  $user_solution[$result->getResult()]["value"] = $value[0];
1266  $user_solution[$result->getResult()]["frac_helper"] = $value[1];
1267  }
1268  else
1269  {
1270  $user_solution[$result->getResult()]["value"] = $value;
1271  $user_solution[$result->getResult()]["frac_helper"] = null;
1272  }
1273  }
1274  else
1275  {
1276  if($result->getPrecision() > 0)
1277  {
1278  $user_solution[$result->getResult()]["value"] = round($resVal, $result->getPrecision());
1279  }
1280  }
1281  }
1282  return $user_solution;
1283  }
$result
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
static _div($left_operand, $right_operand, $scale=50)
static convertDecimalToCoprimeFraction($decimal_value, $tolerance=1.e-9)
+ Here is the call graph for this function:

◆ getMaximumPoints()

assFormulaQuestion::getMaximumPoints ( )

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

See also
$points

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

References assQuestion\$points, and $result.

Referenced by isComplete().

903  {
904  $points = 0;
905  foreach($this->results as $result)
906  {
907  $points += $result->getPoints();
908  }
909  return $points;
910  }
$result
+ Here is the caller graph for this function:

◆ getQuestionType()

assFormulaQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Definition at line 1095 of file class.assFormulaQuestion.php.

1096  {
1097  return "assFormulaQuestion";
1098  }

◆ getResult()

assFormulaQuestion::getResult (   $result)

Definition at line 89 of file class.assFormulaQuestion.php.

References $result.

Referenced by loadFromDb(), and substituteVariables().

90  {
91  if(array_key_exists($result, $this->results))
92  {
93  return $this->results[$result];
94  }
95  return null;
96  }
$result
+ Here is the caller graph for this function:

◆ getResults()

assFormulaQuestion::getResults ( )

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

References $results.

Referenced by calculateReachedPoints(), getBestSolution(), and substituteVariables().

85  {
86  return $this->results;
87  }
+ Here is the caller graph for this function:

◆ getResultUnits()

assFormulaQuestion::getResultUnits (   $result)

Definition at line 126 of file class.assFormulaQuestion.php.

References $result, and $resultunits.

Referenced by canUseAdvancedRating(), saveToDb(), and substituteVariables().

127  {
128  if(array_key_exists($result->getResult(), $this->resultunits))
129  {
130  return $this->resultunits[$result->getResult()];
131  }
132  else
133  {
134  return array();
135  }
136  }
$result
+ Here is the caller graph for this function:

◆ getRTETextWithMediaObjects()

assFormulaQuestion::getRTETextWithMediaObjects ( )

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

Definition at line 1147 of file class.assFormulaQuestion.php.

1148  {
1149  $text = parent::getRTETextWithMediaObjects();
1150  return $text;
1151  }

◆ getUnitrepository()

assFormulaQuestion::getUnitrepository ( )
Returns

Definition at line 1318 of file class.assFormulaQuestion.php.

References $unitrepository.

Referenced by addResultUnits(), loadFromDb(), setExportDetailsXLS(), and substituteVariables().

1319  {
1320  return $this->unitrepository;
1321  }
+ Here is the caller graph for this function:

◆ getVariable()

assFormulaQuestion::getVariable (   $variable)

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

Referenced by calculateReachedPoints(), getBestSolution(), setExportDetailsXLS(), and substituteVariables().

66  {
67  if(array_key_exists($variable, $this->variables))
68  {
69  return $this->variables[$variable];
70  }
71  return null;
72  }
+ Here is the caller graph for this function:

◆ getVariables()

assFormulaQuestion::getVariables ( )

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

References $variables.

Referenced by calculateReachedPoints(), getBestSolution(), and substituteVariables().

61  {
62  return $this->variables;
63  }
+ Here is the caller graph for this function:

◆ hasResultUnit()

assFormulaQuestion::hasResultUnit (   $result,
  $unit_id 
)

Definition at line 138 of file class.assFormulaQuestion.php.

References $result, and $resultunits.

139  {
140  if(array_key_exists($result->getResult(), $this->resultunits))
141  {
142  if(array_key_exists($unit_id, $this->resultunits[$result->getResult()]))
143  {
144  return TRUE;
145  }
146  }
147 
148  return FALSE;
149  }
$result

◆ isComplete()

assFormulaQuestion::isComplete ( )

Returns true, if the question is complete for use.

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

Definition at line 542 of file class.assFormulaQuestion.php.

References getMaximumPoints().

543  {
544  if(($this->title) and ($this->author) and ($this->question) and ($this->getMaximumPoints() > 0))
545  {
546  return true;
547  }
548  else
549  {
550  return false;
551  }
552  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ loadFromDb()

assFormulaQuestion::loadFromDb (   $question_id)

Loads a assFormulaQuestion object from a database.

Parameters
integer$question_idA unique key which defines the question in the database

Definition at line 689 of file class.assFormulaQuestion.php.

References $data, $result, ilRTE\_replaceMediaObjectImageSrc(), addResult(), addResultUnit(), addVariable(), ilDB\fetchAssoc(), getResult(), getUnitrepository(), assQuestion\setAdditionalContentEditingMode(), assQuestion\setAuthor(), assQuestion\setComment(), assQuestion\setEstimatedWorkingTime(), setId(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setQuestion(), assQuestion\setSuggestedSolution(), and assQuestion\setTitle().

690  {
691  global $ilDB;
692 
693  $result = $ilDB->queryF("SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s",
694  array('integer'),
695  array($question_id)
696  );
697  if($result->numRows() == 1)
698  {
699  $data = $ilDB->fetchAssoc($result);
700  $this->setId($question_id);
701  $this->setTitle($data["title"]);
702  $this->setComment($data["description"]);
703  $this->setSuggestedSolution($data["solution_hint"]);
704  $this->setOriginalId($data["original_id"]);
705  $this->setObjId($data["obj_fi"]);
706  $this->setAuthor($data["author"]);
707  $this->setOwner($data["owner"]);
708 
709  try
710  {
711  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
712  }
714  {
715  }
716 
717  $this->unitrepository = new ilUnitConfigurationRepository($question_id);
718 
719  include_once("./Services/RTE/classes/class.ilRTE.php");
720  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
721  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
722 
723  // load variables
724  $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s",
725  array('integer'),
726  array($question_id)
727  );
728  if($result->numRows() > 0)
729  {
730  while($data = $ilDB->fetchAssoc($result))
731  {
732  $varObj = new assFormulaQuestionVariable($data["variable"], $data["range_min"], $data["range_max"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["varprecision"], $data["intprecision"]);
733  $varObj->setRangeMinTxt($data['range_min_txt']);
734  $varObj->setRangeMaxTxt($data['range_max_txt']);
735  $this->addVariable($varObj);
736  }
737  }
738  // load results
739  $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s",
740  array('integer'),
741  array($question_id)
742  );
743  if($result->numRows() > 0)
744  {
745  while($data = $ilDB->fetchAssoc($result))
746  {
747  $resObj = new assFormulaQuestionResult($data["result"], $data["range_min"], $data["range_max"], $data["tolerance"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["formula"], $data["points"], $data["resprecision"], $data["rating_simple"], $data["rating_sign"], $data["rating_value"], $data["rating_unit"]);
748  $resObj->setResultType($data['result_type']);
749  $resObj->setRangeMinTxt($data['range_min_txt']);
750  $resObj->setRangeMaxTxt($data['range_max_txt']);
751  $this->addResult($resObj);
752  }
753  }
754 
755  // load result units
756  $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
757  array('integer'),
758  array($question_id)
759  );
760  if($result->numRows() > 0)
761  {
762  while($data = $ilDB->fetchAssoc($result))
763  {
764  $unit = $this->getUnitrepository()->getUnit($data["unit_fi"]);
765  $resObj = $this->getResult($data["result"]);
766  $this->addResultUnit($resObj, $unit);
767  }
768  }
769  }
770  parent::loadFromDb($question_id);
771  }
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
$result
Class ilUnitConfigurationRepository.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question.
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.
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
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.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
+ Here is the call graph for this function:

◆ parseQuestionText()

assFormulaQuestion::parseQuestionText ( )

Definition at line 151 of file class.assFormulaQuestion.php.

References $result, addResult(), addVariable(), clearResults(), clearVariables(), and assQuestion\getQuestion().

152  {
153  $this->clearResults();
154  $this->clearVariables();
155  if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
156  {
157  foreach($matches[1] as $variable)
158  {
159  $varObj = new assFormulaQuestionVariable($variable, 0, 0, null, 0);
160  $this->addVariable($varObj);
161  }
162  }
163 
164  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
165  {
166  foreach($rmatches[1] as $result)
167  {
168  $resObj = new assFormulaQuestionResult($result, NULL, NULL, 0, -1, NULL, 1, 1, TRUE);
169  $this->addResult($resObj);
170  }
171  }
172  }
$result
getQuestion()
Gets the question string of the question object.
+ Here is the call graph for this function:

◆ reworkWorkingData()

assFormulaQuestion::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 1086 of file class.assFormulaQuestion.php.

1087  {
1088  // nothing to do
1089  }

◆ saveToDb()

assFormulaQuestion::saveToDb (   $original_id = "")

Saves a assFormulaQuestion object to a database public.

Definition at line 558 of file class.assFormulaQuestion.php.

References assQuestion\$original_id, $res, $result, $row, assQuestion\getId(), getResultUnits(), and assQuestion\saveQuestionDataToDb().

559  {
560  global $ilDB;
561 
563  // save variables
564  $affectedRows = $ilDB->manipulateF("
565  DELETE FROM il_qpl_qst_fq_var
566  WHERE question_fi = %s",
567  array("integer"),
568  array($this->getId())
569  );
570 
571  $source_qst_id = $original_id;
572  $target_qst_id = $this->getId();
573 
574  foreach($this->variables as $variable)
575  {
576  $next_id = $ilDB->nextId('il_qpl_qst_fq_var');
577  $ilDB->insert('il_qpl_qst_fq_var',
578  array(
579  'variable_id' => array('integer', $next_id),
580  'question_fi' => array('integer', $this->getId()),
581  'variable' => array('text', $variable->getVariable()),
582  'range_min' => array('float', ((strlen($variable->getRangeMin())) ? $variable->getRangeMin() : 0.0)),
583  'range_max' => array('float', ((strlen($variable->getRangeMax())) ? $variable->getRangeMax() : 0.0)),
584  'unit_fi' => array('integer', (is_object($variable->getUnit()) ? (int)$variable->getUnit()->getId() : 0)),
585  'varprecision' => array('integer', (int)$variable->getPrecision()),
586  'intprecision' => array('integer', (int)$variable->getIntprecision()),
587  'range_min_txt' => array('text', $variable->getRangeMinTxt()),
588  'range_max_txt' => array('text', $variable->getRangeMaxTxt())
589  ));
590 
591  }
592  // save results
593  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
594  array("integer"),
595  array($this->getId())
596  );
597 
598  foreach($this->results as $result)
599  {
600  $next_id = $ilDB->nextId('il_qpl_qst_fq_res');
601  if( is_object($result->getUnit()))
602  {
603  $tmp_result_unit = $result->getUnit()->getId();
604  }
605  else
606  {
607  $tmp_result_unit = NULL;
608  }
609 
610  $formula = str_replace(",", ".", $result->getFormula());
611 
612  $ilDB->insert("il_qpl_qst_fq_res", array(
613  "result_id" => array("integer", $next_id),
614  "question_fi" => array("integer", $this->getId()),
615  "result" => array("text", $result->getResult()),
616  "range_min" => array("float", ((strlen($result->getRangeMin())) ? $result->getRangeMin() : 0)),
617  "range_max" => array("float", ((strlen($result->getRangeMax())) ? $result->getRangeMax() : 0)),
618  "tolerance" => array("float", ((strlen($result->getTolerance())) ? $result->getTolerance() : 0)),
619  "unit_fi" => array("integer", (int)$tmp_result_unit),
620  "formula" => array("clob", $formula),
621  "resprecision" => array("integer", $result->getPrecision()),
622  "rating_simple" => array("integer", ($result->getRatingSimple()) ? 1 : 0),
623  "rating_sign" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingSign()),
624  "rating_value" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingValue()),
625  "rating_unit" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingUnit()),
626  "points" => array("float", $result->getPoints()),
627  "result_type" => array('integer', (int)$result->getResultType()),
628  "range_min_txt" => array("text", $result->getRangeMinTxt()),
629  "range_max_txt" => array("text", $result->getRangeMaxTxt())
630 
631  ));
632  }
633  // save result units
634  $affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
635  array("integer"),
636  array($this->getId())
637  );
638  foreach($this->results as $result)
639  {
640  foreach($this->getResultUnits($result) as $unit)
641  {
642  $next_id = $ilDB->nextId('il_qpl_qst_fq_res_unit');
643  $affectedRows = $ilDB->manipulateF("INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)",
644  array('integer', 'integer', 'text', 'integer'),
645  array(
646  $next_id,
647  $this->getId(),
648  $result->getResult(),
649  $unit->getId()
650  )
651  );
652  }
653  }
654 
655 
656  // copy category/unit-process:
657  // if $source_qst_id = '' -> nothing to copy because this is a new question
658  // if $source_qst_id == $target_qst_id -> nothing to copy because this is just an update-process
659  // if $source_qst_id != $target_qst_id -> copy categories and untis because this is a copy-process
660  // @todo: Nadia wtf?
661  if($source_qst_id != $target_qst_id && $source_qst_id > 0)
662  {
663  $res = $ilDB->queryF('
664  SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi = %s',
665  array('integer'), array($source_qst_id));
666 
667  $cp_cats = array();
668  while($row = $ilDB->fetchAssoc($res))
669  {
670  $cp_cats[] = $row['category_id'];
671  }
672 
673  foreach($cp_cats as $old_category_id)
674  {
675  // copy admin-categorie to custom-category (with question_fi)
676  $new_cat_id = $this->unitrepository->copyCategory($old_category_id, $target_qst_id);
677 
678  // copy units to custom_category
679  $this->unitrepository->copyUnitsByCategories($old_category_id, $new_cat_id, $target_qst_id);
680  }
681  }
682  parent::saveToDb();
683  }
getId()
Gets the id of the assQuestion object.
$result
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

Parameters
integer$test_idThe database id of the test containing this question
Returns
boolean Indicates the save status (true if saved successful, false otherwise) public
See also
$answers

Definition at line 981 of file class.assFormulaQuestion.php.

References $_POST, $pass, $result, $row, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), assQuestion\getId(), assQuestion\getProcessLocker(), and assQuestion\logAction().

982  {
983  global $ilDB;
984 
985  if(is_null($pass))
986  {
987  include_once "./Modules/Test/classes/class.ilObjTest.php";
988  $pass = ilObjTest::_getPass($active_id);
989  }
990 
991  $this->getProcessLocker()->requestUserSolutionUpdateLock();
992 
993  $entered_values = FALSE;
994  foreach($_POST as $key => $value)
995  {
996  if(preg_match("/^result_(\\\$r\\d+)$/", $key, $matches))
997  {
998  if(strlen($value)) $entered_values = TRUE;
999  $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND " . $ilDB->like('value1', 'clob', $matches[1]),
1000  array('integer', 'integer', 'integer'),
1001  array($active_id, $pass, $this->getId())
1002  );
1003  if($result->numRows())
1004  {
1005  while($row = $ilDB->fetchAssoc($result))
1006  {
1007  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s",
1008  array('integer'),
1009  array($row['solution_id'])
1010  );
1011  }
1012  }
1013 
1014  $next_id = $ilDB->nextId('tst_solutions');
1015  $affectedRows = $ilDB->insert("tst_solutions", array(
1016  "solution_id" => array("integer", $next_id),
1017  "active_fi" => array("integer", $active_id),
1018  "question_fi" => array("integer", $this->getId()),
1019  "value1" => array("clob", $matches[1]),
1020  "value2" => array("clob", str_replace(",", ".", $value)),
1021  "pass" => array("integer", $pass),
1022  "tstamp" => array("integer", time())
1023  ));
1024  }
1025  else if(preg_match("/^result_(\\\$r\\d+)_unit$/", $key, $matches))
1026  {
1027  $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND " . $ilDB->like('value1', 'clob', $matches[1] . "_unit"),
1028  array('integer', 'integer', 'integer'),
1029  array($active_id, $pass, $this->getId())
1030  );
1031  if($result->numRows())
1032  {
1033  while($row = $ilDB->fetchAssoc($result))
1034  {
1035  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s",
1036  array('integer'),
1037  array($row['solution_id'])
1038  );
1039  }
1040  }
1041 
1042  $next_id = $ilDB->nextId('tst_solutions');
1043  $affectedRows = $ilDB->insert("tst_solutions", array(
1044  "solution_id" => array("integer", $next_id),
1045  "active_fi" => array("integer", $active_id),
1046  "question_fi" => array("integer", $this->getId()),
1047  "value1" => array("clob", $matches[1] . "_unit"),
1048  "value2" => array("clob", $value),
1049  "pass" => array("integer", $pass),
1050  "tstamp" => array("integer", time())
1051  ));
1052  }
1053  }
1054 
1055  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
1056 
1057  if($entered_values)
1058  {
1059  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1061  {
1062  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1063  }
1064  }
1065  else
1066  {
1067  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
1069  {
1070  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
1071  }
1072  }
1073 
1074  return true;
1075  }
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
$result
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
_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:

◆ setExportDetailsXLS()

assFormulaQuestion::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
array$eval_dataCumulated evaluation data public

Definition at line 1164 of file class.assFormulaQuestion.php.

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

1165  {
1166  require_once 'Services/Excel/classes/class.ilExcelUtils.php';
1167  $solution = $this->getSolutionValues($active_id, $pass);
1168  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
1169  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
1170  $i = 1;
1171  foreach($solution as $solutionvalue)
1172  {
1173  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($solutionvalue["value1"]), $format_bold);
1174  if(strpos($solutionvalue["value1"], "_unit"))
1175  {
1176  $unit = $this->getUnitrepository()->getUnit($solutionvalue["value2"]);
1177  if(is_object($unit))
1178  {
1179  $worksheet->write($startrow + $i, 1, $unit->getUnit());
1180  }
1181  }
1182  else
1183  {
1184  $worksheet->write($startrow + $i, 1, $solutionvalue["value2"]);
1185  }
1186  if(preg_match("/(\\\$v\\d+)/", $solutionvalue["value1"], $matches))
1187  {
1188  $var = $this->getVariable($solutionvalue["value1"]);
1189  if(is_object($var) && (is_object($var->getUnit())))
1190  {
1191  $worksheet->write($startrow + $i, 2, $var->getUnit()->getUnit());
1192  }
1193  }
1194  $i++;
1195  }
1196  return $startrow + $i + 1;
1197  }
& 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:

◆ setId()

assFormulaQuestion::setId (   $id = -1)

Definition at line 1285 of file class.assFormulaQuestion.php.

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

Referenced by loadFromDb().

1286  {
1287  parent::setId($id);
1288  $this->unitrepository->setConsumerId($this->getId());
1289  }
getId()
Gets the id of the assQuestion object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUnitrepository()

assFormulaQuestion::setUnitrepository (   $unitrepository)
Parameters
\ilUnitConfigurationRepository$unitrepository

Definition at line 1310 of file class.assFormulaQuestion.php.

References $unitrepository.

1311  {
1312  $this->unitrepository = $unitrepository;
1313  }

◆ substituteVariables()

assFormulaQuestion::substituteVariables (   $userdata = null,
  $graphicalOutput = FALSE,
  $forsolution = FALSE,
  $result_output = FALSE 
)

Definition at line 192 of file class.assFormulaQuestion.php.

References $result, assFormulaQuestionResult\convertDecimalToCoprimeFraction(), assQuestion\getId(), ilUtil\getImagePath(), assQuestion\getQuestion(), getResult(), getResults(), getResultUnits(), getUnitrepository(), getVariable(), getVariables(), ilUtil\prepareFormOutput(), assFormulaQuestionResult\RESULT_CO_FRAC, assFormulaQuestionResult\RESULT_DEC, assFormulaQuestionResult\RESULT_FRAC, and assFormulaQuestionResult\RESULT_NO_SELECTION.

193  {
194  global $ilDB;
195 
196  if((count($this->results) == 0) && (count($this->variables) == 0))
197  return false;
198 
199  $text = $this->getQuestion();
200  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
201  {
202  foreach($rmatches[1] as $result)
203  {
204  $resObj = $this->getResult($result);
205  $resObj->findValidRandomVariables($this->getVariables(), $this->getResults());
206  }
207  }
208  if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
209  {
210  foreach($matches[1] as $variable)
211  {
212  $varObj = $this->getVariable($variable);
213  if(is_array($userdata))
214  {
215  if(strlen($userdata[$varObj->getVariable()]))
216  {
217  $value = $userdata[$varObj->getVariable()];
218  $varObj->setValue($value);
219  }
220  else
221  {
222  // save value to db
223  $next_id = $ilDB->nextId('tst_solutions');
224  $affectedRows = $ilDB->insert("tst_solutions", array(
225  "solution_id" => array("integer", $next_id),
226  "active_fi" => array("integer", $userdata["active_id"]),
227  "question_fi" => array("integer", $this->getId()),
228  "value1" => array("clob", $variable),
229  "value2" => array("clob", $varObj->getValue()),
230  "points" => array("float", 0),
231  "pass" => array("integer", $userdata["pass"]),
232  "tstamp" => array("integer", time())
233  ));
234  }
235  }
236  $unit = (is_object($varObj->getUnit())) ? $varObj->getUnit()->getUnit() : "";
237  $val = (strlen($varObj->getValue()) > 8) ? strtoupper(sprintf("%e", $varObj->getValue())) : $varObj->getValue();
238  $text = preg_replace("/\\$" . substr($variable, 1) . "(?![0-9]+)/", $val . " " . $unit . "\\1", $text);
239  }
240  }
241  if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
242  {
243  foreach($rmatches[1] as $result)
244  {
245  $resObj = $this->getResult($result);
246  $value = "";
247  $frac_helper = '';
248  $user_data[$result]['result_type'] = $resObj->getResultType();
249 
250  if(
251  $resObj->getResultType() == assFormulaQuestionResult::RESULT_FRAC ||
252  $resObj->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
253  )
254  {
255  $is_frac = true;
256  }
257  if(is_array($userdata))
258  {
259  if(is_array($userdata[$result]))
260  {
261  if($forsolution && $result_output)
262  {
263  $value_org = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId());
264  $value = sprintf("%." . $resObj->getPrecision() . "f", $value_org);
265  if($is_frac)
266  {
268  if(is_array($value))
269  {
270  $frac_helper = $value[1];
271  $value = $value[0];
272  }
273  }
274  }
275  else
276  {
277  if($forsolution)
278  {
279  $value = $userdata[$result]["value"];
280  }
281  else
282  {
283  $value = ' value="' . $userdata[$result]["value"] . '"';
284  }
285  }
286  }
287  }
288  else
289  {
290  if($forsolution)
291  {
292  $value = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId());
293  $value = sprintf("%." . $resObj->getPrecision() . "f", $value);
294 
295  if($is_frac)
296  {
298  if(is_array($value))
299  {
300  $frac_helper = $value[1];
301  $value = $value[0];
302  }
303  $value = ' value="' . $value . '"';
304  }
305  }
306  else
307  {
308  // Precision fix for Preview by tjoussen
309  // If all default values are set, this function is called in getPreview
310  $use_precision = !($userdata == null && $graphicalOutput == FALSE && $forsolution == FALSE && $result_output == FALSE);
311 
312  $val = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), $use_precision);
313 
314  if($resObj->getResultType() == assFormulaQuestionResult::RESULT_FRAC
315  ||$resObj->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC)
316  {
317  $val = $resObj->convertDecimalToCoprimeFraction($val);
318  if(is_array($val))
319  {
320  $frac_helper = $val[1];
321  $val = $val[0];
322  }
323  }
324  else
325  {
326  $val = sprintf("%." . $resObj->getPrecision() . "f", $val);
327  $val = (strlen($val) > 8) ? strtoupper(sprintf("%e", $val)) : $val;
328  }
329  $value = ' value="' . $val . '"';
330  }
331  }
332 
333  if($forsolution)
334  {
335  $input = '<span class="solutionbox">' . ilUtil::prepareFormOutput($value) . '</span>';
336  }
337  else
338  {
339  $input = '<input type="text" name="result_' . $result . '"' . $value . ' />';
340  }
341 
342  $units = "";
343  if(count($this->getResultUnits($resObj)) > 0)
344  {
345  if($forsolution)
346  {
347  if(is_array($userdata))
348  {
349  foreach($this->getResultUnits($resObj) as $unit)
350  {
351  if($userdata[$result]["unit"] == $unit->getId())
352  {
353  $units = $unit->getUnit();
354  }
355  }
356  }
357  else
358  {
359  if($resObj->getUnit())
360  {
361  $units = $resObj->getUnit()->getUnit();
362  }
363  }
364  }
365  else
366  {
367  $units = '<select name="result_' . $result . '_unit">';
368  $units .= '<option value="-1">' . $this->lng->txt("select_unit") . '</option>';
369  foreach($this->getResultUnits($resObj) as $unit)
370  {
371  $units .= '<option value="' . $unit->getId() . '"';
372  if((is_array($userdata[$result])) && (strlen($userdata[$result]["unit"])))
373  {
374  if($userdata[$result]["unit"] == $unit->getId())
375  {
376  $units .= ' selected="selected"';
377  }
378  }
379  $units .= '>' . $unit->getUnit() . '</option>';
380  }
381  $units .= '</select>';
382  }
383  }
384  else
385  {
386  $units = "";
387  }
388  switch($resObj->getResultType())
389  {
391  $units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_dec');
392  break;
394  if(strlen($frac_helper))
395  {
396  $units .= ' &asymp; ' . $frac_helper . ', ';
397  }
398  elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result]["frac_helper"]))
399  {
400  if(!preg_match('-/-', $value))
401  {
402  $units .= ' &asymp; ' . $userdata[$result]["frac_helper"] . ', ';
403  }
404  }
405  $units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_frac');
406  break;
408  if(strlen($frac_helper))
409  {
410  $units .= ' &asymp; ' . $frac_helper . ', ';
411  }
412  elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result]["frac_helper"]))
413  {
414  if(!preg_match('-/-', $value))
415  {
416  $units .= ' &asymp; ' . $userdata[$result]["frac_helper"] . ', ';
417  }
418  }
419  $units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_co_frac');
420  break;
422  break;
423  }
424  $checkSign = "";
425  if($graphicalOutput)
426  {
427  $resunit = null;
428  $user_value = '';
429  if(is_array($userdata) && is_array($userdata[$result]))
430  {
431  if($userdata[$result]["unit"] > 0)
432  {
433  $resunit = $this->getUnitrepository()->getUnit($userdata[$result]["unit"]);
434  }
435 
436  if(isset($userdata[$result]["value"]))
437  {
438  $user_value = $userdata[$result]["value"];
439  }
440  }
441 
442  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution_image.html", true, true, 'Modules/TestQuestionPool');
443 
444  if($resObj->isCorrect($this->getVariables(), $this->getResults(), $user_value, $resunit))
445  {
446  $template->setCurrentBlock("icon_ok");
447  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png"));
448  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
449  $template->parseCurrentBlock();
450  }
451  else
452  {
453  $template->setCurrentBlock("icon_not_ok");
454  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png"));
455  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
456  $template->parseCurrentBlock();
457  }
458  $checkSign = $template->get();
459  }
460  $resultOutput = "";
461  if($result_output)
462  {
463  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution_result.html", true, true, 'Modules/TestQuestionPool');
464 
465  if(is_array($userdata))
466  {
467  $found = $resObj->getResultInfo($this->getVariables(), $this->getResults(), $userdata[$resObj->getResult()]["value"], $userdata[$resObj->getResult()]["unit"], $this->getUnitrepository()->getUnits());
468  }
469  else
470  {
471  $found = $resObj->getResultInfo($this->getVariables(), $this->getResults(), $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId()), is_object($resObj->getUnit()) ? $resObj->getUnit()->getId() : NULL, $this->getUnitrepository()->getUnits());
472  }
473  $resulttext = "(";
474  if($resObj->getRatingSimple())
475  {
476  if($frac_helper)
477  {
478  $resulttext .="n/a";
479  }
480  else
481  {
482  $resulttext .= $found['points'] . " " . (($found['points'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points'));
483  }
484  }
485  else
486  {
487  $resulttext .= $this->lng->txt("rated_sign") . " " . (($found['sign']) ? $found['sign'] : 0) . " " . (($found['sign'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points')) . ", ";
488  $resulttext .= $this->lng->txt("rated_value") . " " . (($found['value']) ? $found['value'] : 0) . " " . (($found['value'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points')) . ", ";
489  $resulttext .= $this->lng->txt("rated_unit") . " " . (($found['unit']) ? $found['unit'] : 0) . " " . (($found['unit'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points'));
490  }
491 
492  $resulttext .= ")";
493  $template->setVariable("RESULT_OUTPUT", $resulttext);
494 
495  $resultOutput = $template->get();
496  }
497  $text = preg_replace("/\\\$" . substr($result, 1) . "(?![0-9]+)/", $input . " " . $units . " " . $checkSign . " " . $resultOutput . " " . "\\1", $text);
498  }
499  }
500  return $text;
501  }
getId()
Gets the id of the assQuestion object.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$result
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
getQuestion()
Gets the question string of the question object.
static convertDecimalToCoprimeFraction($decimal_value, $tolerance=1.e-9)
+ Here is the call graph for this function:

Field Documentation

◆ $results

assFormulaQuestion::$results
private

Definition at line 20 of file class.assFormulaQuestion.php.

Referenced by getResults().

◆ $resultunits

assFormulaQuestion::$resultunits
private

Definition at line 21 of file class.assFormulaQuestion.php.

Referenced by __get(), getResultUnits(), and hasResultUnit().

◆ $unitrepository

assFormulaQuestion::$unitrepository
private

Definition at line 26 of file class.assFormulaQuestion.php.

Referenced by getUnitrepository(), and setUnitrepository().

◆ $variables

assFormulaQuestion::$variables
private

Definition at line 19 of file class.assFormulaQuestion.php.

Referenced by getVariables().


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