Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 45c4c5e2c4
commit f437236b69
  1. 50
      main/exercice/answer.class.php
  2. 158
      main/exercice/exercise.class.php
  3. 151
      main/exercice/question.class.php

@ -85,7 +85,7 @@ class Answer
/**
* Clears $new_* arrays
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
function cancel() {
$this->new_answer = array();
@ -102,7 +102,7 @@ class Answer
/**
* Reads answer information from the database
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
public function read()
{
@ -138,8 +138,8 @@ class Answer
/**
* returns all answer ids from this question Id
*
* @author - Yoselyn Castillo
* @return - array - $id (answer ids)
* @author Yoselyn Castillo
* @return array - $id (answer ids)
*/
public function selectAnswerId()
{
@ -224,8 +224,8 @@ class Answer
/**
* returns the autoincrement id identificator
*
* @author - Juan Carlos Ra<EFBFBD>a
* @return - integer - answer num
* @author Juan Carlos Ra<EFBFBD>a
* @return integer - answer num
*/
function selectAutoId($id)
{
@ -235,8 +235,8 @@ class Answer
/**
* returns the number of answers in this question
*
* @author - Olivier Brouckaert
* @return - integer - number of answers
* @author Olivier Brouckaert
* @return integer - number of answers
*/
function selectNbrAnswers()
{
@ -246,8 +246,8 @@ class Answer
/**
* returns the question ID which the answers belong to
*
* @author - Olivier Brouckaert
* @return - integer - the question ID
* @author Olivier Brouckaert
* @return integer - the question ID
*/
function selectQuestionId()
{
@ -257,8 +257,8 @@ class Answer
/**
* returns the question ID of the destination question
*
* @author - Julio Montoya
* @return - integer - the question ID
* @author Julio Montoya
* @return integer - the question ID
*/
function selectDestination($id)
{
@ -268,9 +268,9 @@ class Answer
/**
* returns the answer title
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @param - integer $id - answer ID
* @return - string - answer title
* @return string - answer title
*/
function selectAnswer($id)
{
@ -297,9 +297,9 @@ class Answer
/**
* returns the answer title from an answer's position
*
* @author - Yannick Warnier
* @author Yannick Warnier
* @param - integer $id - answer ID
* @return - bool - answer title
* @return bool - answer title
*/
function selectAnswerIdByPosition($pos) {
foreach ($this->position as $k => $v) {
@ -375,9 +375,9 @@ class Answer
/**
* tells if answer is correct or not
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @param - integer $id - answer ID
* @return - integer - 0 if bad answer, not 0 if good answer
* @return integer - 0 if bad answer, not 0 if good answer
*/
function isCorrect($id)
{
@ -387,9 +387,9 @@ class Answer
/**
* returns answer comment
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @param - integer $id - answer ID
* @return - string - answer comment
* @return string - answer comment
*/
function selectComment($id)
{
@ -399,9 +399,9 @@ class Answer
/**
* returns answer weighting
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @param - integer $id - answer ID
* @return - integer - answer weighting
* @return integer - answer weighting
*/
function selectWeighting($id)
{
@ -411,9 +411,9 @@ class Answer
/**
* returns answer position
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @param - integer $id - answer ID
* @return - integer - answer position
* @return integer - answer position
*/
function selectPosition($id)
{
@ -507,7 +507,7 @@ class Answer
/**
* Records answers into the data base
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
function save()
{

@ -66,7 +66,8 @@ class Exercise {
*
* @author - Olivier Brouckaert
*/
function Exercise($course_id = null) {
public function Exercise($course_id = null)
{
$this->id = 0;
$this->exercise = '';
$this->description = '';
@ -98,13 +99,14 @@ class Exercise {
}
/**
* reads exercise informations from the data base
* Reads exercise information from the data base
*
* @author - Olivier Brouckaert
* @param - integer $id - exercise ID
* @return - boolean - true if exercise exists, otherwise false
* @author Olivier Brouckaert
* @param integer $id - exercise ID
* @return boolean - true if exercise exists, otherwise false
*/
function read($id) {
public function read($id)
{
global $_configuration;
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
@ -192,7 +194,8 @@ class Exercise {
return false;
}
function getCutTitle() {
function getCutTitle()
{
return cut($this->exercise, EXERCISE_MAX_NAME_SIZE);
}
@ -209,8 +212,8 @@ class Exercise {
/**
* returns the exercise title
*
* @author - Olivier Brouckaert
* @return - string - exercise title
* @author Olivier Brouckaert
* @return string - exercise title
*/
function selectTitle() {
return $this->exercise;
@ -219,7 +222,7 @@ class Exercise {
/**
* returns the number of attempts setted
*
* @return - numeric - exercise attempts
* @return numeric - exercise attempts
*/
function selectAttempts() {
return $this->attempts;
@ -227,7 +230,7 @@ class Exercise {
/** returns the number of FeedbackType *
* 0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback
* @return - numeric - exercise attempts
* @return numeric - exercise attempts
*/
function selectFeedbackType() {
return $this->feedback_type;
@ -243,8 +246,8 @@ class Exercise {
/**
* returns the exercise description
*
* @author - Olivier Brouckaert
* @return - string - exercise description
* @author Olivier Brouckaert
* @return string - exercise description
*/
function selectDescription() {
return $this->description;
@ -253,8 +256,8 @@ class Exercise {
/**
* returns the exercise sound file
*
* @author - Olivier Brouckaert
* @return - string - exercise description
* @author Olivier Brouckaert
* @return string - exercise description
*/
function selectSound() {
return $this->sound;
@ -263,16 +266,16 @@ class Exercise {
/**
* returns the exercise type
*
* @author - Olivier Brouckaert
* @return - integer - exercise type
* @author Olivier Brouckaert
* @return integer - exercise type
*/
function selectType() {
return $this->type;
}
/**
* @author - hubert borderiou 30-11-11
* @return - integer : do we display the question category name for students
* @author hubert borderiou 30-11-11
* @return integer : do we display the question category name for students
*/
function selectDisplayCategoryName() {
return $this->display_category_name;
@ -283,8 +286,8 @@ class Exercise {
}
/**
* @author - hubert borderiou 30-11-11
* @return - : modify object to update the switch display_category_name
* @author hubert borderiou 30-11-11
* @return : modify object to update the switch display_category_name
* $in_txt is an integer 0 or 1
*/
function updateDisplayCategoryName($in_txt) {
@ -292,16 +295,16 @@ class Exercise {
}
/**
* @author - hubert borderiou 28-11-11
* @return - html text : the text to display ay the end of the test.
* @author hubert borderiou 28-11-11
* @return html text : the text to display ay the end of the test.
*/
function selectTextWhenFinished() {
return $this->text_when_finished;
}
/**
* @author - hubert borderiou 28-11-11
* @return - html text : update the text to display ay the end of the test.
* @author hubert borderiou 28-11-11
* @return html text : update the text to display ay the end of the test.
*/
function updateTextWhenFinished($in_txt) {
$this->text_when_finished = $in_txt;
@ -309,8 +312,8 @@ class Exercise {
/**
* return 1 or 2 if randomByCat
* @author - hubert borderiou
* @return - integer - quiz random by category
* @author hubert borderiou
* @return integer - quiz random by category
*/
function selectRandomByCat() {
return $this->randomByCat;
@ -320,8 +323,8 @@ class Exercise {
* return 0 if no random by cat
* return 1 if random by cat, categories shuffled
* return 2 if random by cat, categories sorted by alphabetic order
* @author - hubert borderiou
* @return - integer - quiz random by category
* @author hubert borderiou
* @return integer - quiz random by category
*/
function isRandomByCat() {
$res = 0;
@ -336,7 +339,7 @@ class Exercise {
/**
* return nothing
* update randomByCat value for object
* @author - hubert borderiou
* @author hubert borderiou
*/
function updateRandomByCat($in_randombycat) {
if ($in_randombycat == 1) {
@ -352,8 +355,8 @@ class Exercise {
/**
* tells if questions are selected randomly, and if so returns the draws
*
* @author - Carlos Vargas
* @return - integer - results disabled exercise
* @author Carlos Vargas
* @return integer - results disabled exercise
*/
function selectResultsDisabled() {
return $this->results_disabled;
@ -362,8 +365,8 @@ class Exercise {
/**
* tells if questions are selected randomly, and if so returns the draws
*
* @author - Olivier Brouckaert
* @return - integer - 0 if not random, otherwise the draws
* @author Olivier Brouckaert
* @return integer - 0 if not random, otherwise the draws
*/
function isRandom() {
if($this->random > 0 || $this->random == -1) {
@ -376,7 +379,7 @@ class Exercise {
/**
* returns random answers status.
*
* @author - Juan Carlos Rana
* @author Juan Carlos Rana
*/
function selectRandomAnswers() {
return $this->random_answers;
@ -392,8 +395,8 @@ class Exercise {
/**
* returns the exercise status (1 = enabled ; 0 = disabled)
*
* @author - Olivier Brouckaert
* @return - boolean - true if enabled, otherwise false
* @author Olivier Brouckaert
* @return boolean - true if enabled, otherwise false
*/
function selectStatus() {
return $this->active;
@ -402,8 +405,8 @@ class Exercise {
/**
* returns the array with the question ID list
*
* @author - Olivier Brouckaert
* @return - array - question ID list
* @author Olivier Brouckaert
* @return array - question ID list
*/
function selectQuestionList($from_db = false) {
if ($from_db && !empty($this->id)) {
@ -450,8 +453,8 @@ class Exercise {
/**
* returns the number of questions in this exercise
*
* @author - Olivier Brouckaert
* @return - integer - number of questions
* @author Olivier Brouckaert
* @return integer - number of questions
*/
function selectNbrQuestions() {
return sizeof($this->questionList);
@ -464,8 +467,8 @@ class Exercise {
/**
* Selects questions randomly in the question list
*
* @author - Olivier Brouckaert
* @return - array - if the exercise is not set to take questions randomly, returns the question list
* @author Olivier Brouckaert
* @return array - if the exercise is not set to take questions randomly, returns the question list
* without randomizing, otherwise, returns the list with questions selected randomly
* Modified by Hubert Borderiou 15 nov 2011
*/
@ -502,9 +505,9 @@ class Exercise {
/**
* returns 'true' if the question ID is in the question list
*
* @author - Olivier Brouckaert
* @param - integer $questionId - question ID
* @return - boolean - true if in the list, otherwise false
* @author Olivier Brouckaert
* @param integer $questionId - question ID
* @return boolean - true if in the list, otherwise false
*/
function isInList($questionId) {
if (is_array($this->questionList))
@ -516,8 +519,8 @@ class Exercise {
/**
* changes the exercise title
*
* @author - Olivier Brouckaert
* @param - string $title - exercise title
* @author Olivier Brouckaert
* @param string $title - exercise title
*/
function updateTitle($title) {
$this->exercise=$title;
@ -526,7 +529,7 @@ class Exercise {
/**
* changes the exercise max attempts
*
* @param - numeric $attempts - exercise max attempts
* @param numeric $attempts - exercise max attempts
*/
function updateAttempts($attempts) {
$this->attempts=$attempts;
@ -536,7 +539,7 @@ class Exercise {
/**
* changes the exercise feedback type
*
* @param - numeric $attempts - exercise max attempts
* @param numeric $attempts - exercise max attempts
*/
function updateFeedbackType($feedback_type) {
$this->feedback_type=$feedback_type;
@ -545,8 +548,8 @@ class Exercise {
/**
* changes the exercise description
*
* @author - Olivier Brouckaert
* @param - string $description - exercise description
* @author Olivier Brouckaert
* @param string $description - exercise description
*/
function updateDescription($description) {
$this->description=$description;
@ -555,8 +558,8 @@ class Exercise {
/**
* changes the exercise expired_time
*
* @author - Isaac flores
* @param - int The expired time of the quiz
* @author Isaac flores
* @param int The expired time of the quiz
*/
function updateExpiredTime($expired_time) {
$this->expired_time = $expired_time;
@ -577,9 +580,9 @@ class Exercise {
/**
* changes the exercise sound file
*
* @author - Olivier Brouckaert
* @param - string $sound - exercise sound file
* @param - string $delete - ask to delete the file
* @author Olivier Brouckaert
* @param string $sound - exercise sound file
* @param string $delete - ask to delete the file
*/
function updateSound($sound,$delete) {
global $audioPath, $documentPath;
@ -609,8 +612,8 @@ class Exercise {
/**
* changes the exercise type
*
* @author - Olivier Brouckaert
* @param - integer $type - exercise type
* @author Olivier Brouckaert
* @param integer $type - exercise type
*/
function updateType($type) {
$this->type=$type;
@ -620,8 +623,8 @@ class Exercise {
* sets to 0 if questions are not selected randomly
* if questions are selected randomly, sets the draws
*
* @author - Olivier Brouckaert
* @param - integer $random - 0 if not random, otherwise the draws
* @author Olivier Brouckaert
* @param integer $random - 0 if not random, otherwise the draws
*/
function setRandom($random) {
/*if ($random == 'all') {
@ -634,8 +637,8 @@ class Exercise {
/**
* sets to 0 if answers are not selected randomly
* if answers are selected randomly
* @author - Juan Carlos Rana
* @param - integer $random_answers - random answers
* @author Juan Carlos Rana
* @param integer $random_answers - random answers
*/
function updateRandomAnswers($random_answers) {
$this->random_answers = $random_answers;
@ -644,7 +647,7 @@ class Exercise {
/**
* enables the exercise
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
function enable() {
$this->active=1;
@ -653,7 +656,7 @@ class Exercise {
/**
* disables the exercise
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
function disable() {
$this->active=0;
@ -675,7 +678,7 @@ class Exercise {
/**
* updates the exercise in the data base
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
function save($type_e = '')
{
@ -832,9 +835,9 @@ class Exercise {
/**
* Adds a question into the question list
*
* @author - Olivier Brouckaert
* @param - integer $questionId - question ID
* @return - boolean - true if the question has been added, otherwise false
* @author Olivier Brouckaert
* @param integer $questionId - question ID
* @return boolean - true if the question has been added, otherwise false
*/
function addToList($questionId) {
// checks if the question ID is not in the list
@ -855,9 +858,9 @@ class Exercise {
/**
* removes a question from the question list
*
* @author - Olivier Brouckaert
* @param - integer $questionId - question ID
* @return - boolean - true if the question has been removed, otherwise false
* @author Olivier Brouckaert
* @param integer $questionId - question ID
* @return boolean - true if the question has been removed, otherwise false
*/
function removeFromList($questionId) {
// searches the position of the question ID in the list
@ -885,7 +888,7 @@ class Exercise {
* deletes the exercise from the database
* Notice : leaves the question in the data base
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
function delete() {
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -900,7 +903,7 @@ class Exercise {
/**
* Creates the form to create / edit an exercise
* @param FormValidator $form the formvalidator instance (by reference)
* @param FormValidator $form
*/
function createForm ($form, $type='full') {
global $id;
@ -1580,7 +1583,7 @@ class Exercise {
/**
* Changes the exercise id
*
* @param - in $id - exercise id
* @param int $id - exercise id
*/
private function updateId($id) {
$this->id = $id;
@ -1589,7 +1592,7 @@ class Exercise {
/**
* Changes the exercise status
*
* @param - string $status - exercise status
* @param string $status - exercise status
*/
function updateStatus($status) {
$this->active = $status;
@ -4131,7 +4134,8 @@ class Exercise {
* @param $in_title
* @return string
*/
public static function get_formated_title_variable($in_title) {
public static function get_formated_title_variable($in_title)
{
return api_html_entity_decode($in_title);
}

@ -82,7 +82,7 @@ abstract class Question
/**
* constructor of the class
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
*/
public function Question()
{
@ -110,11 +110,12 @@ abstract class Question
}
/**
* Reads question informations from the data base
* Reads question information from the data base
*
* @author - Olivier Brouckaert
* @param - integer $id - question ID
* @return - boolean - true if question exists, otherwise false
* @author Olivier Brouckaert
* @param integer $id - question ID
*
* @return Question
*/
static function read($id, $course_id = null) {
$id = intval($id);
@ -176,7 +177,7 @@ abstract class Question
/**
* returns the question ID
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - integer - question ID
*/
function selectId() {
@ -186,7 +187,7 @@ abstract class Question
/**
* returns the question title
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - string - question title
*/
function selectTitle() {
@ -196,7 +197,7 @@ abstract class Question
/**
* returns the question description
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - string - question description
*/
function selectDescription() {
@ -207,7 +208,7 @@ abstract class Question
/**
* returns the question weighting
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - integer - question weighting
*/
function selectWeighting()
@ -218,7 +219,7 @@ abstract class Question
/**
* returns the question position
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - integer - question position
*/
function selectPosition() {
@ -228,7 +229,7 @@ abstract class Question
/**
* returns the answer type
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - integer - answer type
*/
function selectType() {
@ -238,7 +239,7 @@ abstract class Question
/**
* returns the level of the question
*
* @author - Nicolas Raynaud
* @author Nicolas Raynaud
* @return - integer - level of the question, 0 by default.
*/
function selectLevel() {
@ -248,7 +249,7 @@ abstract class Question
/**
* returns the picture name
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - string - picture name
*/
function selectPicture() {
@ -265,7 +266,7 @@ abstract class Question
/**
* returns the array with the exercise ID list
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - array - list of exercise ID which the question is in
*/
function selectExerciseList() {
@ -275,7 +276,7 @@ abstract class Question
/**
* returns the number of exercises which this question is in
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - integer - number of exercises
*/
function selectNbrExercises() {
@ -285,8 +286,8 @@ abstract class Question
/**
* changes the question title
*
* @author - Olivier Brouckaert
* @param - string $title - question title
* @author Olivier Brouckaert
* @param string $title - question title
*/
function updateTitle($title) {
$this->question=$title;
@ -299,8 +300,8 @@ abstract class Question
/**
* changes the question description
*
* @author - Olivier Brouckaert
* @param - string $description - question description
* @author Olivier Brouckaert
* @param string $description - question description
*/
function updateDescription($description) {
$this->description=$description;
@ -309,32 +310,32 @@ abstract class Question
/**
* changes the question weighting
*
* @author - Olivier Brouckaert
* @param - integer $weighting - question weighting
* @author Olivier Brouckaert
* @param integer $weighting - question weighting
*/
function updateWeighting($weighting) {
$this->weighting=$weighting;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - array of category $in_category
* @author Hubert Borderiou 12-10-2011
* @param array of category $in_category
*/
function updateCategory($in_category) {
$this->category=$in_category;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
* @author Hubert Borderiou 12-10-2011
* @param interger $in_positive
*/
function updateScoreAlwaysPositive($in_positive) {
$this->scoreAlwaysPositive=$in_positive;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
* @author Hubert Borderiou 12-10-2011
* @param interger $in_positive
*/
function updateUncheckedMayScore($in_positive) {
$this->uncheckedMayScore=$in_positive;
@ -347,7 +348,7 @@ abstract class Question
* if category is empty, then question has no category then delete the category entry
*
* @param - int $in_positive
* @author - Julio Montoya - Adding multiple cat support
* @author Julio Montoya - Adding multiple cat support
*/
function saveCategories($category_list) {
@ -375,8 +376,8 @@ abstract class Question
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
* @author Hubert Borderiou 12-10-2011
* @param interger $in_positive
* in this version, a question can only have 1 category
* if category is 0, then question has no category then delete the category entry
*/
@ -418,8 +419,8 @@ abstract class Question
/**
* changes the question position
*
* @author - Olivier Brouckaert
* @param - integer $position - question position
* @author Olivier Brouckaert
* @param integer $position - question position
*/
function updatePosition($position) {
$this->position=$position;
@ -428,8 +429,8 @@ abstract class Question
/**
* changes the question level
*
* @author - Nicolas Raynaud
* @param - integer $level - question level
* @author Nicolas Raynaud
* @param integer $level - question level
*/
function updateLevel($level) {
$this->level=$level;
@ -439,8 +440,8 @@ abstract class Question
* changes the answer type. If the user changes the type from "unique answer" to "multiple answers"
* (or conversely) answers are not deleted, otherwise yes
*
* @author - Olivier Brouckaert
* @param - integer $type - answer type
* @author Olivier Brouckaert
* @param integer $type - answer type
*/
function updateType($type) {
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
@ -465,9 +466,9 @@ abstract class Question
/**
* adds a picture to the question
*
* @author - Olivier Brouckaert
* @param - string $Picture - temporary path of the picture to upload
* @param - string $PictureName - Name of the picture
* @author Olivier Brouckaert
* @param string $Picture - temporary path of the picture to upload
* @param string $PictureName - Name of the picture
* @return - boolean - true if uploaded, otherwise false
*/
function uploadPicture($Picture, $PictureName, $picturePath = null) {
@ -503,9 +504,9 @@ abstract class Question
/**
* Resizes a picture || Warning!: can only be called after uploadPicture, or if picture is already available in object.
*
* @author - Toon Keppens
* @param - string $Dimension - Resizing happens proportional according to given dimension: height|width|any
* @param - integer $Max - Maximum size
* @author Toon Keppens
* @param string $Dimension - Resizing happens proportional according to given dimension: height|width|any
* @param integer $Max - Maximum size
* @return - boolean - true if success, false if failed
*/
function resizePicture($Dimension, $Max) {
@ -571,7 +572,7 @@ abstract class Question
/**
* deletes the picture
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - boolean - true if removed, otherwise false
*/
function removePicture() {
@ -591,8 +592,8 @@ abstract class Question
/**
* Exports a picture to another question
*
* @author - Olivier Brouckaert
* @param - integer $questionId - ID of the target question
* @author Olivier Brouckaert
* @param integer $questionId - ID of the target question
* @return - boolean - true if copied, otherwise false
*/
function exportPicture($questionId, $course_info) {
@ -628,9 +629,9 @@ abstract class Question
* Temporary pictures are used when we don't want to save a picture right after a form submission.
* For example, if we first show a confirmation box.
*
* @author - Olivier Brouckaert
* @param - string $Picture - temporary path of the picture to move
* @param - string $PictureName - Name of the picture
* @author Olivier Brouckaert
* @param string $Picture - temporary path of the picture to move
* @param string $PictureName - Name of the picture
*/
function setTmpPicture($Picture,$PictureName) {
global $picturePath;
@ -660,7 +661,7 @@ abstract class Question
* Temporary pictures are used when we don't want to save a picture right after a form submission.
* For example, if we first show a confirmation box.
*
* @author - Olivier Brouckaert
* @author Olivier Brouckaert
* @return - boolean - true if moved, otherwise false
*/
function getTmpPicture() {
@ -685,8 +686,8 @@ abstract class Question
* updates the question in the data base
* if an exercise ID is provided, we add that exercise ID into the exercise list
*
* @author - Olivier Brouckaert
* @param - integer $exerciseId - exercise ID if saving in an exercise
* @author Olivier Brouckaert
* @param integer $exerciseId - exercise ID if saving in an exercise
*/
function save($exerciseId=0) {
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
@ -910,9 +911,9 @@ abstract class Question
/**
* adds an exercise into the exercise list
*
* @author - Olivier Brouckaert
* @param - integer $exerciseId - exercise ID
* @param - boolean $fromSave - comming from $this->save() or not
* @author Olivier Brouckaert
* @param integer $exerciseId - exercise ID
* @param boolean $fromSave - comming from $this->save() or not
*/
function addToList($exerciseId, $fromSave = false) {
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
@ -938,8 +939,8 @@ abstract class Question
/**
* removes an exercise from the exercise list
*
* @author - Olivier Brouckaert
* @param - integer $exerciseId - exercise ID
* @author Olivier Brouckaert
* @param integer $exerciseId - exercise ID
* @return - boolean - true if removed, otherwise false
*/
function removeFromList($exerciseId) {
@ -982,8 +983,8 @@ abstract class Question
* the parameter tells if the question is removed from all exercises (value = 0),
* or just from one exercise (value = exercise ID)
*
* @author - Olivier Brouckaert
* @param - integer $deleteFromEx - exercise ID if the question is only removed from one exercise
* @author Olivier Brouckaert
* @param integer $deleteFromEx - exercise ID if the question is only removed from one exercise
*/
function delete($deleteFromEx = 0) {
$course_id = api_get_course_int_id();
@ -1432,9 +1433,9 @@ abstract class Question
/**
* Shows question title an description
*
* @param type $feedback_type
* @param type $counter
* @param type $score
* @param string $feedback_type
* @param int $counter
* @param float $score
*/
function return_header($feedback_type = null, $counter = null, $score = null)
{
@ -1505,7 +1506,7 @@ abstract class Question
$sql = "INSERT INTO $tbl_quiz_question (c_id, question, description, ponderation, position, type, level)
VALUES ($course_id, '".Database::escape_string($question_name)."', '".Database::escape_string($question_description)."', '$max_score', $max_position, $type, $level)";
$rs = Database::query($sql);
Database::query($sql);
// Get the question ID
$question_id = Database::get_last_insert_id();
@ -1519,13 +1520,12 @@ abstract class Question
$sql = "INSERT INTO $tbl_quiz_rel_question "
."(c_id, question_id,exercice_id,question_order)"
." VALUES($course_id, $question_id, $quiz_id, $max_order)";
$rs = Database::query($sql);
Database::query($sql);
return $question_id;
}
/**
* return the image filename of the question type
*
* @return array the image filename of the question type
*/
public function get_type_icon_html() {
$type = $this->selectType();
@ -1549,13 +1549,16 @@ abstract class Question
array(
'limit' => " $start, $limit",
'where' => $default_where,
'order' => "$sidx $sord"));
'order' => "$sidx $sord")
);
return $result;
}
/**
* Get count course medias
* @param int course id
*
* @return int
*/
static function get_count_course_medias($course_id) {
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
@ -1567,6 +1570,10 @@ abstract class Question
return 0;
}
/**
* @param int $course_id
* @return array
*/
static function prepare_course_media_select($course_id) {
$medias = self::get_course_medias($course_id);
$media_list = array();
@ -1580,7 +1587,11 @@ abstract class Question
return $media_list;
}
static function get_default_levels() {
/**
* @return array
*/
static function get_default_levels()
{
$select_level = array(
1=>1,
2=>2,
@ -1591,7 +1602,11 @@ abstract class Question
return $select_level;
}
function show_media_content() {
/**
* @return null|string
*/
function show_media_content()
{
$html = null;
if ($this->parent_id != 0) {
$parent_question = Question::read($this->parent_id);

Loading…
Cancel
Save