Multiple choice in choice ( New module programed for Moodle 1.8+ )

Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Àlex Vaqué Brull -
Number of replies: 39

Multiple choice in choice ( New module for Moodle 1.8+)
Module for Moodle 1.8+

Upgrade of the Joan Codina's code



Description:

Allow for multiple answers in choice.



Links:


code of Joan Codina for the Moodle 1.5 and 1.6
Discussion Moodle Forum



Images:


f1.PNG



f2.PNG




Files:


2 opcions:

1 ) Use Patch
multichoice.patch

or
2) Only overwrite files in moodle

moodle\lang\en_utf8\choice.php
moodle\mod\choice\lib.php
moodle\mod\choice\mod_form.php
moodle\mod\choice\report.php




Authors:


Marina Artigas Pérez and Àlex Vaqué Brull

Prosjek ocjena:Useful (1)
In reply to Àlex Vaqué Brull

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators

nice work guys! - I'll have a look at your patch and see if it can be merged into the core! - will be a couple of weeks before I get a chance to have a good look - school holidays start on Monday!

Any reason why you're still using radio buttons instead of checkboxes?

smiješak

Dan

In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Àlex Vaqué Brull -
Hi!

To do this with "buttons checkboxes " , we 'll make many modifications in the files mod/choice/.

With radio buttons the code change a little only and It is very easy to merged into the core.
odobrava

Thanks!

In reply to Àlex Vaqué Brull

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Joan Codina Filba -
It's a maintenance problem, if this modification does not get into the core, then, for every new realease, the patch needs to be applied and we need to check for compatibility. As more parts of the code are affected more easy is to have a conflict.
In reply to Joan Codina Filba

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators

Hi Guys,

if you prepare a complete patch using checkboxes instead of radio buttons, I would happily review it for inclusion in Core - it's something I've wanted to do for a while........

The problem with the current implementation is that a user can't "update" their choice. - if they have already selected an option, but no longer want to select that, there is no way of removing a single option without deleting all their responses to the choice.... - this could be fixed by adding checkboxes instead of radio buttons.

smiješak

Dan

In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Àlex Vaqué Brull -
Now We're working to do this code with checkboxes ! !
In reply to Àlex Vaqué Brull

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Stéphane Buchmann -
Hi Alex,

May I ask about the status of your changes ?
Any chance to see this patch for 1.9 or should we wait for 2.0 ?

Thanks a lot for your work.

Regards,

Stéphane
In reply to Àlex Vaqué Brull

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Nataša Miloradović -

Hi Guys,

I have just tried to add multiple choices - not as a patch, rather as overwriting files in Moodle.

Tried answering with couple of users, and then looked the results.

They apear ok on the choice page, but when I tried exporting them, there was only one - last answer present.

I guess this is something  that has to do with what Dan Marden mentioned

>The problem with the current implementation is that a user can't "update" their choice. - if they have already selected an option, but no longer want to select that, there is no way of removing a single option without deleting all their responses to the choice.... - this could be fixed by adding checkboxes instead of radio buttons.

Just wanted to report this bug to you.

Natasha

In reply to Nataša Miloradović

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Sharming Wang -

Hello All,

First of all, thanks very much for developing this module, we are using the choice module as an appointment registering platform on our site. We tried a few other booking modules such as 'bookings' and 'Scheduler', and found Choice to be the closest to what we want.

I want to add two more functions to this module. One to be when student submit a choice, he/she will be redirected to a confirmation page. The other one is the system send out a confirmation email to the student automatically after he/she submits a choice. I think the first one should be reasonably easy to do, and the second idea is harder to implement. Anyway my knowledge of php is close to zero, and couldn't do both. Can anyone offer a little bit of help please? I'll really appreciate it.

Sharming

In reply to Sharming Wang

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Anthony Borrow -
Slika Core developers Slika Plugin developers Slika Testers
Sharming - The best way to bring suggestions to the attention of the developers is to create a feature request or improvement issue in the tracker. If it is really important to you and you want to get a bid for how much implementing something would be you could contact a Moodle Partner or Moodle.com and submit a bid request to get an idea of how much work would be involved. If you're lucky someone else may already have a similar patch in place on their system that they might be willing to share. Peace - Anthony
In reply to Àlex Vaqué Brull

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Juan Marín -
Hi Marina y Alex, Thanks for the code.
Do you have any upgrade to use in 1.9.1?


In reply to Juan Marín

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Maiol Pi Blanque -
hi! I'm working to improve Alex's patch, I've changed radio buttons for checkboxes and you can choose more than one question, I will put the patch here and into the tracker section.
In reply to Maiol Pi Blanque

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
Hi there! sounds good! your patch contains other fixes already made, can you please create a clean patch with only your changes? thanks! smiješak Dan
In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Maiol Pi Blanque -
Hi Dan,
thanks, I didn't notice it was wrong. I think this is the correct patch
In reply to Maiol Pi Blanque

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
Hi Maiol,

that's slightly better, but lib.php and view.php aren't quite right yet. - the the code being removed by the diff is old. can you please try again?

thanks!

smiješak

Dan


In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Maiol Pi Blanque -
Hi Dan,

I'm sorry but I was checking what you said but I can't find any difference between the HEAD file.
Maybe I'm doing something wrong.

Maiol
In reply to Maiol Pi Blanque

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
this block pasted below doesn't look right:

couple of things - $countanswers = get_records isn't in HEAD - it's the line you replace it with. $countanswers = $DB->get_records.

also - you've removed a few Carriage returns, and added extra spaces on empty lines which makes the patch a bit messy. - the cleaner and tidier the patch, the easier it is for other developers to see where your exact suggested changes are! - thanks for this! - it's great to see patches for frequently requested features! - it doesn't look like you're far off!

smiješak

Dan


-
- $current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $userid);
+ global $DB;
+
+ $current = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $userid));
+ $current2 = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $userid,'optionid' => $formanswer));
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
- $countanswers = get_records("choice_answers", "optionid", $formanswer);
+ $countanswers = $DB->get_records("choice_answers", array('optionid'=> $formanswer));
if ($countanswers) {
+
$countans = 0;
foreach ($countanswers as $ca) { //only return enrolled users.
if (has_capability('mod/choice:choose', $context, $ca->userid, false)) {
$countans = $countans+1;
}
}
-

In reply to Maiol Pi Blanque

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Juan Marín -
Hi Maiol.
I have probed the patch in a Xamplite windows intallation moodle 2.0.
I use Cygwin to extract the patch.


I had put it previously in Moodle/ but an error appear:
www/moodle
$ patch -p1 -b <new_multiple_choicesDOS.diff
can't find file to patch at input line 10
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|### Eclipse Workspace Patch 1.0
|#P moodle
|Index: mod/choice/index.php
|===================================================================
|RCS file: /cvsroot/moodle/moodle/mod/choice/index.php,v
|retrieving revision 1.42
|diff -u -r1.42 index.php
|--- mod/choice/index.php 23 May 2008 07:03:17 -0000 1.42
|+++ mod/choice/index.php 20 Jun 2008 19:07:08 -0000
--------------------------
File to patch:


When I have put the diff file in moodle/mod the first two files are changed but an error apperar in hunk#3

www/moodle/mod
$ patch -p1 -b <new_multiple_choicesDOS.diff
patching file choice/index.php
patching file choice/lib.php
Hunk #1 succeeded at 175 (offset 4 lines).
Hunk #2 succeeded at 234 (offset 4 lines).
Hunk #3 FAILED at 259.
patch: **** malformed patch at line 164: add_to_log($courseid, "choice", "choose", "view.php?id=$cm->id", $choice->id, $cm->id);

In reply to Maiol Pi Blanque

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Juan Marín -
Maiol, I'm sorry... but I don't know how to use/install the patch
Seeing the .TXT I guess you has changed the files:
+++ mod/choice/index.php
+++ mod/choice/lib.php
+++ mod/choice/mod_form.php
+++ lang/en_utf8/choice.php
+++ mod/choice/view.php

But I don't know which lines to change and how to change it. I suppose that + means added lines, - means suppress line .. (@@ I don't know what is)
It is possible to hang the four files modified in a ZIP? In this case I can copy them in my server and test your work.

Thanks for the work done.

In reply to Juan Marín

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
Hi Juan,

the files Maiol has provided are diffs based on Moodle 2.0 - applying them to Moodle 1.9 or lower will not work.

If you are playing with Moodle 2.0, there's a good explanation on how to use Patch for windows here that will help you apply them:
http://moodle.org/mod/forum/discuss.php?d=61379#p286372


thanks,

smiješak

Dan


In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Juan Marín -
Thanks Dan.
The explanation is very clear... but for windows...and I use Linux in my MoodleServers. I will look for some information in the forums about patch and linux (I hope it would be not so difficult to find it).


I have a moodle 2.0 and a moodle 1.9 test servers and I test the files in both... perhaps the path would be Ok in both environments.

In reply to Juan Marín

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Juan Marín -
How to create a patch is clear: http://docs.moodle.org/en/Development:How_to_create_a_patch

But I couldn't find how to "Restore" a patch in LINUX. Sorry shy, can anybody help me?
In reply to Juan Marín

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
you can use the command "patch"

something like:

patch -p1 < patchfile.diff

smiješak

Dan

*Feel free to add some more info to the documentation wiki about this!
In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
In fact - I Just created:
http://docs.moodle.org/en/Development:How_to_apply_a_patch

feel free to flesh it out a bit more!

smiješak

Dan
In reply to Dan Marsden

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Gareth J Barnard -
Slika Core developers Slika Particularly helpful Moodlers Slika Plugin developers

Hi,

I tried to patch Moodle 1.9.1, but it did not work.  Complaining about finding the config.php file.

It would be really useful if this patch was placed into the core release.

Regards,

Gareth

In reply to Gareth J Barnard

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Juan Marín -
I have similar problems.
In reply to Juan Marín

Re: Multiple choice in choice ( New module programed for Moodle 1.8+ )

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
The Patch provided wasn't clean, and it was for Moodle 2.0 - it didn't apply cleanly to a Moodle 2.0 or a moodle 1.9 install. Unfortunately I don't have any free time to spend on this. If it's something you really needed you could contract a Moodle Partner to do the work for you.

(Disclosure: I work for the NZ Moodle Partner Catalyst.)
In reply to Dan Marsden

has multiple choice in choice managed to get into Moodle 2.0?

napisao/la Peter Evans -

Has multiple choice managed to get into Moodle 2.0? This would be a very useful improvement which has been long awaited by many.

Peter Evans

In reply to Peter Evans

Re: has multiple choice in choice managed to get into Moodle 2.0?

napisao/la Dan Marsden -
Slika Core developers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers Slika Plugins guardians Slika Testers Slika Translators
Hi Peter, no it hasn't sorry, and I haven't got any free-time to spend on this - my comments above still apply though - you could contact your local Moodle partner for a quote to do this work if you were willing to pay to have it done.
In reply to Dan Marsden

What is the status of multiple choice in choice for Moodle 1.9?

napisao/la Dave Sherwin -
Slika Particularly helpful Moodlers
Reading through the forums it sounds like I should not use MDL-3034 or MDL-3035 because they are for older versions and will not give us the functionality to select multiple choice in choice. Is that true or am I not understanding the discussions?

Just curious was this a function at one time and just does not work with Moodle 1.8+ or is there a setting I am missing administratively?

Thanks...
...Dave
In reply to Dave Sherwin

Re: What is the status of multiple choice in choice for Moodle 1.9?

napisao/la Anthony Borrow -
Slika Core developers Slika Plugin developers Slika Testers
Dave - Might the feedback module be a better fit for you? Peace - Anthony
In reply to Anthony Borrow

Re: What is the status of multiple choice in choice for Moodle 1.9?

napisao/la Dave Sherwin -
Slika Particularly helpful Moodlers
Anthony - thanks
The feedback module will work perfectly for the activity we want the teachers to participate. Plus there are other type of questions that we can also get feedback which will give us more flexibility then a basic survey.
Thanks again - you are a hero smiješak

In reply to Dave Sherwin

Re: What is the status of multiple choice in choice for Moodle 1.9?

napisao/la Anthony Borrow -
Slika Core developers Slika Plugin developers Slika Testers
Dave - You are most welcome. I really liked feedback especially because it allowed for multiple questions. We used it for course evaluations and it worked great especially considering (as you noted) that there is good flexibility with the types of questions you can ask. Happy Moodling! Peace - Anthony
In reply to Anthony Borrow

Re: What is the status of multiple choice in choice for Moodle 1.9?

napisao/la Lina María Perez Tamayo -

Estoy Creando el Banco de Preguntas de 3000 de Opción múltiple Estando en La Pregunta 1800 me genero El Siguiente error No Se PUDO insertar Las Opciones de Opción múltiple Cuestionario !DESDE entonces no hemos podido CREAR mas Preguntas de opción multiple

In reply to Lina María Perez Tamayo

Re: What is the status of multiple choice in choice for Moodle 1.9?

napisao/la jehan procaccia -

regarding this thread ... is it now possible to enable multiple choice in choice !?

what realeses are supported ? (1.9, 2.0 ?)

where is the appropriate patch or full plugin ?

isn't in the core now !?

Tanks .