Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 94646c66c1
commit 5f22d03c21
  1. 19
      main/exercice/answer.class.php
  2. 20
      main/exercice/exercise.class.php
  3. 53
      main/exercice/exercise.lib.php
  4. 13
      main/exercice/exercise_result.class.php
  5. 2
      main/exercice/fill_blanks.class.php
  6. 109
      main/exercice/freeanswer.class.php
  7. 24
      main/exercice/hotspot.class.php
  8. 1
      main/exercice/matching.class.php
  9. 3
      main/exercice/multiple_answer.class.php
  10. 30
      main/exercice/multiple_answer_combination.class.php
  11. 5
      main/exercice/multiple_answer_combination_true_false.class.php
  12. 3
      main/exercice/multiple_answer_true_false.class.php
  13. 24
      main/exercice/oral_expression.class.php
  14. 96
      main/exercice/question.class.php
  15. 2
      main/exercice/testcategory.class.php
  16. 3
      main/exercice/unique_answer.class.php
  17. 45
      main/exercice/unique_answer_no_option.class.php

@ -1,18 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This class allows to instantiate an object of type Answer
* 5 arrays are created to receive the attributes of each answer belonging to a specified question
* @package chamilo.exercise
* @author Olivier Brouckaert
* @version $Id: answer.class.php 21172 2009-06-01 20:58:05Z darkvela $
*/
/**
* Code
*/
/**
* Answer class
* @package chamilo.exercise
* Class Answer
* Allows to instantiate an object of type Answer
* 5 arrays are created to receive the attributes of each answer belonging to a specified question
* @package chamilo.exercise
* @author Olivier Brouckaert
* @package chamilo.exercise
*/
class Answer
{

@ -1,15 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Exercise class: This class allows to instantiate an object of type Exercise
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya Cleaning exercises
* Modified by Hubert Borderiou #294
*/
/**
* Code
*/
define('ALL_ON_ONE_PAGE', 1);
define('ONE_PER_PAGE', 2);
@ -28,6 +19,15 @@ $debug = false; //All exercise scripts should depend in this debug variable
require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php';
/**
* Class Exercise
*
* Allows to instantiate an object of type Exercise
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya Cleaning exercises
* Modified by Hubert Borderiou #294
*/
class Exercise
{
public $id;

@ -10,9 +10,7 @@
* @version $Id: exercise.lib.php 22247 2009-07-20 15:57:25Z ivantcholakov $
* Modified by Hubert Borderiou 2011-10-21 Question Category
*/
/**
* Code
*/
// The initialization class for the online editor is needed here.
require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
@ -25,7 +23,18 @@ require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
* @param int current item from the list of questions
* @param int number of total questions
* */
function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false) {
function showQuestion(
$questionId,
$only_questions = false,
$origin = false,
$current_item = '',
$show_title = true,
$freeze = false,
$user_choice = array(),
$show_comment = false,
$exercise_feedback = null,
$show_answers = false
) {
// Text direction for the current language
$is_ltr_text_direction = api_get_text_direction() != 'rtl';
@ -214,7 +223,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
}
}
for ($answerId=1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
@ -829,7 +837,12 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
return $nbrAnswers;
}
function get_exercise_track_exercise_info($exe_id) {
/**
* @param int $exe_id
* @return array
*/
function get_exercise_track_exercise_info($exe_id)
{
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_COURSE = Database::get_main_table(TABLE_MAIN_COURSE);
@ -855,7 +868,8 @@ function get_exercise_track_exercise_info($exe_id) {
/**
* Validates the time control key
*/
function exercise_time_control_is_valid($exercise_id, $lp_id = 0 , $lp_item_id = 0) {
function exercise_time_control_is_valid($exercise_id, $lp_id = 0 , $lp_item_id = 0)
{
$course_id = api_get_course_int_id();
$exercise_id = intval($exercise_id);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -937,8 +951,15 @@ function get_count_exam_hotpotatoes_results($in_hotpot_path) {
* @param null $where_condition
* @return array|int
*/
function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_column, $in_direction, $in_hotpot_path, $in_get_count = false, $where_condition = null)
{
function get_exam_results_hotpotatoes_data(
$in_from,
$in_number_of_items,
$in_column,
$in_direction,
$in_hotpot_path,
$in_get_count = false,
$where_condition = null
) {
$course_code = api_get_course_id();
// by default in_column = 1 If parameters given, it is the name of the column witch is the bdd field name
if ($in_column == 1) {
@ -999,8 +1020,15 @@ function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_co
* Gets the exam'data results
* @todo this function should be moved in a library + no global calls
*/
function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
{
function get_exam_results_data(
$from,
$number_of_items,
$column,
$direction,
$exercise_id,
$extra_where_conditions = null,
$get_count = false
) {
//@todo replace all this globals
global $documentPath, $filter;
@ -1228,8 +1256,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
}
$sizeof = count($results);
$user_list_id = array ();
$user_list_id = array();
$locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
//Looping results

@ -16,7 +16,8 @@ class ExerciseResult
/**
* constructor of the class
*/
public function ExerciseResult($get_questions=false,$get_answers=false) {
public function ExerciseResult($get_questions = false, $get_answers = false)
{
}
/**
@ -264,6 +265,7 @@ class ExerciseResult
$this->results = $return;
return true;
}
/**
* Exports the complete report as a CSV file
* @param string Document path inside the document tool
@ -391,7 +393,14 @@ class ExerciseResult
* Exports the complete report as an XLS file
* @return boolean False on error
*/
public function exportCompleteReportXLS($document_path='',$user_id = null, $export_user_fields= false, $export_filter = 0, $exercise_id=0, $hotpotato_name = null) {
public function exportCompleteReportXLS(
$document_path = '',
$user_id = null,
$export_user_fields = false,
$export_filter = 0,
$exercise_id = 0,
$hotpotato_name = null
) {
global $charset;
$this->_getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_'.date('YmdGis').'.xls';

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* Class FillBlanks
*
* @author Eric Marguin

@ -1,75 +1,70 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the FreeAnswer class.
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
* @package chamilo.exercise
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**
* Code
*/
if (!class_exists('FreeAnswer')):
class FreeAnswer extends Question
{
static $typePicture = 'open_answer.gif';
static $explanationLangVar = 'FreeAnswer';
/**
* @package chamilo.exercise
* Constructor
*/
class FreeAnswer extends Question {
static $typePicture = 'open_answer.gif';
static $explanationLangVar = 'FreeAnswer';
/**
* Constructor
*/
function FreeAnswer() {
parent::question();
$this->type = FREE_ANSWER;
$this->isContent = $this->getIsContent();
}
function FreeAnswer()
{
parent::question();
$this->type = FREE_ANSWER;
$this->isContent = $this->getIsContent();
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm($form) {
$form->addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1'));
global $text, $class;
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1)));
} else {
if ($this->isContent == 1) {
$form->setDefaults(array('weighting' => '10'));
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm($form)
{
$form->addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1'));
global $text, $class;
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1)));
} else {
if ($this->isContent == 1) {
$form->setDefaults(array('weighting' => '10'));
}
}
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form) {
$this->weighting = $form->getSubmitValue('weighting');
$this->save();
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param FormValidator
*/
function processAnswersCreation($form)
{
$this->weighting = $form->getSubmitValue('weighting');
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
if (!empty($score['comments']) || $score['score'] > 0) {
$score['revised'] = true;
} else {
$score['revised'] = false;
}
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="' . $this->question_table_class . '" >
<tr>
<th>' . get_lang("Answer") . '</th>
</tr>';
return $header;
function return_header($feedback_type = null, $counter = null, $score = null)
{
if (!empty($score['comments']) || $score['score'] > 0) {
$score['revised'] = true;
} else {
$score['revised'] = false;
}
}
endif;
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="' . $this->question_table_class . '" >
<tr>
<th>' . get_lang("Answer") . '</th>
</tr>';
return $header;
}
}

@ -1,18 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the HotSpot class.
* @package chamilo.exercise
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**
* Code
*/
if(!class_exists('HotSpot')):
/**
CLASS HotSpot
* Class HotSpot
*
* This class allows to instantiate an object of type HotSpot (MULTIPLE CHOICE, UNIQUE ANSWER),
* extending the class question
@ -20,9 +10,8 @@ if(!class_exists('HotSpot')):
* @author Eric Marguin
* @package chamilo.exercise
**/
class HotSpot extends Question {
class HotSpot extends Question
{
static $typePicture = 'hotspot.gif';
static $explanationLangVar = 'HotSpot';
@ -85,9 +74,10 @@ class HotSpot extends Question {
}
/**
* @package chamilo.exercise
* Class HotSpotDelineation
*/
class HotSpotDelineation extends HotSpot {
class HotSpotDelineation extends HotSpot
{
static $typePicture = 'hotspot_delineation.gif';
static $explanationLangVar = 'HotspotDelineation';
@ -115,4 +105,4 @@ class HotSpotDelineation extends HotSpot {
parent::processAnswersCreation ($form);
}
}
endif;

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */
/**
*
* Class Matching
* Matching questions type class
*

@ -1,7 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
CLASS MultipleAnswer
* Class MultipleAnswer
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question

@ -1,10 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Code
*/
/**
CLASS MultipleAnswer
* Class MultipleAnswer
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
@ -12,8 +9,8 @@
* @author Eric Marguin
* @package chamilo.exercise
**/
class MultipleAnswerCombination extends Question {
class MultipleAnswerCombination extends Question
{
static $typePicture = 'mcmac.gif';
static $explanationLangVar = 'MultipleSelectCombination';
@ -21,7 +18,8 @@ class MultipleAnswerCombination extends Question {
/**
* Constructor
*/
function MultipleAnswerCombination(){
function MultipleAnswerCombination()
{
parent::question();
$this -> type = MULTIPLE_ANSWER_COMBINATION;
$this -> isContent = $this-> getIsContent();
@ -29,10 +27,11 @@ class MultipleAnswerCombination extends Question {
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
* @param $form FormValidator
* @param the answers number to display
*/
function createAnswersForm ($form) {
function createAnswersForm ($form)
{
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$obj_ex = $_SESSION['objExercise'];
@ -57,7 +56,7 @@ class MultipleAnswerCombination extends Question {
if(!empty($this -> id)) {
$answer = new Answer($this -> id);
$answer -> read();
if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) {
if (count($answer->nbrAnswers)>0 && !$form->isSubmitted()) {
$nb_answers = $answer->nbrAnswers;
}
}
@ -93,7 +92,6 @@ class MultipleAnswerCombination extends Question {
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer['.$i.']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment['.$i.']');
$answer_number=$form->addElement('text', 'counter['.$i.']', null,'value="'.$i.'"');
$answer_number->freeze();
@ -131,11 +129,10 @@ class MultipleAnswerCombination extends Question {
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
$form->addElement('style_submit_button', 'submitQuestion',$text, 'class="'.$class.'"');
// setting the save button here and not in the question class.php
}
}
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
$renderer->setElementTemplate('{element}&nbsp;','submitQuestion');
$renderer->setElementTemplate('{element}&nbsp;','moreAnswers');
@ -157,8 +154,8 @@ class MultipleAnswerCombination extends Question {
* @param the formvalidator instance
* @param the answers number to display
*/
function processAnswersCreation($form) {
function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id);
@ -197,7 +194,8 @@ class MultipleAnswerCombination extends Question {
$this -> save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
function return_header($feedback_type = null, $counter = null, $score = null)
{
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'">
<tr>

@ -1,10 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Code
*/
/**
CLASS MultipleAnswer
* Class MultipleAnswer
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question

@ -1,10 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class MultipleAnswerTrueFalse
* This class allows to instantiate an object of type MULTIPLE_ANSWER
* (MULTIPLE CHOICE, MULTIPLE ANSWER), extending the class question
* @author Julio Montoya
* @author Julio Montoya
*
* @package chamilo.exercise
*/

@ -1,24 +1,22 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Code
*/
/**
* File containing the FreeAnswer class.
* Class OralExpression
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
* @author Eric Marguin
* @package chamilo.exercise
*/
class OralExpression extends Question {
class OralExpression extends Question
{
static $typePicture = 'audio_question.png';
static $explanationLangVar = 'OralExpression';
/**
* Constructor
*/
function OralExpression(){
function OralExpression()
{
parent::question();
$this -> type = ORAL_EXPRESSION;
$this -> isContent = $this-> getIsContent();
@ -26,9 +24,10 @@ class OralExpression extends Question {
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
* @param $form FormValidator
*/
function createAnswersForm ($form) {
function createAnswersForm ($form)
{
$form -> addElement('text','weighting',get_lang('Weighting'), array('class' => 'span1'));
global $text, $class;
// setting the save button here and not in the question class.php
@ -46,12 +45,14 @@ class OralExpression extends Question {
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form) {
function processAnswersCreation($form)
{
$this->weighting = $form -> getSubmitValue('weighting');
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
function return_header($feedback_type = null, $counter = null, $score = null)
{
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
@ -63,6 +64,7 @@ class OralExpression extends Question {
<tr>
<th>&nbsp;</th>
</tr>';
return $header;
}
}

@ -1,15 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the Question class.
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya <gugli100@gmail.com> lot of bug fixes
* Modified by hubert.borderiou@grenet.fr - add question categories
*/
/**
* Code
*/
// Question types
define('UNIQUE_ANSWER', 1);
@ -35,13 +25,15 @@ define('MCMA', 2);
define('FIB', 3);
/**
QUESTION CLASS
* Class Question
*
* This class allows to instantiate an object of type Question
*
* @author Olivier Brouckaert, original author
* @author Patrick Cool, LaTeX support
* @package chamilo.exercise
* @author Olivier Brouckaert, original author
* @author Patrick Cool, LaTeX support
* @author Julio Montoya <gugli100@gmail.com> lot of bug fixes
* @author hubert.borderiou@grenet.fr - add question categories
* @package chamilo.exercise
*/
abstract class Question
{
@ -101,7 +93,8 @@ abstract class Question
$this->parent_id = 0;
}
public function getIsContent() {
public function getIsContent()
{
$isContent = null;
if (isset($_REQUEST['isContent'])) {
$isContent = intval($_REQUEST['isContent']);
@ -117,7 +110,8 @@ abstract class Question
*
* @return Question
*/
static function read($id, $course_id = null) {
static function read($id, $course_id = null)
{
$id = intval($id);
if (!empty($course_id)) {
@ -167,9 +161,11 @@ abstract class Question
$objQuestion->exerciseList[] = $obj->exercice_id;
}
}
return $objQuestion;
}
}
// question not found
return false;
}
@ -180,7 +176,8 @@ abstract class Question
* @author Olivier Brouckaert
* @return - integer - question ID
*/
function selectId() {
function selectId()
{
return $this->id;
}
@ -190,7 +187,8 @@ abstract class Question
* @author Olivier Brouckaert
* @return string - question title
*/
function selectTitle() {
function selectTitle()
{
return $this->question;
}
@ -200,7 +198,8 @@ abstract class Question
* @author Olivier Brouckaert
* @return string - question description
*/
function selectDescription() {
function selectDescription()
{
$this->description=text_filter($this->description);
return $this->description;
}
@ -222,7 +221,8 @@ abstract class Question
* @author Olivier Brouckaert
* @return integer - question position
*/
function selectPosition() {
function selectPosition()
{
return $this->position;
}
@ -232,7 +232,8 @@ abstract class Question
* @author Olivier Brouckaert
* @return integer - answer type
*/
function selectType() {
function selectType()
{
return $this->type;
}
@ -242,7 +243,8 @@ abstract class Question
* @author Nicolas Raynaud
* @return integer - level of the question, 0 by default.
*/
function selectLevel() {
function selectLevel()
{
return $this->level;
}
@ -252,11 +254,13 @@ abstract class Question
* @author Olivier Brouckaert
* @return string - picture name
*/
function selectPicture() {
function selectPicture()
{
return $this->picture;
}
function selectPicturePath() {
function selectPicturePath()
{
if (!empty($this->picture)) {
return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->picture;
}
@ -269,7 +273,8 @@ abstract class Question
* @author Olivier Brouckaert
* @return array - list of exercise ID which the question is in
*/
function selectExerciseList() {
function selectExerciseList()
{
return $this->exerciseList;
}
@ -360,7 +365,8 @@ abstract class Question
foreach ($category_list as $category_id) {
$category_id = intval($category_id);
$question_id = Database::escape_string($this->id);
$sql = "SELECT count(*) AS nb FROM $TBL_QUESTION_REL_CATEGORY WHERE category_id = $category_id AND question_id = $question_id AND c_id=".api_get_course_int_id();
$sql = "SELECT count(*) AS nb FROM $TBL_QUESTION_REL_CATEGORY
WHERE category_id = $category_id AND question_id = $question_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql);
$row = Database::fetch_array($res);
if ($row['nb'] > 0) {
@ -369,7 +375,7 @@ abstract class Question
//$res = Database::query($sql);
} else {
$sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id) VALUES (".api_get_course_int_id().", $question_id, $category_id)";
$res = Database::query($sql);
Database::query($sql);
}
}
}
@ -377,11 +383,12 @@ abstract class Question
/**
* @author Hubert Borderiou 12-10-2011
* @param int $in_positive
* @param int $in_category
* in this version, a question can only have 1 category
* if category is 0, then question has no category then delete the category entry
*/
function saveCategory($in_category) {
function saveCategory($in_category)
{
if ($in_category <= 0) {
$this->deleteCategory();
} else {
@ -390,15 +397,16 @@ abstract class Question
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$category_id = Database::escape_string($in_category);
$question_id = Database::escape_string($this->id);
$sql = "SELECT count(*) AS nb FROM $TBL_QUESTION_REL_CATEGORY WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
$sql = "SELECT count(*) AS nb FROM $TBL_QUESTION_REL_CATEGORY
WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql);
$row = Database::fetch_array($res);
if ($row['nb'] > 0){
$sql = "UPDATE $TBL_QUESTION_REL_CATEGORY SET category_id=$category_id WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql);
Database::query($sql);
} else {
$sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY VALUES (".api_get_course_int_id().", $question_id, $category_id)";
$res = Database::query($sql);
Database::query($sql);
}
}
}
@ -409,10 +417,12 @@ abstract class Question
* @param : none
* delte the category for question
*/
function deleteCategory() {
function deleteCategory()
{
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$question_id = Database::escape_string($this->id);
$sql = "DELETE FROM $TBL_QUESTION_REL_CATEGORY WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
$sql = "DELETE FROM $TBL_QUESTION_REL_CATEGORY
WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
Database::query($sql);
}
@ -422,7 +432,8 @@ abstract class Question
* @author Olivier Brouckaert
* @param integer $position - question position
*/
function updatePosition($position) {
function updatePosition($position)
{
$this->position=$position;
}
@ -432,7 +443,8 @@ abstract class Question
* @author Nicolas Raynaud
* @param integer $level - question level
*/
function updateLevel($level) {
function updateLevel($level)
{
$this->level=$level;
}
@ -443,7 +455,8 @@ abstract class Question
* @author Olivier Brouckaert
* @param integer $type - answer type
*/
function updateType($type) {
function updateType($type)
{
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$course_id = $this->course['real_id'];
@ -471,7 +484,8 @@ abstract class Question
* @param string $PictureName - Name of the picture
* @return boolean - true if uploaded, otherwise false
*/
function uploadPicture($Picture, $PictureName, $picturePath = null) {
function uploadPicture($Picture, $PictureName, $picturePath = null)
{
if (empty($picturePath)) {
global $picturePath;
}
@ -498,6 +512,7 @@ abstract class Question
return api_item_property_update($this->course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', api_get_user_id());
}
}
return false;
}
@ -509,11 +524,12 @@ abstract class Question
* @param integer $Max - Maximum size
* @return boolean - true if success, false if failed
*/
function resizePicture($Dimension, $Max) {
function resizePicture($Dimension, $Max)
{
global $picturePath;
// if the question has an ID
if($this->id) {
if ($this->id) {
// Get dimensions from current image.
$my_image = new Image($picturePath.'/'.$this->picture);

@ -1,9 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/** @author hubert.borderiou **/
/**
* Class Testcategory
* @author hubert.borderiou
* @todo rename to ExerciseCategory
*/
class Testcategory

@ -1,7 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* UNIQUE_ANSWER class
* Class UniqueAnswer
*
* This class allows to instantiate an object of type UNIQUE_ANSWER
* (MULTIPLE CHOICE, UNIQUE ANSWER),

@ -2,26 +2,14 @@
/* For licensing terms, see /license.txt */
/**
* File containing the UNIQUE_ANSWER class.
* @package chamilo.exercise
* @author Eric Marguin
*/
/**
* Code
*/
/**
CLASS UNIQUE_ANSWER
* Class UniqueAnswerNoOption
* Allows to instantiate an object of type UNIQUE_ANSWER (MULTIPLE CHOICE, UNIQUE ANSWER),
* extending the class question
* @author Eric Marguin
* @author Julio Montoya
* @package chamilo.exercise
*
* This class allows to instantiate an object of type UNIQUE_ANSWER (MULTIPLE CHOICE, UNIQUE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @author Julio Montoya
* @package chamilo.exercise
**/
*/
class UniqueAnswerNoOption extends Question
{
static $typePicture = 'mcuao.gif';
@ -30,7 +18,8 @@ class UniqueAnswerNoOption extends Question
/**
* Constructor
*/
function UniqueAnswerNoOption(){
function UniqueAnswerNoOption()
{
//this is highly important
parent::question();
$this -> type = UNIQUE_ANSWER_NO_OPTION;
@ -42,7 +31,8 @@ class UniqueAnswerNoOption extends Question
* @param the formvalidator instance
* @param the answers number to display
*/
function createAnswersForm ($form) {
function createAnswersForm ($form)
{
// getting the exercise list
$obj_ex = $_SESSION['objExercise'];
@ -277,10 +267,7 @@ class UniqueAnswerNoOption extends Question
}
$form->addElement('hidden', 'nb_answers');
$form->setConstants(array('nb_answers' => $nb_answers));
}
@ -289,8 +276,8 @@ class UniqueAnswerNoOption extends Question
* @param the formvalidator instance
* @param the answers number to display
*/
function processAnswersCreation($form) {
function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form -> getSubmitValue('correct');
$objAnswer = new Answer($this->id);
@ -307,9 +294,6 @@ class UniqueAnswerNoOption extends Question
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
$scenario = $form -> getSubmitValue('scenario');
//
//$list_destination = $form -> getSubmitValue('destination'.$i);
//$destination_str = $form -> getSubmitValue('destination'.$i);
@ -386,7 +370,8 @@ class UniqueAnswerNoOption extends Question
$this -> save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
function return_header($feedback_type = null, $counter = null, $score = null)
{
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'">
<tr>

Loading…
Cancel
Save