ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 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, ilAssQuestionPreviewSession $previewSession=null)
 canUseAdvancedRating ($result)
 Check if advanced rating can be used for a result.
 isComplete ()
 Returns true, if the question is complete for use.
 saveToDb ($original_id="")
 Saves a assFormulaQuestion object to a database public.
 loadFromDb ($question_id)
 Loads a assFormulaQuestion object from a database.
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assFormulaQuestion public.
 copyObject ($target_questionpool_id, $title="")
 Copies an assFormulaQuestion object public.
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 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.
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database.
 getQuestionType ()
 Returns the question type of the question.
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database.
 getAnswerTableName ()
 Returns the name of the answer table in the database.
 deleteAnswers ($question_id)
 Deletes datasets from answers tables.
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor.
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question.
 getBestSolution ($solutions)
 Returns the best solution for a given pass of a participant.
 setId ($id=-1)
 Sets the id of the assQuestion object.
 __get ($value)
 Object getter.
 setUnitrepository ($unitrepository)
 getUnitrepository ()
 getOperators ($expression)
 Get all available operations for a specific question.
 getExpressionTypes ()
 Get all available expression types for a specific question.
 getAvailableAnswerOptions ($index=null)
 If index is null, the function returns an array with all anwser options Else it returns the specific answer option.
- Public Member Functions inherited from assQuestion
 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.
 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.
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database.
 setTitle ($title="")
 Sets the title string of the assQuestion object.
 setTestId ($id=-1)
 Sets the test id of the assQuestion object.
 setComment ($comment="")
 Sets the comment string of the assQuestion object.
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type.
 setShuffle ($shuffle=true)
 Sets the shuffle flag.
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second.
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string.
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array
 setAuthor ($author="")
 Sets the authors name of the assQuestion object.
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object.
 getTitle ()
 Gets the title string of the assQuestion object.
 getId ()
 Gets the id of the assQuestion object.
 getShuffle ()
 Gets the shuffle flag.
 getTestId ()
 Gets the test id of the assQuestion object.
 getComment ()
 Gets the comment string of the assQuestion object.
 getOutputType ()
 Gets the output type.
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output.
 supportsNonJsOutput ()
 requiresJsSwitch ()
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question.
 getAuthor ()
 Gets the authors name of the assQuestion object.
 getOwner ()
 Gets the creator/owner ID of the assQuestion object.
 getObjId ()
 Get the object id of the container object.
 setObjId ($obj_id=0)
 Set the object id of the container object.
 setExternalId ($external_id)
 getExternalId ()
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question.
_getQuestionInfo ($question_id)
 Returns question information from the database.
 getSuggestedSolutionOutput ()
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 getSuggestedSolutions ()
 Return the suggested solutions.
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question.
 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.
 getAdjustedReachedPoints ($active_id, $pass=NULL)
 returns the reached points ...
 calculateResultsFromSolution ($active_id, $pass=NULL, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution.
 persistWorkingState ($active_id, $pass=NULL, $obligationsEnabled=false)
 persists the working state for current testactive and testpass
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place.
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it.
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution.
 getJavaPath ()
 Returns the image path for web accessable images of a question.
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question.
 buildImagePath ($questionId, $parentObjectId)
 getFlashPath ()
 Returns the image path for web accessable flash files of a question.
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question.
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution.
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question.
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question.
getSolutionValues ($active_id, $pass=NULL)
 Loads solutions of a given user from the database an returns it.
 isInUse ($question_id="")
 Checks whether the question is in use or not.
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not.
 pcArrayShuffle ($array)
 Shuffles the values of a given array.
 getQuestionTypeFromDb ($question_id)
 get question type for question id
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database.
 delete ($question_id)
 Deletes a question and all materials from the database.
 getTotalAnswers ()
 get total number of answers
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method
 _getTitle ($a_q_id)
 Returns the title of a question.
 _getQuestionText ($a_q_id)
 Returns question text.
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 syncXHTMLMediaObjectsOfQuestion ()
 createPageObject ()
 create page object of question
 copyPageOfQuestion ($a_q_id)
 getPageOfQuestion ()
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id.
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id.
 setOriginalId ($original_id)
 getOriginalId ()
 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.
 saveQuestionDataToDb ($original_id="")
 setNewOriginalId ($newId)
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database.
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index.
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question.
 _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.
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool.
 getPoints ()
 Returns the maximum available points for the question.
 setPoints ($a_points)
 Sets the maximum available points for the question.
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution.
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution.
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user.
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not.
 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.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests.
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string.
 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.
 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.
 getQuestion ()
 Gets the question string of the question object.
 setQuestion ($question="")
 Sets the question string of the question object.
 getQuestionTypeID ()
 Returns the question type of the question.
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table
getInstances ()
 Gets all instances of the question.
 _needsManualScoring ($question_id)
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id.
 __set ($key, $value)
 Object setter.
 getNrOfTries ()
 setNrOfTries ($a_nr_of_tries)
 setExportImagePath ($a_path)
 _questionExistsInTest ($question_id, $test_id)
 formatSAQuestion ($a_q)
 Format self assessment question.
 setPreventRteUsage ($a_val)
 Set prevent rte usage.
 getPreventRteUsage ()
 Get prevent rte usage.
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode.
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode.
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries.
 getDefaultNrOfTries ()
 Get Default Nr of Tries.
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered or not
 isAutosaveable ()
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 getQuestionChangeListeners ()
 getHtmlUserSolutionPurifier ()
 getHtmlQuestionContentPurifier ()
 setLastChange ($lastChange)
 getLastChange ()
 setStep ($step)
 getStep ()
 toJSON ()
- Public Member Functions inherited from iQuestionCondition
 getUserQuestionResult ($active_id, $pass)
 Get the user solution for a question by active_id and the test pass.

Protected Member Functions

 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary.
 getSolutionSubmit ()
- Protected Member Functions inherited from assQuestion
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID.
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test)
 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)
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated.
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced.
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 buildQuestionDataQuery ()

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.
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution.
static _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method
static _getOriginalId ($question_id)
 Returns the original id of a question.
static originalQuestionExists ($questionId)
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
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.
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not.
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type.
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.
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id.
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id.
static lookupParentObjId ($questionId)
 ilDB $ilDB
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)
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration
static setResultGateway ($resultGateway)
static getResultGateway ()
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default"
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject"
 $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 = "?"
- 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
- 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

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

Constructor & Destructor Documentation

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()

Reimplemented from assQuestion.

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

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

{
$this->variables = array();
$this->results = array();
$this->resultunits = array();
$this->unitrepository = new ilUnitConfigurationRepository(0);
}

Member Function Documentation

assFormulaQuestion::__get (   $value)

Object getter.

Reimplemented from assQuestion.

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

References $resultunits.

{
switch($value)
{
case "resultunits":
break;
default:
return parent::__get($value);
break;
}
}
assFormulaQuestion::addResult (   $result)

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

References $result.

Referenced by loadFromDb(), and parseQuestionText().

{
$this->results[$result->getResult()] = $result;
}

+ Here is the caller graph for this function:

assFormulaQuestion::addResultUnit (   $result,
  $unit 
)

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

References $result.

Referenced by loadFromDb().

{
if(is_object($result) && is_object($unit))
{
if(!is_array($this->resultunits[$result->getResult()]))
{
$this->resultunits[$result->getResult()] = array();
}
$this->resultunits[$result->getResult()][$unit->getId()] = $unit;
}
}

+ Here is the caller graph for this function:

assFormulaQuestion::addResultUnits (   $result,
  $unit_ids 
)

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

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

{
$this->resultunits[$result->getResult()] = array();
if((!is_object($result)) || (!is_array($unit_ids))) return;
foreach($unit_ids as $id)
{
if(is_numeric($id) && ($id > 0)) $this->resultunits[$result->getResult()][$id] = $this->getUnitrepository()->getUnit($id);
}
}

+ Here is the call graph for this function:

assFormulaQuestion::addVariable (   $variable)

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

Referenced by loadFromDb(), and parseQuestionText().

{
$this->variables[$variable->getVariable()] = $variable;
}

+ Here is the caller graph for this function:

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

Reimplemented from assQuestion.

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

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

{
if(is_null($pass))
{
$pass = $this->getSolutionMaxPass($active_id);
}
$solutions =& $this->getSolutionValues($active_id, $pass);
$user_solution = array();
foreach($solutions as $idx => $solution_value)
{
if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
{
$user_solution[$matches[1]] = $solution_value["value2"];
$varObj = $this->getVariable($solution_value["value1"]);
$varObj->setValue($solution_value["value2"]);
}
else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["value"] = $solution_value["value2"];
}
else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["unit"] = $solution_value["value2"];
}
}
//vd($this->getResults());
$points = 0;
foreach($this->getResults() as $result)
{
//vd($user_solution[$result->getResult()]["value"]);
$points += $result->getReachedPoints($this->getVariables(), $this->getResults(), $user_solution[$result->getResult()]["value"], $user_solution[$result->getResult()]["unit"], $this->unitrepository->getUnits());
}
return $points;
}

+ Here is the call graph for this function:

assFormulaQuestion::calculateReachedPointsFromPreviewSession ( ilAssQuestionPreviewSession  $previewSession)

Reimplemented from assQuestion.

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

References assQuestion\$points, $result, ilAssQuestionPreviewSession\getParticipantsSolution(), getResults(), and getVariables().

{
$user_solution = $previewSession->getParticipantsSolution();
$points = 0;
foreach($this->getResults() as $result)
{
$v = isset($user_solution[$result->getResult()]) ? $user_solution[$result->getResult()] : null;
$u = isset($user_solution[$result->getResult().'_unit']) ? $user_solution[$result->getResult().'_unit'] : null;
$points += $result->getReachedPoints(
$this->getVariables(),
$this->getResults(),
$v,
$u,
$this->unitrepository->getUnits());
}
return $points;
}

+ Here is the call graph for this function:

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

References $result, and getResultUnits().

{
$result_units = $this->getResultUnits($result);
$resultunit = $result->getUnit();
$similar_units = 0;
foreach($result_units as $unit)
{
if(is_object($resultunit))
{
if($resultunit->getId() != $unit->getId())
{
if($resultunit->getBaseUnit() && $unit->getBaseUnit())
{
if($resultunit->getBaseUnit() == $unit->getBaseUnit()) return false;
}
if($resultunit->getBaseUnit())
{
if($resultunit->getBaseUnit() == $unit->getId()) return false;
}
if($unit->getBaseUnit())
{
if($unit->getBaseUnit() == $resultunit->getId()) return false;
}
}
}
}
return true;
}

+ Here is the call graph for this function:

assFormulaQuestion::checkForDuplicateResults ( )

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

References assQuestion\getQuestion().

{
if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
{
if((count(array_unique($rmatches[1]))) != count($rmatches[1])) return false;
}
return true;
}

+ Here is the call graph for this function:

assFormulaQuestion::checkForDuplicateVariables ( )

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

References assQuestion\getQuestion().

{
if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
{
if((count(array_unique($matches[1]))) != count($matches[1])) return false;
}
return true;
}

+ Here is the call graph for this function:

assFormulaQuestion::clearResults ( )

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

Referenced by parseQuestionText().

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

+ Here is the caller graph for this function:

assFormulaQuestion::clearVariables ( )

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

Referenced by parseQuestionText().

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

+ Here is the caller graph for this function:

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

Copies an assFormulaQuestion object public.

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
$source_questionpool_id = $this->getObjId();
$clone->setObjId($target_questionpool_id);
if ($title)
{
$clone->setTitle($title);
}
$clone->saveToDb();
// copy question page content
$clone->copyPageOfQuestion($original_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($original_id);
$clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
return $clone->id;
}

+ Here is the call graph for this function:

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

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$sourceQuestionId = $this->id;
$sourceParentId = $this->getObjId();
// duplicate the question in database
$clone = $this;
$clone->id = -1;
$clone->setObjId($targetParentId);
if ($targetQuestionTitle)
{
$clone->setTitle($targetQuestionTitle);
}
$clone->saveToDb();
// copy question page content
$clone->copyPageOfQuestion($sourceQuestionId);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
$clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
return $clone->id;
}

+ Here is the call graph for this function:

assFormulaQuestion::deleteAnswers (   $question_id)

Deletes datasets from answers tables.

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

Reimplemented from assQuestion.

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

References $ilDB.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_var WHERE question_fi = %s",
array('integer'),
array($question_id)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
array('integer'),
array($question_id)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
assFormulaQuestion::duplicate (   $for_test = true,
  $title = "",
  $author = "",
  $owner = "",
  $testObjId = null 
)

Duplicates an assFormulaQuestion public.

Reimplemented from assQuestion.

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$this_id = $this->getId();
$thisObjId = $this->getObjId();
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
if( (int)$testObjId > 0 )
{
$clone->setObjId($testObjId);
}
if ($title)
{
$clone->setTitle($title);
}
if ($author)
{
$clone->setAuthor($author);
}
if ($owner)
{
$clone->setOwner($owner);
}
if ($for_test)
{
$clone->saveToDb($original_id);
}
else
{
$clone->saveToDb();
}
// copy question page content
$clone->copyPageOfQuestion($this_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($this_id);
$clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
return $clone->id;
}

+ Here is the call graph for this function:

assFormulaQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name

Reimplemented from assQuestion.

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

{
return "";
}
assFormulaQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Reimplemented from assQuestion.

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

{
return "";
}
assFormulaQuestion::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 1422 of file class.assFormulaQuestion.php.

References getResult(), and getResults().

{
if($index !== null)
{
return $this->getResult('$r'.($index+1));
}
else
{
return $this->getResults();
}
}

+ Here is the call graph for this function:

assFormulaQuestion::getBestSolution (   $solutions)

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

Returns
array An associated array containing the best solution public

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

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

{
$user_solution = array();
foreach($solutions as $idx => $solution_value)
{
if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
{
$user_solution[$matches[1]] = $solution_value["value2"];
$varObj = $this->getVariable($matches[1]);
$varObj->setValue($solution_value["value2"]);
}
else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["value"] = $solution_value["value2"];
}
else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["unit"] = $solution_value["value2"];
}
}
foreach($this->getResults() as $result)
{
$resVal = $result->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), false);
if(is_object($result->getUnit()))
{
$user_solution[$result->getResult()]["unit"] = $result->getUnit()->getId();
$user_solution[$result->getResult()]["value"] = $resVal;
}
else if($result->getUnit() == NULL)
{
$unit_factor = 1;
// there is no fix result_unit, any "available unit" is accepted
$available_units = $result->getAvailableResultUnits(parent::getId());
$result_name = $result->getResult();
if($available_units[$result_name] != NULL)
{
$check_unit = in_array($user_solution[$result_name]['unit'], $available_units[$result_name]);
}
if($check_unit == true)
{
//get unit-factor
$unit_factor = assFormulaQuestionUnit::lookupUnitFactor($user_solution[$result_name]['unit']);
$user_solution[$result->getResult()]["value"] = round(ilMath::_div($resVal, $unit_factor), 55);
}
}
if($result->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
|| $result->getResultType() == assFormulaQuestionResult::RESULT_FRAC)
{
if(is_array($value))
{
$user_solution[$result->getResult()]["value"] = $value[0];
$user_solution[$result->getResult()]["frac_helper"] = $value[1];
}
else
{
$user_solution[$result->getResult()]["value"] = $value;
$user_solution[$result->getResult()]["frac_helper"] = null;
}
}
elseif($result->getPrecision() > 0)
{
$user_solution[$result->getResult()]["value"] = round($resVal, $result->getPrecision());
}
else
{
$user_solution[$result->getResult()]["value"] = round($resVal);
}
}
return $user_solution;
}

+ Here is the call graph for this function:

assFormulaQuestion::getExpressionTypes ( )
assFormulaQuestion::getMaximumPoints ( )

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

See Also
$points

Reimplemented from assQuestion.

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

References assQuestion\$points, and $result.

Referenced by isComplete().

{
$points = 0;
foreach($this->results as $result)
{
$points += $result->getPoints();
}
return $points;
}

+ Here is the caller graph for this function:

assFormulaQuestion::getOperators (   $expression)

Get all available operations for a specific question.

Parameters
$expression

Implements iQuestionCondition.

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

References ilOperatorsExpressionMapping\getOperatorsByExpression().

{
require_once "./Modules/TestQuestionPool/classes/class.ilOperatorsExpressionMapping.php";
}

+ Here is the call graph for this function:

assFormulaQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Reimplemented from assQuestion.

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

{
return "assFormulaQuestion";
}
assFormulaQuestion::getResult (   $result)

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

References $result.

Referenced by getAvailableAnswerOptions(), loadFromDb(), and substituteVariables().

{
if(array_key_exists($result, $this->results))
{
return $this->results[$result];
}
return null;
}

+ Here is the caller graph for this function:

assFormulaQuestion::getResults ( )

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

References $results.

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

{
}

+ Here is the caller graph for this function:

assFormulaQuestion::getResultUnits (   $result)

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

References $result, and $resultunits.

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

{
if(array_key_exists($result->getResult(), $this->resultunits))
{
return $this->resultunits[$result->getResult()];
}
else
{
return array();
}
}

+ Here is the caller graph for this function:

assFormulaQuestion::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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

{
return $text;
}
assFormulaQuestion::getSolutionSubmit ( )
protected
Returns
array

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

References $_POST.

Referenced by savePreviewData(), and saveWorkingData().

{
$solutionSubmit = array();
foreach($_POST as $k => $v)
{
if(preg_match("/^result_(\\\$r\\d+)$/", $k))
{
$solutionSubmit[$k] = $v;
} elseif(preg_match("/^result_(\\\$r\\d+)_unit$/", $k))
{
$solutionSubmit[$k] = $v;
}
}
return $solutionSubmit;
}

+ Here is the caller graph for this function:

assFormulaQuestion::getUnitrepository ( )
Returns

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

References $unitrepository.

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

{
}

+ Here is the caller graph for this function:

assFormulaQuestion::getVariable (   $variable)

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

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

{
if(array_key_exists($variable, $this->variables))
{
return $this->variables[$variable];
}
return null;
}

+ Here is the caller graph for this function:

assFormulaQuestion::getVariables ( )

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

References $variables.

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

{
}

+ Here is the caller graph for this function:

assFormulaQuestion::hasResultUnit (   $result,
  $unit_id 
)

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

References $result, and $resultunits.

{
if(array_key_exists($result->getResult(), $this->resultunits))
{
if(array_key_exists($unit_id, $this->resultunits[$result->getResult()]))
{
return TRUE;
}
}
return FALSE;
}
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

Reimplemented from assQuestion.

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

References getMaximumPoints().

{
if(($this->title) and ($this->author) and ($this->question) and ($this->getMaximumPoints() > 0))
{
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

assFormulaQuestion::loadFromDb (   $question_id)

Loads a assFormulaQuestion object from a database.

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

Reimplemented from assQuestion.

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

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

{
global $ilDB;
$result = $ilDB->queryF("SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
$this->setId($question_id);
$this->setTitle($data["title"]);
$this->setComment($data["description"]);
$this->setSuggestedSolution($data["solution_hint"]);
$this->setOriginalId($data["original_id"]);
$this->setObjId($data["obj_fi"]);
$this->setAuthor($data["author"]);
$this->setOwner($data["owner"]);
try
{
$this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
}
{
}
$this->unitrepository = new ilUnitConfigurationRepository($question_id);
include_once("./Services/RTE/classes/class.ilRTE.php");
$this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
$this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
// load variables
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s",
array('integer'),
array($question_id)
);
if($result->numRows() > 0)
{
while($data = $ilDB->fetchAssoc($result))
{
$varObj = new assFormulaQuestionVariable($data["variable"], $data["range_min"], $data["range_max"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["varprecision"], $data["intprecision"]);
$varObj->setRangeMinTxt($data['range_min_txt']);
$varObj->setRangeMaxTxt($data['range_max_txt']);
$this->addVariable($varObj);
}
}
// load results
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s",
array('integer'),
array($question_id)
);
if($result->numRows() > 0)
{
while($data = $ilDB->fetchAssoc($result))
{
$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"]);
$resObj->setResultType($data['result_type']);
$resObj->setRangeMinTxt($data['range_min_txt']);
$resObj->setRangeMaxTxt($data['range_max_txt']);
$this->addResult($resObj);
}
}
// load result units
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
array('integer'),
array($question_id)
);
if($result->numRows() > 0)
{
while($data = $ilDB->fetchAssoc($result))
{
$unit = $this->getUnitrepository()->getUnit($data["unit_fi"]);
$resObj = $this->getResult($data["result"]);
$this->addResultUnit($resObj, $unit);
}
}
}
parent::loadFromDb($question_id);
}

+ Here is the call graph for this function:

assFormulaQuestion::parseQuestionText ( )

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

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

{
$this->clearResults();
$this->clearVariables();
if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
{
foreach($matches[1] as $variable)
{
$varObj = new assFormulaQuestionVariable($variable, 0, 0, null, 0);
$this->addVariable($varObj);
}
}
if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
{
foreach($rmatches[1] as $result)
{
$resObj = new assFormulaQuestionResult($result, NULL, NULL, 0, -1, NULL, 1, 1, TRUE);
$this->addResult($resObj);
}
}
}

+ Here is the call graph for this function:

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

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

Reimplemented from assQuestion.

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

{
// nothing to do
}
assFormulaQuestion::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

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

References ilAssQuestionPreviewSession\getParticipantsSolution(), getSolutionSubmit(), and ilAssQuestionPreviewSession\setParticipantsSolution().

{
$userSolution = $previewSession->getParticipantsSolution();
foreach($this->getSolutionSubmit() as $key => $val)
{
$matches = null;
if(preg_match("/^result_(\\\$r\\d+)$/", $key, $matches))
{
$userSolution[$matches[1]] = $val;
}
else if(preg_match("/^result_(\\\$r\\d+)_unit$/", $key, $matches))
{
$userSolution[$matches[1] . "_unit"] = $val;
}
}
$previewSession->setParticipantsSolution($userSolution);
}

+ Here is the call graph for this function:

assFormulaQuestion::saveToDb (   $original_id = "")

Saves a assFormulaQuestion object to a database public.

Reimplemented from assQuestion.

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

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

{
global $ilDB;
// save variables
$affectedRows = $ilDB->manipulateF("
DELETE FROM il_qpl_qst_fq_var
WHERE question_fi = %s",
array("integer"),
array($this->getId())
);
$source_qst_id = $original_id;
$target_qst_id = $this->getId();
foreach($this->variables as $variable)
{
$next_id = $ilDB->nextId('il_qpl_qst_fq_var');
$ilDB->insert('il_qpl_qst_fq_var',
array(
'variable_id' => array('integer', $next_id),
'question_fi' => array('integer', $this->getId()),
'variable' => array('text', $variable->getVariable()),
'range_min' => array('float', ((strlen($variable->getRangeMin())) ? $variable->getRangeMin() : 0.0)),
'range_max' => array('float', ((strlen($variable->getRangeMax())) ? $variable->getRangeMax() : 0.0)),
'unit_fi' => array('integer', (is_object($variable->getUnit()) ? (int)$variable->getUnit()->getId() : 0)),
'varprecision' => array('integer', (int)$variable->getPrecision()),
'intprecision' => array('integer', (int)$variable->getIntprecision()),
'range_min_txt' => array('text', $variable->getRangeMinTxt()),
'range_max_txt' => array('text', $variable->getRangeMaxTxt())
));
}
// save results
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res WHERE question_fi = %s",
array("integer"),
array($this->getId())
);
foreach($this->results as $result)
{
$next_id = $ilDB->nextId('il_qpl_qst_fq_res');
if( is_object($result->getUnit()))
{
$tmp_result_unit = $result->getUnit()->getId();
}
else
{
$tmp_result_unit = NULL;
}
$formula = str_replace(",", ".", $result->getFormula());
$ilDB->insert("il_qpl_qst_fq_res", array(
"result_id" => array("integer", $next_id),
"question_fi" => array("integer", $this->getId()),
"result" => array("text", $result->getResult()),
"range_min" => array("float", ((strlen($result->getRangeMin())) ? $result->getRangeMin() : 0)),
"range_max" => array("float", ((strlen($result->getRangeMax())) ? $result->getRangeMax() : 0)),
"tolerance" => array("float", ((strlen($result->getTolerance())) ? $result->getTolerance() : 0)),
"unit_fi" => array("integer", (int)$tmp_result_unit),
"formula" => array("clob", $formula),
"resprecision" => array("integer", $result->getPrecision()),
"rating_simple" => array("integer", ($result->getRatingSimple()) ? 1 : 0),
"rating_sign" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingSign()),
"rating_value" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingValue()),
"rating_unit" => array("float", ($result->getRatingSimple()) ? 0 : $result->getRatingUnit()),
"points" => array("float", $result->getPoints()),
"result_type" => array('integer', (int)$result->getResultType()),
"range_min_txt" => array("text", $result->getRangeMinTxt()),
"range_max_txt" => array("text", $result->getRangeMaxTxt())
));
}
// save result units
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s",
array("integer"),
array($this->getId())
);
foreach($this->results as $result)
{
foreach($this->getResultUnits($result) as $unit)
{
$next_id = $ilDB->nextId('il_qpl_qst_fq_res_unit');
$affectedRows = $ilDB->manipulateF("INSERT INTO il_qpl_qst_fq_res_unit (result_unit_id, question_fi, result, unit_fi) VALUES (%s, %s, %s, %s)",
array('integer', 'integer', 'text', 'integer'),
array(
$next_id,
$this->getId(),
$result->getResult(),
$unit->getId()
)
);
}
}
// copy category/unit-process:
// if $source_qst_id = '' -> nothing to copy because this is a new question
// if $source_qst_id == $target_qst_id -> nothing to copy because this is just an update-process
// if $source_qst_id != $target_qst_id -> copy categories and untis because this is a copy-process
// @todo: Nadia wtf?
if($source_qst_id != $target_qst_id && $source_qst_id > 0)
{
$res = $ilDB->queryF('
SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi = %s',
array('integer'), array($source_qst_id));
$cp_cats = array();
while($row = $ilDB->fetchAssoc($res))
{
$cp_cats[] = $row['category_id'];
}
foreach($cp_cats as $old_category_id)
{
// copy admin-categorie to custom-category (with question_fi)
$new_cat_id = $this->unitrepository->copyCategory($old_category_id, $target_qst_id);
// copy units to custom_category
$this->unitrepository->copyUnitsByCategories($old_category_id, $new_cat_id, $target_qst_id);
}
}
}

+ Here is the call graph for this function:

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

Reimplemented from assQuestion.

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

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

{
global $ilDB;
if(is_null($pass))
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
}
$this->getProcessLocker()->requestUserSolutionUpdateLock();
$solutionSubmit = $this->getSolutionSubmit();
$entered_values = FALSE;
foreach($solutionSubmit as $key => $value)
{
$matches = null;
if(preg_match("/^result_(\\\$r\\d+)$/", $key, $matches))
{
if(strlen($value)) $entered_values = TRUE;
$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]),
array('integer', 'integer', 'integer'),
array($active_id, $pass, $this->getId())
);
if($result->numRows())
{
while($row = $ilDB->fetchAssoc($result))
{
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s",
array('integer'),
array($row['solution_id'])
);
}
}
$affectedRows = $this->saveCurrentSolution($active_id,$pass,$matches[1],str_replace(",", ".", $value));
}
else if(preg_match("/^result_(\\\$r\\d+)_unit$/", $key, $matches))
{
$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"),
array('integer', 'integer', 'integer'),
array($active_id, $pass, $this->getId())
);
if($result->numRows())
{
while($row = $ilDB->fetchAssoc($result))
{
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s",
array('integer'),
array($row['solution_id'])
);
}
}
$affectedRows = $this->saveCurrentSolution($active_id,$pass,$matches[1] . "_unit",$value);
}
}
$this->getProcessLocker()->releaseUserSolutionUpdateLock();
if($entered_values)
{
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
}
}
else
{
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
}
}
return true;
}

+ Here is the call graph for this function:

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

Reimplemented from assQuestion.

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

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

{
require_once 'Services/Excel/classes/class.ilExcelUtils.php';
$solution = $this->getSolutionValues($active_id, $pass);
$worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
$worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
$i = 1;
foreach($solution as $solutionvalue)
{
$worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($solutionvalue["value1"]), $format_bold);
if(strpos($solutionvalue["value1"], "_unit"))
{
$unit = $this->getUnitrepository()->getUnit($solutionvalue["value2"]);
if(is_object($unit))
{
$worksheet->write($startrow + $i, 1, $unit->getUnit());
}
}
else
{
$worksheet->write($startrow + $i, 1, $solutionvalue["value2"]);
}
if(preg_match("/(\\\$v\\d+)/", $solutionvalue["value1"], $matches))
{
$var = $this->getVariable($solutionvalue["value1"]);
if(is_object($var) && (is_object($var->getUnit())))
{
$worksheet->write($startrow + $i, 2, $var->getUnit()->getUnit());
}
}
$i++;
}
return $startrow + $i + 1;
}

+ Here is the call graph for this function:

assFormulaQuestion::setId (   $id = -1)

Sets the id of the assQuestion object.

Parameters
integer$idA unique integer value public
See Also
$id

Reimplemented from assQuestion.

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

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

Referenced by loadFromDb().

{
$this->unitrepository->setConsumerId($this->getId());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $unitrepository.

{
$this->unitrepository = $unitrepository;
}
assFormulaQuestion::substituteVariables (   $userdata = null,
  $graphicalOutput = FALSE,
  $forsolution = FALSE,
  $result_output = FALSE,
ilAssQuestionPreviewSession  $previewSession = null 
)

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

References $ilDB, $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.

{
global $ilDB;
if((count($this->results) == 0) && (count($this->variables) == 0))
return false;
$text = $this->getQuestion();
if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
{
foreach($rmatches[1] as $result)
{
$resObj = $this->getResult($result);
$resObj->findValidRandomVariables($this->getVariables(), $this->getResults());
}
}
if(preg_match_all("/(\\\$v\\d+)/ims", $this->getQuestion(), $matches))
{
foreach($matches[1] as $variable)
{
$varObj = $this->getVariable($variable);
if(is_array($userdata))
{
if(strlen($userdata[$varObj->getVariable()]))
{
$value = $userdata[$varObj->getVariable()];
$varObj->setValue($value);
}
elseif( is_object($previewSession) )
{
$userSolution = $previewSession->getParticipantsSolution();
$userSolution[$varObj->getVariable()] = $varObj->getValue();
$previewSession->setParticipantsSolution($userSolution);
}
else
{
// save value to db
$this->saveCurrentSolution($userdata["active_id"], $userdata["pass"], $variable,$varObj->getValue());
}
}
$unit = (is_object($varObj->getUnit())) ? $varObj->getUnit()->getUnit() : "";
$val = (strlen($varObj->getValue()) > 8) ? strtoupper(sprintf("%e", $varObj->getValue())) : $varObj->getValue();
$text = preg_replace("/\\$" . substr($variable, 1) . "(?![0-9]+)/", $val . " " . $unit . "\\1", $text);
}
}
if(preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches))
{
foreach($rmatches[1] as $result)
{
$resObj = $this->getResult($result);
$value = "";
$frac_helper = '';
$user_data[$result]['result_type'] = $resObj->getResultType();
if(
$resObj->getResultType() == assFormulaQuestionResult::RESULT_FRAC ||
$resObj->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
)
{
$is_frac = true;
}
if(is_array($userdata))
{
if(is_array($userdata[$result]))
{
if($forsolution && $result_output)
{
$value_org = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId());
$value = sprintf("%." . $resObj->getPrecision() . "f", $value_org);
if($is_frac)
{
if(is_array($value))
{
$frac_helper = $value[1];
$value = $value[0];
}
}
}
else
{
if($forsolution)
{
$value = $userdata[$result]["value"];
}
else
{
$value = ' value="' . $userdata[$result]["value"] . '"';
}
}
}
}
else
{
if($forsolution)
{
$value = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId());
$value = sprintf("%." . $resObj->getPrecision() . "f", $value);
if($is_frac)
{
if(is_array($value))
{
$frac_helper = $value[1];
$value = $value[0];
}
$value = ' value="' . $value . '"';
}
}
else
{
// Precision fix for Preview by tjoussen
// If all default values are set, this function is called in getPreview
$use_precision = !($userdata == null && $graphicalOutput == FALSE && $forsolution == FALSE && $result_output == FALSE);
$val = $resObj->calculateFormula($this->getVariables(), $this->getResults(), parent::getId(), $use_precision);
if($resObj->getResultType() == assFormulaQuestionResult::RESULT_FRAC
||$resObj->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC)
{
$val = $resObj->convertDecimalToCoprimeFraction($val);
if(is_array($val))
{
$frac_helper = $val[1];
$val = $val[0];
}
}
else
{
$val = sprintf("%." . $resObj->getPrecision() . "f", $val);
$val = (strlen($val) > 8) ? strtoupper(sprintf("%e", $val)) : $val;
}
$value = ' value="' . $val . '"';
}
}
if($forsolution)
{
$input = '<span class="solutionbox">' . ilUtil::prepareFormOutput($value) . '</span>';
}
else
{
$input = '<input type="text" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" name="result_' . $result . '"' . $value . ' />';
}
$units = "";
if(count($this->getResultUnits($resObj)) > 0)
{
if($forsolution)
{
if(is_array($userdata))
{
foreach($this->getResultUnits($resObj) as $unit)
{
if($userdata[$result]["unit"] == $unit->getId())
{
$units = $unit->getUnit();
}
}
}
else
{
if($resObj->getUnit())
{
$units = $resObj->getUnit()->getUnit();
}
}
}
else
{
$units = '<select name="result_' . $result . '_unit">';
$units .= '<option value="-1">' . $this->lng->txt("select_unit") . '</option>';
foreach($this->getResultUnits($resObj) as $unit)
{
$units .= '<option value="' . $unit->getId() . '"';
if((is_array($userdata[$result])) && (strlen($userdata[$result]["unit"])))
{
if($userdata[$result]["unit"] == $unit->getId())
{
$units .= ' selected="selected"';
}
}
$units .= '>' . $unit->getUnit() . '</option>';
}
$units .= '</select>';
}
}
else
{
$units = "";
}
switch($resObj->getResultType())
{
$units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_dec');
break;
if(strlen($frac_helper))
{
$units .= ' &asymp; ' . $frac_helper . ', ';
}
elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result]["frac_helper"]))
{
if(!preg_match('-/-', $value))
{
$units .= ' &asymp; ' . $userdata[$result]["frac_helper"] . ', ';
}
}
$units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_frac');
break;
if(strlen($frac_helper))
{
$units .= ' &asymp; ' . $frac_helper . ', ';
}
elseif (is_array($userdata) && isset($userdata[$result]) && strlen($userdata[$result]["frac_helper"]))
{
if(!preg_match('-/-', $value))
{
$units .= ' &asymp; ' . $userdata[$result]["frac_helper"] . ', ';
}
}
$units .= ' ' . $this->lng->txt('expected_result_type') . ': ' . $this->lng->txt('result_co_frac');
break;
break;
}
$checkSign = "";
if($graphicalOutput)
{
$resunit = null;
$user_value = '';
if(is_array($userdata) && is_array($userdata[$result]))
{
if($userdata[$result]["unit"] > 0)
{
$resunit = $this->getUnitrepository()->getUnit($userdata[$result]["unit"]);
}
if(isset($userdata[$result]["value"]))
{
$user_value = $userdata[$result]["value"];
}
}
$template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution_image.html", true, true, 'Modules/TestQuestionPool');
if($resObj->isCorrect($this->getVariables(), $this->getResults(), $user_value, $resunit))
{
$template->setCurrentBlock("icon_ok");
$template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
$template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("icon_not_ok");
$template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
$template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
$template->parseCurrentBlock();
}
$checkSign = $template->get();
}
$resultOutput = "";
if($result_output)
{
$template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution_result.html", true, true, 'Modules/TestQuestionPool');
if(is_array($userdata))
{
$found = $resObj->getResultInfo($this->getVariables(), $this->getResults(), $userdata[$resObj->getResult()]["value"], $userdata[$resObj->getResult()]["unit"], $this->getUnitrepository()->getUnits());
}
else
{
$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());
}
$resulttext = "(";
if($resObj->getRatingSimple())
{
if($frac_helper)
{
$resulttext .="n/a";
}
else
{
$resulttext .= $found['points'] . " " . (($found['points'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points'));
}
}
else
{
$resulttext .= $this->lng->txt("rated_sign") . " " . (($found['sign']) ? $found['sign'] : 0) . " " . (($found['sign'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points')) . ", ";
$resulttext .= $this->lng->txt("rated_value") . " " . (($found['value']) ? $found['value'] : 0) . " " . (($found['value'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points')) . ", ";
$resulttext .= $this->lng->txt("rated_unit") . " " . (($found['unit']) ? $found['unit'] : 0) . " " . (($found['unit'] == 1) ? $this->lng->txt('point') : $this->lng->txt('points'));
}
$resulttext .= ")";
$template->setVariable("RESULT_OUTPUT", $resulttext);
$resultOutput = $template->get();
}
$text = preg_replace("/\\\$" . substr($result, 1) . "(?![0-9]+)/", $input . " " . $units . " " . $checkSign . " " . $resultOutput . " " . "\\1", $text);
}
}
return $text;
}

+ Here is the call graph for this function:

Field Documentation

assFormulaQuestion::$results
private

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

Referenced by getResults().

assFormulaQuestion::$resultunits
private

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

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

assFormulaQuestion::$unitrepository
private

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

Referenced by getUnitrepository(), and setUnitrepository().

assFormulaQuestion::$variables
private

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

Referenced by getVariables().


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