Fixed \"Exercises with content\" - see CT#514

skala
Ronny Velasquez 15 years ago
parent 203991f548
commit 8836644805
  1. 15
      main/exercice/fill_blanks.class.php
  2. 8
      main/exercice/freeanswer.class.php
  3. 16
      main/exercice/matching.class.php
  4. 15
      main/exercice/multiple_answer.class.php
  5. 13
      main/exercice/multiple_answer_combination.class.php
  6. 21
      main/exercice/question.class.php
  7. 5
      main/exercice/question_create.php
  8. 14
      main/exercice/unique_answer.class.php

@ -36,6 +36,7 @@ class FillBlanks extends Question
{
parent::question();
$this -> type = FILL_IN_BLANKS;
$this -> isContent = $this-> getIsContent();
}
/**
@ -45,7 +46,7 @@ class FillBlanks extends Question
function createAnswersForm ($form)
{
$defaults = array();
if(!empty($this->id)) {
$objAnswer = new answer($this->id);
@ -148,10 +149,14 @@ class FillBlanks extends Question
global $text, $class;
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
$form -> setDefaults($defaults);
if (!empty($this -> id)) {
$form -> setDefaults($defaults);
} else {
if ($this -> isContent == 1) {
$form -> setDefaults($defaults);
}
}
}

@ -41,6 +41,7 @@ class FreeAnswer extends Question {
function FreeAnswer(){
parent::question();
$this -> type = FREE_ANSWER;
$this -> isContent = $this-> getIsContent();
}
/**
@ -53,11 +54,12 @@ class FreeAnswer extends Question {
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)) {
if (!empty($this->id)) {
$form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
} else {
$form -> setDefaults(array('weighting' => '10'));
if ($this -> isContent == 1) {
$form -> setDefaults(array('weighting' => '10'));
}
}
}

@ -34,6 +34,7 @@ class Matching extends Question {
function Matching(){
parent::question();
$this -> type = MATCHING;
$this -> isContent = $this-> getIsContent();
}
/**
@ -210,13 +211,18 @@ class Matching extends Question {
$group[] = FormValidator :: createElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
}
$form -> addGroup($group);
$form -> setDefaults($defaults);
if (!empty($this -> id)) {
$form -> setDefaults($defaults);
} else {
if ($this -> isContent == 1) {
$form -> setDefaults($defaults);
}
}
$form->setConstants(array('nb_matches' => $nb_matches,'nb_options' => $nb_options));
}

@ -31,6 +31,7 @@ class MultipleAnswer extends Question {
function MultipleAnswer(){
parent::question();
$this -> type = MULTIPLE_ANSWER;
$this -> isContent = $this-> getIsContent();
}
/**
@ -156,12 +157,18 @@ class MultipleAnswer extends Question {
$renderer->setElementTemplate('{element} ','submitQuestion');
$renderer->setElementTemplate('{element}','moreAnswers');
$form -> addElement ('html', '</div></div>');
$defaults['correct'] = $correct;
$form -> setDefaults($defaults);
if (!empty($this -> id)) {
$form -> setDefaults($defaults);
} else {
if ($this -> isContent == 1) {
$form -> setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}

@ -31,6 +31,7 @@ class MultipleAnswerCombination extends Question {
function MultipleAnswerCombination(){
parent::question();
$this -> type = MULTIPLE_ANSWER_COMBINATION;
$this -> isContent = $this-> getIsContent();
}
/**
@ -39,7 +40,6 @@ class MultipleAnswerCombination extends Question {
* @param the answers number to display
*/
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'];
@ -162,12 +162,15 @@ class MultipleAnswerCombination extends Question {
$renderer->setElementTemplate('{element}&nbsp;','submitQuestion');
$renderer->setElementTemplate('{element}','moreAnswers');
$form -> addElement ('html', '</div></div>');
$defaults['correct'] = $correct;
$form -> setDefaults($defaults);
if (!empty($this->id)) {
$form -> setDefaults($defaults);
} else {
if ($this -> isContent == 1) {
$form -> setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}

@ -41,7 +41,8 @@ abstract class Question
var $level;
var $picture;
var $exerciseList; // array with the list of exercises which this question is in
private $isContent;
static $typePicture = 'new_question.png';
static $explanationLangVar = '';
static $questionTypes = array(
@ -69,6 +70,11 @@ abstract class Question
$this->level = 1;
$this->exerciseList=array();
}
public function getIsContent() {
$isContent = intval($_REQUEST['isContent']);
return $this->isContent = $isContent;
}
/**
* Reads question informations from the data base
@ -996,7 +1002,10 @@ abstract class Question
$renderer->setElementTemplate('<div class="row"><div class="label">{label}</div><div class="formw" >{element}</div></div>','questionName');
$renderer->setElementTemplate('<div class="row"><div class="label">{label}</div><div class="formw">{element}</div></div>','questionLevel');
$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
// default content
$isContent = intval($_REQUEST['isContent']);
// question type
$answerType= intval($_REQUEST['answerType']);
$form->addElement('hidden','answerType',$_REQUEST['answerType']);
@ -1038,7 +1047,13 @@ abstract class Question
$defaults['questionName'] = $this -> question;
$defaults['questionDescription'] = $this -> description;
$defaults['questionLevel'] = $this -> level;
$form -> setDefaults($defaults);
if (!empty($_REQUEST['myid'])) {
$form -> setDefaults($defaults);
} else {
if ($isContent == 1) {
$form -> setDefaults($defaults);
}
}
}
/**

@ -54,6 +54,9 @@ while ($row = Database :: fetch_array($result)) {
}
$form->addElement('select', 'exercice', get_lang('Exercice'), $exercises);
// generate default content
$form->addElement('checkbox', 'is_content', get_lang('DefaultContent'), null, array('checked' => true));
// the submit button
$form->addElement('style_submit_button', 'SubmitCreateQuestion', get_lang('CreateQuestion'), 'class="add"');
@ -74,7 +77,7 @@ if ($form->validate()) {
$answer_type = $question_type_id;
}
}
header('Location: admin.php?exerciseId='.$values['exercice'].'&newQuestion=yes&answerType='.$answer_type);
header('Location: admin.php?exerciseId='.$values['exercice'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type);
exit;
} else {
// header

@ -34,6 +34,7 @@ class UniqueAnswer extends Question {
//this is highly important
parent::question();
$this -> type = UNIQUE_ANSWER;
$this -> isContent = $this-> getIsContent();
}
/**
@ -44,7 +45,7 @@ class UniqueAnswer extends Question {
function createAnswersForm ($form) {
// getting the exercise list
$obj_ex =$_SESSION['objExercise'];
$editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
//this line define how many question by default appear when creating a choice question
@ -266,10 +267,15 @@ class UniqueAnswer extends Question {
$correct=1;
}
$defaults['correct'] = $correct;
$form -> setDefaults($defaults);
if (!empty($this -> id)) {
$form -> setDefaults($defaults);
} else {
if ($this -> isContent == 1) {
$form -> setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}

Loading…
Cancel
Save