Removing use of global to set submit button attrinutes. submitText and submitClass variables added in the Question class.

skala
Julio Montoya 13 years ago
parent 179d83e617
commit 35afbdd043
  1. 16
      main/exercice/admin.php
  2. 7
      main/exercice/draggable.class.php
  3. 5
      main/exercice/fill_blanks.class.php
  4. 5
      main/exercice/freeanswer.class.php
  5. 7
      main/exercice/global_multiple_answer.class.php
  6. 27
      main/exercice/hotspot.class.php
  7. 7
      main/exercice/matching.class.php
  8. 9
      main/exercice/multiple_answer.class.php
  9. 5
      main/exercice/multiple_answer_combination.class.php
  10. 7
      main/exercice/multiple_answer_true_false.class.php
  11. 6
      main/exercice/oral_expression.class.php
  12. 4
      main/exercice/question.class.php
  13. 17
      main/exercice/question_admin.inc.php
  14. 9
      main/exercice/unique_answer.class.php
  15. 8
      main/exercice/unique_answer_image.class.php
  16. 8
      main/exercice/unique_answer_no_option.class.php
  17. 9
      src/ChamiloLMS/Controller/Admin/QuestionManager/QuestionManagerController.php

@ -113,7 +113,7 @@ if (empty($modifyExercise)) {
$modifyExercise = isset($_GET['modifyExercise'])?$_GET['modifyExercise']:0;
}
//Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc
// Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc
delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_int_id(), api_get_session_id());
@ -174,7 +174,7 @@ if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['
exit; //otherwise following clicks may become buggy
}
// intializes the Exercise object
// Initializes the Exercise object.
if (!is_object($objExercise)) {
// construction of the Exercise object
$objExercise = new Exercise();
@ -187,7 +187,7 @@ if (!is_object($objExercise)) {
Session::write('objExercise', $objExercise);
}
// doesn't select the exercise ID if we come from the question pool
// Doesn't select the exercise ID if we come from the question pool
if (!isset($fromExercise) or !$fromExercise) {
// gets the right exercise ID, and if 0 creates a new exercise
if (!$exerciseId = $objExercise->selectId()) {
@ -197,7 +197,7 @@ if (!isset($fromExercise) or !$fromExercise) {
$nbrQuestions = $objExercise->selectNbrQuestions();
// intializes the Question object
// Initializes the Question object
if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
if ($editQuestion || $newQuestion) {
@ -212,14 +212,14 @@ if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
}
}
// checks if the object exists
// Checks if the object exists.
if (is_object($objQuestion)) {
// gets the question ID
$questionId = $objQuestion->selectId();
}
}
// if cancelling an exercise
// If cancelling an exercise.
if (!empty($cancelExercise)) {
// existing exercise
if ($exerciseId) {
@ -558,7 +558,7 @@ if ($newQuestion || $editQuestion) {
$type = Security::remove_XSS($_REQUEST['answerType']);
}
echo '<input type="hidden" name="Type" value="'.$type.'" />';
//Create/Edit question
// Create/Edit question.
require 'question_admin.inc.php';
}
@ -589,4 +589,4 @@ if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspot
Session::write('objExercise', $objExercise);
Session::write('objQuestion', $objQuestion);
Session::write('objAnswer', $objAnswer);
Display::display_footer();
Display::display_footer();

@ -152,12 +152,9 @@ class Draggable extends Matching
'class="btn minus"'
);
global $text, $class;
$group[] = $form->createElement('style_submit_button', 'submitQuestion', $text, 'class="'.$class.'"');
$group[] = $form->createElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
$form->addGroup($group);
$form->addElement('html', '</table></div></div>');
if (!empty($this->id)) {
$form->setDefaults($defaults);
} else {
@ -218,4 +215,4 @@ class Draggable extends Matching
</tr>';
return $header;
}
}
}

@ -136,9 +136,8 @@ class FillBlanks extends Question
$form -> addElement('html','<div id="blanks_weighting"></div>');
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->addElement('style_submit_button','submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
if (!empty($this -> id)) {
$form -> setDefaults($defaults);
@ -199,4 +198,4 @@ class FillBlanks extends Question
</tr>';
return $header;
}
}
}

@ -36,9 +36,8 @@ class FreeAnswer extends Question {
*/
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 . '"');
$form->addElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="' . $this->submitClass . '"');
if (!empty($this->id)) {
$form->setDefaults(array('weighting' => Text::float_format($this->weighting, 1)));
} else {
@ -70,4 +69,4 @@ class FreeAnswer extends Question {
</tr>';
return $header;
}
}
}

@ -145,18 +145,17 @@ class GlobalMultipleAnswer extends Question
$form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
$navigator_info = api_get_navigator();
global $text, $class;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="plus"');
$form->addElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
$form->addElement('submit', 'submitQuestion', $this->submitText, 'class="' . $this->submitClass . '"');
} else {
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'), 'class="minus"');
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'), 'class="plus"');
$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
$form->addElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="' . $this->submitClass . '"');
// setting the save button here and not in the question class.php
}
}
@ -251,4 +250,4 @@ class GlobalMultipleAnswer extends Question
$header .= '</tr>';
return $header;
}
}
}

@ -31,25 +31,24 @@ class HotSpot extends Question {
function display() {
}
function createForm (&$form, $fck_config=0) {
parent::createForm ($form, $fck_config);
global $text, $class;
if(!isset($_GET['editQuestion'])) {
$renderer = $form->defaultRenderer();
$renderer = $form->defaultRenderer();
$form->addElement('file','imageUpload',array('<img src="../img/hotspots.png" />', get_lang('UploadJpgPicture')) );
// setting the save button here and not in the question class.php
// Saving a question
$form->addElement('style_submit_button','submitQuestion',get_lang('GoToQuestion'), 'class="'.$class.'"');
$form->addElement('style_submit_button','submitQuestion',get_lang('GoToQuestion'), 'class="'.$this->submitClass.'"');
$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
} else {
// setting the save button here and not in the question class.php
// Editing a question
$form->addElement('style_submit_button','submitQuestion',get_lang('ModifyExercise'), 'class="'.$class.'"');
$form->addElement('style_submit_button','submitQuestion',get_lang('ModifyExercise'), 'class="'.$this->submitClass.'"');
}
}
function processCreation ($form, $objExercise = null) {
@ -58,18 +57,18 @@ class HotSpot extends Question {
if(!empty($file_info['tmp_name'])) {
$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
global $picturePath;
//fixed width ang height
if (file_exists($picturePath.'/'.$this->picture)) {
//fixed width ang height
if (file_exists($picturePath.'/'.$this->picture)) {
list($width,$height) = @getimagesize($picturePath.'/'.$this->picture);
if($width>$height) {
$this->resizePicture('width',545);
} else {
$this->resizePicture('height',350);
}
$this->save();
$this->save();
} else {
return false;
}
}
}
}
@ -95,16 +94,16 @@ class HotSpotDelineation extends HotSpot {
$this -> type = HOT_SPOT_DELINEATION;
}
function createForm (&$form, $fck_config=0) {
parent::createForm ($form, $fck_config);
parent::createForm ($form, $fck_config);
}
function processCreation ($form, $objExercise = null) {
$file_info = $form -> getSubmitValue('imageUpload');
parent::processCreation ($form, $objExercise);
}
function createAnswersForm ($form) {
parent::createAnswersForm ($form);
}
@ -112,4 +111,4 @@ class HotSpotDelineation extends HotSpot {
function processAnswersCreation ($form) {
parent::processAnswersCreation ($form);
}
}
}

@ -193,18 +193,17 @@ class Matching extends Question
$form->addElement('html', '</table></div></div>');
$group = array();
global $text, $class;
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
// setting the save button here and not in the question class.php
$group[] = $form->createElement('submit', 'submitQuestion', $text, 'class="'.$class.'"');
$group[] = $form->createElement('submit', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
$group[] = $form->createElement('submit', 'lessOptions', get_lang('DelElem'), 'class="minus"');
$group[] = $form->createElement('submit', 'moreOptions', get_lang('AddElem'), 'class="plus"');
} else {
// setting the save button here and not in the question class.php
$group[] = $form->createElement('style_submit_button', 'lessOptions', get_lang('DelElem'), 'class="minus"');
$group[] = $form->createElement('style_submit_button', 'moreOptions', get_lang('AddElem'), ' class="plus"');
$group[] = $form->createElement('style_submit_button', 'submitQuestion', $text, 'class="'.$class.'"');
$group[] = $form->createElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
}
$form->addGroup($group);
@ -274,4 +273,4 @@ class Matching extends Question
}
return $header;
}
}
}

@ -132,22 +132,19 @@ class MultipleAnswer extends Question {
$form -> addElement ('html', '<br />');
$form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required');
$navigator_info = api_get_navigator();
global $text, $class;
if ($obj_ex->edit_exercise_in_lp == true) {
//ie6 fix
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
$form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('submit','submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
} else {
// setting the save button here and not in the question class.php
$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.'"');
$form->addElement('style_submit_button','submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
}
}
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
@ -220,4 +217,4 @@ class MultipleAnswer extends Question {
$header .= '</tr>';
return $header;
}
}
}

@ -130,19 +130,18 @@ class MultipleAnswerCombination extends Question
$form->addElement('text', 'weighting[1]', get_lang('Score'), array('class' => "span1", 'value' => '10'));
$navigator_info = api_get_navigator();
global $text, $class;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
$form->addElement('submit', 'submitQuestion', $text, 'class="'.$class.'"');
$form->addElement('submit', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
} else {
$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.'"');
$form->addElement('style_submit_button', 'submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
// setting the save button here and not in the question class.php

@ -178,20 +178,19 @@ class MultipleAnswerTrueFalse extends Question
$navigator_info = api_get_navigator();
global $text, $class;
if ($obj_ex->edit_exercise_in_lp == true) {
//ie6 fix
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
$form->addElement('submit', 'submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('submit', 'submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
} else {
// setting the save button here and not in the question class.php
$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.'"');
$form->addElement('style_submit_button', 'submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
}
}
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
@ -292,4 +291,4 @@ class MultipleAnswerTrueFalse extends Question
$header .= '</tr>';
return $header;
}
}
}

@ -35,9 +35,9 @@ class OralExpression extends Question
*/
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.'"');
$form->addElement('style_submit_button','submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
if (!empty($this->id)) {
$form -> setDefaults(array('weighting' => Text::float_format($this->weighting, 1)));
} else {
@ -70,4 +70,4 @@ class OralExpression extends Question
</tr>';
return $header;
}
}
}

@ -41,6 +41,8 @@ abstract class Question
public $editionMode = 'normal';
public $exercise; // exercise obj
public $setDefaultValues = false;
public $submitClass;
public $submitText;
public static $questionTypes = array(
UNIQUE_ANSWER => array('unique_answer.class.php', 'UniqueAnswer'),
@ -1971,4 +1973,4 @@ abstract class Question
return $labels;
}
}
}

@ -1,8 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script allows to manage the statements of questions.
* It is included from the script admin.php
* This script allows to manage the statements of questions.
* It is included from the script admin.php
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya
@ -31,18 +31,19 @@ if (is_object($objQuestion)) {
$form = new FormValidator('question_admin_form', 'post', $action);
if (isset($_GET['editQuestion'])) {
$class = "btn save";
$text = get_lang('ModifyQuestion');
$objQuestion->submitClass = "btn save";
$objQuestion->submitText = get_lang('ModifyQuestion');
} else {
$class = "btn add";
$text = get_lang('AddQuestionToExercise');
$objQuestion->submitClass = "btn add";
$objQuestion->submitText = get_lang('AddQuestionToExercise');
}
$types_information = Question::get_question_type_list();
$form_title_extra = get_lang($types_information[$type][1]);
// form title
$form->addElement('header', $text.': '.$form_title_extra);
$form->addElement('header', $objQuestion->submitText.': '.$form_title_extra);
if ($fastEdition) {
$form->setAllowRichEditorInForm(false);
@ -98,4 +99,4 @@ if (is_object($objQuestion)) {
// display the form
$form->display();
}
}
}

@ -273,19 +273,18 @@ class UniqueAnswer extends Question
$navigator_info = api_get_navigator();
global $text, $class;
// ie6 fix.
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"');
$form->addElement('submit', 'submitQuestion', $text, 'class="'.$class.'"');
$form->addElement('submit', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
} else {
//setting the save button here and not in the question class.php
$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.'"');
$form->addElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
}
}
$renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
@ -466,4 +465,4 @@ class UniqueAnswer extends Question
return $rs;
}
}
}
}

@ -264,19 +264,17 @@ class UniqueAnswerImage extends UniqueAnswer
$navigator_info = api_get_navigator();
global $text, $class;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"');
$form->addElement('submit', 'submitQuestion', $text, 'class="'.$class.'"');
$form->addElement('submit', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
} else {
//setting the save button here and not in the question class.php
$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.'"');
$form->addElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="'.$this->submitClass.'"');
}
}
$renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
@ -375,4 +373,4 @@ class UniqueAnswerImage extends UniqueAnswer
{
return parent::return_header($feedback_type, $counter, $score, $show_media);
}
}
}

@ -251,23 +251,21 @@ class UniqueAnswerNoOption extends Question
//}
$form -> addElement ('html', '</table>');
$form -> addElement ('html', '<br />');
$navigator_info = api_get_navigator();
global $text, $class;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="btn plus"');
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="btn minus"');
$form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('submit','submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
} else {
//setting the save button here and not in the question class.php
$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.'"');
$form->addElement('style_submit_button','submitQuestion',$this->submitText, 'class="'.$this->submitClass.'"');
}
}
$renderer->setElementTemplate('{element}&nbsp;','submitQuestion');
@ -413,4 +411,4 @@ class UniqueAnswerNoOption extends Question
$header .= '</tr>';
return $header;
}
}
}

@ -40,8 +40,17 @@ class QuestionManagerController
$app['extraJS'] = $extraJS;
$exercise = new \Exercise();
$exercise->edit_exercise_in_lp = true;
$class = "btn save";
$text = get_lang('ModifyQuestion');
/** @var \Question $question */
$question = \Question::read($id, null, $exercise);
$question->submitClass = "btn save";
$question->submitText = get_lang('ModifyQuestion');
$question->setDefaultValues = true;
$form = new \FormValidator('edit_question');
$question->createForm($form);

Loading…
Cancel
Save