Project

General

Profile

Feature #6095

Multiple correct answers (or more than one correct answer) in a fill in the blanks gap

Added by Gabriel Aaron about 6 years ago. Updated over 2 years ago.

Status:
Feature implemented
Priority:
Normal
Category:
Exercises
Target version:
Start date:
17/04/2013
Due date:
% Done:

100%

Estimated time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

is there a way to have more than 1 correct answer in a fill in the blanks question?
I tried the following combinations(which i've read about in the internet) with no success:

TEXT TEXT TEXT [ANSWER1,ANSWER2]
TEXT TEXT TEXT [ANSWER1|ANSWER2]
TEXT TEXT TEXT [ANSWER1@ANSWER2]

any help would be greatly appreciated.

History

#1

Updated by Yannick Warnier about 6 years ago

The right way to go about to find the place where this has to be modified would be to:
  • go to exercise_submit.php (the url used during the test) and look for scoring. On line 415, we have this: $objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false, $objExercise->propagate_neg); which seems to combine the necessary elements to represent the place where the score is calculated.
  • find Exercise::manage_answer() in exercise.class.php (~1897)
  • find where the user answer ($choice) is compared to the correct system answer
  • get to the FILL_IN_BLANKS section (~line 2232)
  • around lin 2328 you have the scoring logic for all answers, so I would guess just reading patiently the (extensive) code documentation in there, you should be able to make sense our of it and add a split('|') or explode('|') somewhere and mak it possible to use more than one possible word.
#2

Updated by Yannick Warnier about 6 years ago

Probably the best place would b lines 2326 and 2327:

                            $user_tags[$i] = stripslashes($user_tags[$i]);
                            if ($correct_tags[$i] == $user_tags[$i]) {

which would now look something like this:
                            $user_tags[$i] = stripslashes($user_tags[$i]);
                            if (preg_match('/|/',$user_tags[$i]) {
                                $splitwords = split('|',$user_tags[$i]);
                                if (in_array($correct_tags[$i],$splitwords)) {
                                ...
                            } else {
                                if ($correct_tags[$i] == $user_tags[$i]) {                                
                                ...
                            }

That should be it (although that doesn't allow you to define a different score per word)

#3

Updated by Yannick Warnier about 6 years ago

  • Category set to Exercises
  • Status changed from New to Needs testing
  • Target version set to 2.0
  • % Done changed from 0 to 40
#4

Updated by Gabriel Aaron about 6 years ago

Thank you Yannick for all this information and help.
Im using version 1.9.4 (https://chamilo.googlecode.com/files/chamilo-1.9.4.zip) in which exercise_submit.php has 1053 lines. im not being able to find the code you are talking about.

#5

Updated by Gabriel Aaron about 6 years ago

I found a file with similar code, exercise.class.php in main/exercise.
You can see it here http://pastebin.com/KyrHQas6

I tried applying the modifications you talked about.. but i dont really know how.. i know some php.. but not as much i would wish.

I will really appreciate it if you can do the necessary modifications for me to test in the pastebin url for me to test and give feedback.

thanks you again!

#6

Updated by Gabriel Aaron about 6 years ago

I also found some related code in exercise.lib.php in main/exercise
http://pastebin.com/WDNDgV4a

Im pretty sure this should also be modified in order for this to work as expected.

#7

Updated by Yannick Warnier over 3 years ago

  • Assignee set to Hubert Borderiou
  • % Done changed from 40 to 70

I believe this was added to 1.10 by Hubert. Right, Hubert? Can you remind me of the link to your blog explaining it?

#9

Updated by Yannick Warnier over 2 years ago

  • Subject changed from multiple correct answers (or more than one correct answer) in a fill in the blanks gap to Multiple correct answers (or more than one correct answer) in a fill in the blanks gap
  • Status changed from Needs testing to Feature implemented
  • Target version changed from 2.0 to 1.11.4
  • % Done changed from 70 to 100

Also available in: Atom PDF