Code to add a "vertical" display of users for Choice activities.
If "display vertically" is chosen, it will apply to both the list
of options and the list of responses.
This code is working on my system (1.9.4+) but use with caution. The code needs to be
cleaned up a bit. Please report problems.
Back up your code before modifying it. Wear safety glasses. Dont't run with scissors.
Add to language file lang/xx/choice.php
$string['options'] = 'Options';
$string['participants'] = 'Participants';
$string['limits'] = 'Limits';
Add to report.php at around 207:
(this replaces a single call to choice_show_results() with an if-else that
calls the appropriate method.)
//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_HORIZONTAL) {
choice_show_results($choice, $course, $cm, $allresponses);
}
else {
choice_show_results_vert($choice, $course, $cm, $allresponses);
}
//end new code
//existing code
////// //now give links for downloading spreadsheets.
////// if (!empty($users) && has_capability('mod/choice:downloadresponses',$context)) {
Add to view.php at 153:
(this replaces a single call to choice_show_results() with an if-else that
calls the appropriate method.)
// if ( $choice->showresults == CHOICE_SHOWRESULTS_ALWAYS or
// ($choice->showresults == CHOICE_SHOWRESULTS_AFTER_ANSWER and $current ) or
// ($choice->showresults == CHOICE_SHOWRESULTS_AFTER_CLOSE and !$choiceopen ) ) {
//show table with students responses.
if ($choice->display == CHOICE_DISPLAY_HORIZONTAL) {
choice_show_results($choice, $course, $cm, $allresponses);
}
else {
choice_show_results_vert($choice, $course, $cm, $allresponses);
}
// } else if (!$choiceformshown) {
// print_simple_box(get_string('noresultsviewable', 'choice'), 'center');
// }
Add to lib.php:
function choice_show_results_vert($choice, $course, $cm, $allresponses, $forcepublish='') {
global $CFG, $COLUMN_HEIGHT;
print_heading(get_string("responses", "choice"));
if (empty($forcepublish)) { //alow the publish setting to be overridden
$forcepublish = $choice->publish;
}
if (empty($allresponses)) {
print_heading(get_string("nousersyet"));
return false;
}
$totalresponsecount = 0;
foreach ($allresponses as $optionid => $userlist) {
if ($choice->showunanswered || $optionid) {
$totalresponsecount += count($userlist);
}
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$hascapfullnames = has_capability('moodle/site:viewfullnames', $context);
$viewresponses = has_capability('mod/choice:readresponses', $context);
//echo "forcepublish = ".$forcepublish."
";
switch ($forcepublish) {
case CHOICE_PUBLISH_NAMES:
//echo 'publish names
';
echo '