Questions and request about Choice

Questions and request about Choice

by Brian Gray -
Number of replies: 14
Dan -

I've been playing with the Choice activity and and the Choice block on my 1.6 beta test system.  I really like the Choice block - a nice addition!

I added a couple of feature requests to the bug tracker (# 5776).  We will have a few cases this year that require 40 different options for students to choose from.  I would like to be able to import the list of choices instead of typing them.  I would also like to have the option of displaying the responses vertically. Ideally, it would work excactly like the existing option for the list of choices (i.e., an entry on the configurtion page to select vertical or horizontal display).

When playing with the Choice block, I noticed that if the related Choice activity is set to use Visible or Separate groups, the block moves from the left or right side of the screen to the bottom of the screen, under all of the course blocks in the center column.  Is this a bug or a feature?

In your previous posts related to the choice block, one of your screen shots uses images instead of text for the choice options.  I could not find any information on how to do that.  What's the trick?

My teachers like this module, and it gets a lot of use.  Thanks for your work on it.

bkg

Average of ratings: -
In reply to Brian Gray

Re: Questions and request about Choice

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Brian - saw this post after the bug. - to use images, you use the html code for each image eg:
<img src="myimage.jpg" />

when I get a chance I will be adding the same vertical responses display that is shown in the choice block to the Choice Module in 1.7

The visible/seperate groups one sounds weird - any chance you could post a couple of screenshots to show what you mean? - doesn't sound like a feature to me!

thanks,

:-)

Dan

In reply to Dan Marsden

Re: Questions and request about Choice

by Brian Gray -
A JPG image is attached.

The Choice block and the "Add Blocks" block move to the bottom of the screen and stretch across the entire screen. 

If the Choice activity is set to "No Groups", the Choice block goes back to the top right column of the screen as expected.

My environment is:
Moodle 1.6 Beta 5 (2006050504)
RedHat Linux ES 3
PHP 4.3.2
MySql 5.0.21


Attachment ChoiceBlockBad.JPG
In reply to Brian Gray

Re: Questions and request about Choice

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
ahh, I see the problem there! definately a bug! - I'll try to post a patch for that one when I get back in to work on Monday. - I might have to hide the drop down on the block when groups are used.

thanks!

smile

Dan
In reply to Dan Marsden

Re: Questions and request about Choice

by Tobias Hamacher -
Hi Dan,

did anything happen about the vertical results in choice? I'm having the same need now: many choices and a very very wide results-list.

Greetings
Tobias
V 1.9.4+


In reply to Tobias Hamacher

Re: Questions and request about Choice

by Brian Gray -
See attached file (install.txt) for instructions to add an option for "vertical display of responses from users".

The code is written so that if the "display vertically" option is set for the options, it will also apply to the responses from users.

This may not be what we want long-term, but it works for now.

Let me know what problems you see.

bkg

In reply to Brian Gray

Re: Questions and request about Choice

by Tobias Hamacher -
Hi Brian,

i am having problems in edittig the report.php -file of the choice mod.

In the install.txt the changes are described like this:

//existing code
////// if (has_capability('mod/choice:deleteresponses', $context) /* and $choice->showunanswered */) {
////// choice_show_selectfor_link($cm);
////// }

//start new code
//show table with students responses.
if ($choice->display == CHOICE_DISPLAY_HORIZ ...a.s.o.


My existing code in Line 206 of the original report.php but does look like this:

choice_show_results($choice, $course, $cm, $users, $format); //show table with students responses.

when i comment this line out and place your code underneath, no results are shown at all.
When i leave the old code unchanged and place the new code underneath, only horizontal results are shown, as before.

Any idea what i can do about it?

Thanks - Tobias




In reply to Tobias Hamacher

Re: Questions and request about Choice

by Brian Gray -

I managed to copy the wrong code into the instructions. An updated version is attached.

The only change is: in my if-else block in report.php, change the last argument to each of the calls to choice_show_results() from $allresponses to $users.

Let me know what happens.

bkg
In reply to Brian Gray

Re: Questions and request about Choice

by Tobias Hamacher -
Hi Brian,

i changed the parts in report.php you pointed out to me, unfortunately with no effect. When I chose "display vertically" in choice settings no results are being displayed at all.


This is my changed code in report.php at around 207:
// choice_show_results($choice, $course, $cm, $users, $format); //show table with students responses.


if (has_capability('mod/choice:deleteresponses', $context) /* and $choice->showunanswered */) {
choice_show_selectfor_link($cm);
}

if ($choice->display == CHOICE_DISPLAY_HORIZONTAL) {
choice_show_results($choice, $course, $cm, $users);
}
else {
choice_show_results_vert($choice, $course, $cm, $users);
}


This is my changed code in view.php at 153:
// print the results at the bottom of the screen

// if ( $choice->showresults == CHOICE_SHOWRESULTS_ALWAYS or
// ($choice->showresults == CHOICE_SHOWRESULTS_AFTER_ANSWER and $current ) or
// ($choice->showresults == CHOICE_SHOWRESULTS_AFTER_CLOSE and !$choiceopen ) ) {

if ($choice->display == CHOICE_DISPLAY_HORIZONTAL) {
choice_show_results($choice, $course, $cm, $allresponses); //show table with students responses.
}
else {
choice_show_results_vert($choice, $course, $cm, $allresponses);
}
// } else if (!$choiceformshown) {
// print_simple_box(get_string('noresultsviewable', 'choice'), 'center');
// }

I also added the code in lang/utf8_en/choice.php and mod/choice/lib.php according to your instructions, so i cant see whats going wrong...

Thanks for your Help

Tobias
In reply to Tobias Hamacher

Re: Questions and request about Choice

by Brian Gray -
Hmmmm... I need a bit more information to figure out what I've done wrong here.

If you see neither the list of responses nor error messages when you click on "View Responses" (which runs report.php), then the system debugging setting is suppressing error messages. Please turn on the error display to see what messages we get.

On the site's front page, in the Site Administration block click on Server and then on Debugging. Set the first field (Debugging messages) to NORMAL, and check the box for "Display debug". Save.

Then go to a Choice activity with Display Vertical set.

When you first go to a Choice activity with Display vertical set, you should see the options listed vertically (with radio buttons for you to choose). Below that, you should see either a vertical list of responses with names or bar charts. Do you? Are there error messages?

Click on "View Responses". What error messages are displayed?

After you get the error messages copied, go back and turn debugging off.

Please post the error messages, and attach your view.php, report.php and lib.php files for me to look at.

Is the Choice activity set to show responses to students? Anonymously or with names?

We should be able to make this work quickly.

bkg

In reply to Brian Gray

Re: Questions and request about Choice

by Tobias Hamacher -
Hi Brian,

thanks for the quick answer! These are the error messages:


Fatal error
: Call to undefined function countcolumns() in /var/www/moodle/mod/choice/lib.php on line 791

Fatal error: Call to undefined function choice_show_selectfor_link() in /var/www/moodle/mod/choice/report.php on line 209


In choice settings "always show results to students" and "publish full results" is set.

.php files attached as zip.

Greetings - Tobias


In reply to Tobias Hamacher

Re: Questions and request about Choice

by Brian Gray -

Ahhh...now I see what I did. I've been working on another modification to the Choice module - one that allows the teacher to make the choice for a student who does not respond to the activity. I refer to it as the "select-for" feature. (See this forum entry and this Moodle Tracker entry.) A PDF file attached to the Tracker entry shows a walk-through of the "select-for" features. Any user with the "delete response" capability can also make selections for others.

I accidentally used the version of lib.php modified for "select-for" when I wrote the code for vertical display of responses. The two are really linked together because of some of the functions that both use.

I have attached a zip file that contains the modified files for both features:
  • report.php
  • view.php
  • lib.php
  • selectfor.php - a new file
  • bar.png - a rotated version of col.png - used in vertical displays when names are hidden
  • lang_choice_additions.php - contains the language strings for both features
Back up the first three files above, and then unzip the whole thing into mod/choice.

Insert the contents of lang_choice_additions.php into lang/xx/choice.php. (Some strings may already be there from your previous attempts at installing this mess.)

My apologies for the confusion. I hope that you find the two new features worth the effort.
Average of ratings: Useful (1)
In reply to Brian Gray

Re: Questions and request about Choice

by Tobias Hamacher -
great, it works perfectly!

Thank you so much -Greetings

Tobias
In reply to Tobias Hamacher

Re: Questions and request about Choice

by Aryan K -

This is an awesome post, I was looking out for the workaround for quite some time. This has saved my day!

Thanks
Aryan