From 86cbd5c58d93f96ae05263f50a3a58a286e9ad86 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 20 Dec 2010 16:04:50 +0100 Subject: [PATCH] Fixing order of buttons: add/deleting questions --- main/exercice/matching.class.php | 10 +-- main/exercice/multiple_answer.class.php | 4 +- .../multiple_answer_combination.class.php | 4 +- main/exercice/question.class.php | 16 ++-- main/exercice/question_admin.inc.php | 45 ++--------- main/exercice/unique_answer.class.php | 76 +++++++++---------- 6 files changed, 58 insertions(+), 97 deletions(-) diff --git a/main/exercice/matching.class.php b/main/exercice/matching.class.php index b34d8887f4..7c4696d00c 100755 --- a/main/exercice/matching.class.php +++ b/main/exercice/matching.class.php @@ -152,15 +152,14 @@ class Matching extends Question { $group[] = FormValidator :: createElement ('submit', 'lessMatches', get_lang('DelElem'),'class="minus"'); $group[] = FormValidator :: createElement ('submit', 'moreMatches', get_lang('AddElem'),'class="plus"'); } else { + $group[] = FormValidator :: createElement ('style_submit_button', 'moreMatches', get_lang('AddElem'),'class="plus"'); $group[] = FormValidator :: createElement ('style_submit_button', 'lessMatches', get_lang('DelElem'),'class="minus"'); - $group[] = FormValidator :: createElement ('style_submit_button', 'moreMatches', get_lang('AddElem'),'class="plus"'); + } $form -> addGroup($group); - //////////////////////// // DISPLAY OPTIONS //// - ////////////////////// $html='
@@ -209,8 +208,9 @@ class Matching extends Question { } else { // setting the save button here and not in the question class.php $group[] = FormValidator :: createElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"'); - $group[] = FormValidator :: createElement ('style_submit_button', 'moreOptions',get_lang('AddElem'),'class="plus"'); - $group[] = FormValidator :: createElement ('style_submit_button', 'lessOptions', get_lang('DelElem'),'class="minus"'); + $group[] = FormValidator :: createElement ('style_submit_button', 'lessOptions', get_lang('DelElem'),'style="float:right;" class="minus"'); + $group[] = FormValidator :: createElement ('style_submit_button', 'moreOptions',get_lang('AddElem'),'style="float:right;" class="plus"'); + diff --git a/main/exercice/multiple_answer.class.php b/main/exercice/multiple_answer.class.php index cf777f5130..6d4cbf102a 100755 --- a/main/exercice/multiple_answer.class.php +++ b/main/exercice/multiple_answer.class.php @@ -150,8 +150,8 @@ class MultipleAnswer extends Question { } else { // 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', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); - $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); + $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'style="float:right"; class="minus"'); + $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"'); } diff --git a/main/exercice/multiple_answer_combination.class.php b/main/exercice/multiple_answer_combination.class.php index cc2f81b6b0..c0b4501332 100755 --- a/main/exercice/multiple_answer_combination.class.php +++ b/main/exercice/multiple_answer_combination.class.php @@ -155,8 +155,8 @@ class MultipleAnswerCombination extends Question { } else { $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"'); - $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); - $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); + $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'style="float:right"; class="minus"'); + $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"'); // setting the save button here and not in the question class.php diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 47f0721100..9cb94865d9 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -907,12 +907,12 @@ abstract class Question function duplicate() { global $TBL_QUESTIONS, $picturePath; - $question=$this->question; - $description=$this->description; - $weighting=$this->weighting; - $position=$this->position; - $type=$this->type; - $level = intval($this->level); + $question = $this->question; + $description = $this->description; + $weighting = $this->weighting; + $position = $this->position; + $type = $this->type; + $level = intval($this->level); $sql="INSERT INTO $TBL_QUESTIONS(question, description, ponderation, position, type, level ) VALUES('".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."' ,'".Database::escape_string($level)."')"; Database::query($sql); @@ -950,8 +950,8 @@ abstract class Question function createForm (&$form,$fck_config=0) { echo ' '; diff --git a/main/exercice/question_admin.inc.php b/main/exercice/question_admin.inc.php index af1040228c..9133e1156a 100755 --- a/main/exercice/question_admin.inc.php +++ b/main/exercice/question_admin.inc.php @@ -5,15 +5,13 @@ * Statement (?) administration * This script allows to manage the statements of questions. * It is included from the script admin.php -* @package dokeos.exercise +* @package chamilo.exercise * @author Olivier Brouckaert * @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $ */ /* -============================================================================== INIT SECTION -============================================================================== */ require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; @@ -25,9 +23,7 @@ if(!defined('ALLOWED_TO_INCLUDE')) { } -/********************* - * INIT QUESTION - *********************/ +// INIT QUESTION if(isset($_GET['editQuestion'])) { $objQuestion = Question::read ($_GET['editQuestion']); @@ -49,34 +45,10 @@ if(isset($_GET['editQuestion'])) { } if(is_object($objQuestion)) { - - /********************* - * FORM STYLES - *********************/ - // if you have a better way to improve the display, please inform me e.marguin@elixir-interactive.com - $styles = ' - - '; - echo $styles; - - - /********************* - * INIT FORM - *********************/ + //INIT FORM $form = new FormValidator('question_admin_form','post',$action); - - - /********************* - * FORM CREATION - *********************/ - + //FORM CREATION + if(isset($_GET['editQuestion'])) { $class="save"; $text=get_lang('ModifyQuestion'); @@ -110,11 +82,8 @@ if(is_object($objQuestion)) { //$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"'); //$renderer = $form->defaultRenderer(); //$renderer->setElementTemplate('
{label}
{element}
','submitQuestion'); - - - /********************** - * FORM VALIDATION - **********************/ + + // FORM VALIDATION if(isset($_POST['submitQuestion']) && $form->validate()) { // question diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index fe4e28b686..e033236f4f 100755 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -3,7 +3,7 @@ /** * File containing the UNIQUE_ANSWER class. - * @package dokeos.exercise + * @package chamilo.exercise * @author Eric Marguin */ @@ -91,7 +91,7 @@ class UniqueAnswer extends Question { '.$feedback_title.' '.get_lang('Weighting').' - + '; $form -> addElement ('html', $html); @@ -101,8 +101,7 @@ class UniqueAnswer 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; } } @@ -113,8 +112,7 @@ class UniqueAnswer extends Question { $select_question=array(); $select_question[0]=get_lang('SelectTargetQuestion'); - require_once '../newscorm/learnpathList.class.php'; - + require_once '../newscorm/learnpathList.class.php'; if (is_array($question_list)) { foreach ($question_list as $key=>$questionid) { //To avoid warning messages @@ -126,9 +124,7 @@ class UniqueAnswer extends Question { } } $select_question[-1]=get_lang('ExitTest'); - - //LP SELECT - require_once('../newscorm/learnpathList.class.php'); + //require_once('../newscorm/learnpath.class.php'); //require_once('../newscorm/learnpathItem.class.php'); @@ -141,35 +137,28 @@ class UniqueAnswer extends Question { $select_lp_id[$id] = cut($details['lp_name'],20); } - $temp_scenario=array(); - + $temp_scenario = array(); if ($nb_answers < 1) { $nb_answers = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } - for($i = 1 ; $i <= $nb_answers ; ++$i) - { - - $form -> addElement ('html', ''); - if(is_object($answer)) - { - if($answer -> correct[$i]) - { + for($i = 1 ; $i <= $nb_answers ; ++$i) { + $form -> addElement ('html', ''); + if (is_object($answer)) { + if ($answer -> correct[$i]) { $correct = $i; } - - $defaults['answer['.$i.']'] = $answer -> answer[$i]; - $defaults['comment['.$i.']'] = $answer -> comment[$i]; + $defaults['answer['.$i.']'] = $answer -> answer[$i]; + $defaults['comment['.$i.']'] = $answer -> comment[$i]; $defaults['weighting['.$i.']'] = float_format($answer -> weighting[$i], 1); $item_list=explode('@@',$answer -> destination[$i]); - //echo '
';	print_r($item_list);
 
-					$try = $item_list[0];
-					$lp = $item_list[1];
-					$list_dest= $item_list[2];
-					$url=$item_list[3];
+					$try       = $item_list[0];
+					$lp        = $item_list[1];
+					$list_dest = $item_list[2];
+					$url       = $item_list[3];
 
 					if ($try==0)
 						$try_result=0;
@@ -181,10 +170,10 @@ class UniqueAnswer extends Question {
 					else
 						$url_result=$url;
 
-					$temp_scenario['url'.$i]=$url_result;
-					$temp_scenario['try'.$i]=$try_result;
-					$temp_scenario['lp'.$i]=$lp;
-					$temp_scenario['destination'.$i]=$list_dest;
+					$temp_scenario['url'.$i]        = $url_result;
+					$temp_scenario['try'.$i]        = $try_result;
+					$temp_scenario['lp'.$i]         = $lp;
+					$temp_scenario['destination'.$i]= $list_dest;
 
 
 					/*$pre_list_destination=explode(';',$list_dest);
@@ -197,10 +186,10 @@ class UniqueAnswer extends Question {
 					*/
 					//$defaults['destination'.$i] = $list_destination;
 				} else {
-					$defaults['answer[1]']  = get_lang('langDefaultUniqueAnswer1');
-					$defaults['weighting[1]'] = 10;
-					$defaults['answer[2]']  = get_lang('langDefaultUniqueAnswer2');
-					$defaults['weighting[2]'] = 0;
+					$defaults['answer[1]']     = get_lang('langDefaultUniqueAnswer1');
+					$defaults['weighting[1]']  = 10;
+					$defaults['answer[2]']     = get_lang('langDefaultUniqueAnswer2');
+					$defaults['weighting[2]']  = 0;
 
 					$temp_scenario['destination'.$i] = array('0');
 					$temp_scenario['lp'.$i] = array('0');
@@ -210,6 +199,7 @@ class UniqueAnswer extends Question {
 				$defaults['scenario']=$temp_scenario;
 				$renderer = & $form->defaultRenderer();
 				$renderer->setElementTemplate('{error}
{element}'); + $renderer->setElementTemplate('{error}
{element}','html'); $answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); $answer_number->freeze(); @@ -220,7 +210,7 @@ class UniqueAnswer extends Question { if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) { // feedback $form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config); - } elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { + } elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { // direct feedback $form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config); //Adding extra feedback fields @@ -236,8 +226,11 @@ class UniqueAnswer extends Question { //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple'); - $form->addElement('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0"'); - $form -> addElement ('html', ''); + $form->addElement('text', 'weighting['.$i.']', null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0"'); + + + $form->addElement ('html', ''); + } $form -> addElement ('html', ''); @@ -250,16 +243,15 @@ class UniqueAnswer extends Question { if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { $form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"'); $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); + $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); } else { //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', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); - $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); - - + $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'style="float:right"; class="minus"'); + $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"'); } } $renderer->setElementTemplate('{element}','submitQuestion');