Project

General

Profile

Feature #3863

Make it possible to change question type

Added by Yannick Warnier over 7 years ago. Updated almost 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Exercises
Target version:
Start date:
01/09/2011
Due date:
% Done:

50%

Estimated time:
Spent time:
Complexity:
Normal
SCRUM pts - complexity:
8

Description

This is a very specific case because I understand not all types are compatible.
Only multiple possibilities, single answer (MPSA) and multiple possibilities, multiple answer (MPMA) should be allowed to switch.

Ex: MPSA
A1
A2
A3* (2pts)
A4

would become a possible MPMA

A1
A2
A3* (2pts)
A4

with the possibility to change it to:

A1*
A2
A3*
A4


Files

chamilo-3863.patch (3.92 KB) chamilo-3863.patch Yannick Warnier, 24/12/2012 05:01

History

#1

Updated by Yannick Warnier over 6 years ago

  • Target version changed from 1.9 Stable to 1.9.2
#2

Updated by Yannick Warnier over 6 years ago

  • Target version changed from 1.9.2 to 1.9.4
#3

Updated by Yannick Warnier about 6 years ago

  • Category set to Exercises

Question types are:

define('UNIQUE_ANSWER',                             1);
define('MULTIPLE_ANSWER',                           2);
define('FILL_IN_BLANKS',                            3);
define('MATCHING',                                  4);
define('FREE_ANSWER',                               5);
define('HOT_SPOT',                                  6);
define('HOT_SPOT_ORDER',                            7);
define('HOT_SPOT_DELINEATION',                      8);
define('MULTIPLE_ANSWER_COMBINATION',               9);
define('UNIQUE_ANSWER_NO_OPTION',                   10);
define('MULTIPLE_ANSWER_TRUE_FALSE',                11);
define('MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE',    12);
define('ORAL_EXPRESSION',                           13);
define('GLOBAL_MULTIPLE_ANSWER',                    14);
define('MEDIA_QUESTION',                            15);

The idea would be to allow a type "1" to become a type "2", and the other way around (although the other way around would imply abandonning anything but the first "correct" answer).

This could be made possible through an additional button at the end of the question edition screen (only for those two types) saying "Convert to multiple answers" / "Convert to single answer".

#4

Updated by Yannick Warnier about 6 years ago

This is a patch that could be applied to 1.9.4dev to enable this feature, but I'm not feeling comfortable adding it now. I think it should be added to Chamilo 1.10 but after the next merge which will stabilize the platform for icpna.

diff -r fd44cd0957c4 main/exercice/multiple_answer.class.php
--- a/main/exercice/multiple_answer.class.php    Sun Dec 23 21:50:44 2012 -0500
+++ b/main/exercice/multiple_answer.class.php    Sun Dec 23 22:58:16 2012 -0500
@@ -149,8 +149,14 @@
                 $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.'"');        
+                if (!empty($this->id)) {
+                    $form->addElement('style_submit_button', 'changeQuestionType',get_lang('ConvertToUniqueAnswer'), 'class="btn refresh"');
+                }
             }
         }
+                if (!empty($this->id)) {
+                    $renderer->setElementTemplate('{element} ','changeQuestionType');
+                }
         $renderer->setElementTemplate('{element} ','lessAnswers');
         $renderer->setElementTemplate('{element} ','submitQuestion');
         $renderer->setElementTemplate('{element} ','moreAnswers');
diff -r fd44cd0957c4 main/exercice/question.class.php
--- a/main/exercice/question.class.php    Sun Dec 23 21:50:44 2012 -0500
+++ b/main/exercice/question.class.php    Sun Dec 23 22:58:16 2012 -0500
@@ -1314,6 +1314,19 @@

           //Save normal question if NOT media
         if ($this->type != MEDIA_QUESTION) {
+            if ($this->type == UNIQUE_ANSWER) {
+                $switch = $form->getSubmitValue('changeQuestionType');
+                if (isset($switch)) {
+                    $this->updateType(MULTIPLE_ANSWER);
+                }
+            } elseif ($this->type == MULTIPLE_ANSWER) {
+                $switch = $form->getSubmitValue('changeQuestionType');
+                if (isset($switch)) {
+                    //@todo make sure there's only one correct answer left
+                    //@todo when converting from multiple to unique, if an answer is incorrect with a score of 1, the score is converted to -1 (!?)
+                    $this->updateType(UNIQUE_ANSWER);
+                }
+            }
             $this->save($objExercise->id);

             // modify the exercise
@@ -1602,4 +1615,4 @@
         }
         return $html;
     }
-}
\ No newline at end of file
+}
diff -r fd44cd0957c4 main/exercice/question_admin.inc.php
--- a/main/exercice/question_admin.inc.php    Sun Dec 23 21:50:44 2012 -0500
+++ b/main/exercice/question_admin.inc.php    Sun Dec 23 22:58:16 2012 -0500
@@ -53,7 +53,7 @@
     }

     // FORM VALIDATION
-    if (isset($_POST['submitQuestion']) && $form->validate()) {
+    if ((isset($_POST['submitQuestion']) or (isset($_POST['changeQuestionType']))) && $form->validate()) {

         // question
         $objQuestion->processCreation($form, $objExercise);
diff -r fd44cd0957c4 main/exercice/unique_answer.class.php
--- a/main/exercice/unique_answer.class.php    Sun Dec 23 21:50:44 2012 -0500
+++ b/main/exercice/unique_answer.class.php    Sun Dec 23 22:58:16 2012 -0500
@@ -237,8 +237,14 @@
                 $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.'"');    
+                if (!empty($this->id)) {
+                    $form->addElement('style_submit_button', 'changeQuestionType',get_lang('ConvertToMultipleAnswer'), 'class="btn refresh"');
+                }
             }
         }
+                if (!empty($this->id)) {
+                    $renderer->setElementTemplate('{element} ','changeQuestionType');
+                }
         $renderer->setElementTemplate('{element} ','submitQuestion');
         $renderer->setElementTemplate('{element} ','lessAnswers');
         $renderer->setElementTemplate('{element} ','moreAnswers');

Attaching the patch file and postponing to 1.10.

#5

Updated by Yannick Warnier about 6 years ago

  • % Done changed from 0 to 50
  • SCRUM pts - complexity changed from ? to 8
#6

Updated by Yannick Warnier almost 3 years ago

  • Target version changed from 2.0 to 3.0

Also available in: Atom PDF