[svn r20166] Test tool: more UI improvements see FS#4029

skala
Julio Montoya 16 years ago
parent f92aa95259
commit f3e45f3636
  1. 2
      main/exercice/fill_blanks.class.php
  2. 14
      main/exercice/freeanswer.class.php
  3. 51
      main/exercice/matching.class.php
  4. 4
      main/exercice/multiple_answer.class.php
  5. 4
      main/exercice/unique_answer.class.php

@ -68,7 +68,7 @@ class FillBlanks extends Question
$fck_attribute = array(); $fck_attribute = array();
//$fck_attribute['Width'] = '348px'; //$fck_attribute['Width'] = '348px';
$fck_attribute['Width'] = '100%'; $fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '450px'; $fck_attribute['Height'] = '350px';
$fck_attribute['ToolbarSet'] = 'Full'; $fck_attribute['ToolbarSet'] = 'Full';

@ -47,20 +47,16 @@ class FreeAnswer extends Question {
* function which redifines Question::createAnswersForm * function which redifines Question::createAnswersForm
* @param the formvalidator instance * @param the formvalidator instance
*/ */
function createAnswersForm ($form) { function createAnswersForm ($form)
$form -> addElement('text','weighting',get_lang('Weighting'),'size="5"');
if(!empty($this->id))
{ {
$form -> setDefaults(array('weighting' => $this->weighting)); $form -> addElement('text','weighting',get_lang('Weighting'),'size="5"');
} if(!empty($this->id)) {
else { $form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
} else {
$form -> setDefaults(array('weighting' => '10')); $form -> setDefaults(array('weighting' => '10'));
} }
} }
/** /**
* abstract function which creates the form to create / edit the answers of the question * abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance * @param the formvalidator instance

@ -74,25 +74,19 @@ class Matching extends Question {
if(isset($_POST['moreOptions'])) if(isset($_POST['moreOptions']))
$nb_options++; $nb_options++;
} } else if(!empty($this -> id)) {
else if(!empty($this -> id))
{
$answer = new Answer($this -> id); $answer = new Answer($this -> id);
$answer -> read(); $answer -> read();
if(count($answer->nbrAnswers)>0) if(count($answer->nbrAnswers)>0) {
{
$a_matches = $a_options = array(); $a_matches = $a_options = array();
$nb_matches = $nb_options = 0; $nb_matches = $nb_options = 0;
for($i=1 ; $i<=$answer->nbrAnswers ; $i++){ for($i=1 ; $i<=$answer->nbrAnswers ; $i++){
if($answer -> isCorrect($i)) if ($answer -> isCorrect($i)) {
{
$nb_matches++; $nb_matches++;
$defaults['answer['.$nb_matches.']'] = $answer -> selectAnswer($i); $defaults['answer['.$nb_matches.']'] = $answer -> selectAnswer($i);
$defaults['weighting['.$nb_matches.']'] = $answer -> selectWeighting($i); $defaults['weighting['.$nb_matches.']'] = float_format($answer -> selectWeighting($i),1);
$defaults['matches['.$nb_matches.']'] = $answer -> correct[$i]; $defaults['matches['.$nb_matches.']'] = $answer -> correct[$i];
} } else {
else
{
$nb_options++; $nb_options++;
$defaults['option['.$nb_options.']'] = $answer -> selectAnswer($i); $defaults['option['.$nb_options.']'] = $answer -> selectAnswer($i);
} }
@ -113,14 +107,9 @@ class Matching extends Question {
$a_matches[$i] = chr(64+$i); // fill the array with A, B, C..... $a_matches[$i] = chr(64+$i); // fill the array with A, B, C.....
} }
$form -> addElement('hidden', 'nb_matches', $nb_matches); $form -> addElement('hidden', 'nb_matches', $nb_matches);
$form -> addElement('hidden', 'nb_options', $nb_options); $form -> addElement('hidden', 'nb_options', $nb_options);
//////////////////////// ////////////////////////
// DISPLAY MATCHES //// // DISPLAY MATCHES ////
////////////////////// //////////////////////
@ -128,13 +117,13 @@ class Matching extends Question {
$html=' $html='
<div class="row"> <div class="row">
<div class="label"> <div class="label">
'.get_lang('Answers').' '.get_lang('Answers').' <br /> <img src="../img/fill_field.png">
</div> </div>
<div class="formw"> <div class="formw">
'.get_lang('MakeCorrespond').' '.get_lang('MakeCorrespond').'
<table class="data_table"> <table class="data_table">
<tr style="text-align: center"> <tr style="text-align: center">
<th> <th width="40px">
'.get_lang('Number').' '.get_lang('Number').'
</th> </th>
<th> <th>
@ -150,23 +139,20 @@ class Matching extends Question {
</tr>'; </tr>';
$form -> addElement ('html', $html); $form -> addElement ('html', $html);
//$form -> addElement ('html_editor', 'answer','<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="updateBlanks(this)"');
for($i = 1 ; $i <= $nb_matches ; ++$i) for($i = 1 ; $i <= $nb_matches ; ++$i) {
{
$form -> addElement ('html', '<tr><td>'); $form -> addElement ('html', '<tr><td>');
$group = array(); $group = array();
$puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"'); $puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"');
$puce->freeze(); $puce->freeze();
$group[] = $puce; $group[] = $puce;
$group[] = FormValidator :: createElement ('text', 'answer['.$i.']',null, 'size="30" style="margin-left: 0em;"');
$group[] = FormValidator :: createElement ('text', 'answer['.$i.']',null, 'size="40" style="margin-left: 0em;"');
$group[] = FormValidator :: createElement ('select', 'matches['.$i.']',null,$a_matches); $group[] = FormValidator :: createElement ('select', 'matches['.$i.']',null,$a_matches);
$group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="2" value="10"'); $group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="10"');
$form -> addGroup($group, null, null, '</td><td width="0">'); $form -> addGroup($group, null, null, '</td><td width="0">');
$form -> addElement ('html', '</td></tr>'); $form -> addElement ('html', '</td></tr>');
} }
$form -> addElement ('html', '</table></div></div>'); $form -> addElement ('html', '</table></div></div>');
@ -175,8 +161,6 @@ class Matching extends Question {
$group[] = FormValidator :: createElement ('style_submit_button', 'moreMatches', get_lang('AddElem'),'class="plus"'); $group[] = FormValidator :: createElement ('style_submit_button', 'moreMatches', get_lang('AddElem'),'class="plus"');
$form -> addGroup($group); $form -> addGroup($group);
//////////////////////// ////////////////////////
// DISPLAY OPTIONS //// // DISPLAY OPTIONS ////
////////////////////// //////////////////////
@ -187,7 +171,7 @@ class Matching extends Question {
<div class="formw"><br /><br /> <div class="formw"><br /><br />
<table class="data_table"> <table class="data_table">
<tr style="text-align: center;"> <tr style="text-align: center;">
<th> <th width="40px">
'.get_lang('Number').' '.get_lang('Number').'
</th> </th>
<th> <th>
@ -197,17 +181,14 @@ class Matching extends Question {
</tr>'; </tr>';
$form -> addElement ('html', $html); $form -> addElement ('html', $html);
for($i = 1 ; $i <= $nb_options ; ++$i) {
for($i = 1 ; $i <= $nb_options ; ++$i)
{
$form -> addElement ('html', '<tr><td>'); $form -> addElement ('html', '<tr><td>');
$group = array(); $group = array();
$puce = FormValidator :: createElement ('text', null,null,'value="'.chr(64+$i).'"'); $puce = FormValidator :: createElement ('text', null,null,'value="'.chr(64+$i).'"');
$puce->freeze(); $puce->freeze();
$group[] = $puce; $group[] = $puce;
$group[] = FormValidator :: createElement ('text', 'option['.$i.']',null, 'size="30" style="margin-left: 0em;"'); $group[] = FormValidator :: createElement ('text', 'option['.$i.']',null, 'size="40" style="margin-left: 0em;"');
$form -> addGroup($group, null, null, '</td><td width="0">'); $form -> addGroup($group, null, null, '</td><td width="0">');
$form -> addElement ('html', '</td></tr>'); $form -> addElement ('html', '</td></tr>');
@ -219,9 +200,7 @@ class Matching extends Question {
$group[] = FormValidator :: createElement ('style_submit_button', 'lessOptions', get_lang('DelElem'),'class="minus"'); $group[] = FormValidator :: createElement ('style_submit_button', 'lessOptions', get_lang('DelElem'),'class="minus"');
$group[] = FormValidator :: createElement ('style_submit_button', 'moreOptions',get_lang('AddElem'),'class="plus"'); $group[] = FormValidator :: createElement ('style_submit_button', 'moreOptions',get_lang('AddElem'),'class="plus"');
$form -> addGroup($group); $form -> addGroup($group);
$form -> setDefaults($defaults); $form -> setDefaults($defaults);
$form->setConstants(array('nb_matches' => $nb_matches,'nb_options' => $nb_options)); $form->setConstants(array('nb_matches' => $nb_matches,'nb_options' => $nb_options));
} }

@ -78,7 +78,7 @@ class MultipleAnswer extends Question {
$html=' $html='
<div class="row"> <div class="row">
<div class="label"> <div class="label">
'.get_lang('Answers').' '.get_lang('Answers').'<br /><img src="../img/fill_field.png">
</div> </div>
<div class="formw"> <div class="formw">
<table class="data_table"> <table class="data_table">
@ -122,7 +122,7 @@ class MultipleAnswer extends Question {
{ {
$defaults['answer['.$i.']'] = $answer -> answer[$i]; $defaults['answer['.$i.']'] = $answer -> answer[$i];
$defaults['comment['.$i.']'] = $answer -> comment[$i]; $defaults['comment['.$i.']'] = $answer -> comment[$i];
$defaults['weighting['.$i.']'] = $answer -> weighting[$i]; $defaults['weighting['.$i.']'] = float_format($answer -> weighting[$i], 1);
$defaults['correct['.$i.']'] = $answer -> correct[$i]; $defaults['correct['.$i.']'] = $answer -> correct[$i];
} }

@ -99,7 +99,7 @@ class UniqueAnswer extends Question {
$html=' $html='
<div class="row"> <div class="row">
<div class="label"> <div class="label">
'.get_lang('Answers').' '.get_lang('Answers').' <br /> <img src="../img/fill_field.png">
</div> </div>
<div class="formw"> <div class="formw">
<table class="data_table"> <table class="data_table">
@ -177,7 +177,7 @@ class UniqueAnswer extends Question {
$defaults['answer['.$i.']'] = $answer -> answer[$i]; $defaults['answer['.$i.']'] = $answer -> answer[$i];
$defaults['comment['.$i.']'] = $answer -> comment[$i]; $defaults['comment['.$i.']'] = $answer -> comment[$i];
$defaults['weighting['.$i.']'] = $answer -> weighting[$i]; $defaults['weighting['.$i.']'] = float_format($answer -> weighting[$i], 1);
$item_list=explode('@@',$answer -> destination[$i]); $item_list=explode('@@',$answer -> destination[$i]);
//echo '<pre>'; print_r($item_list); //echo '<pre>'; print_r($item_list);

Loading…
Cancel
Save