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 '
'; if ($viewresponses) { echo '
'; echo '
'; echo ''; echo ''; } echo ""; echo ""; $columncount = countcolumns($choice->option, $allresponses); // number of votes in each column echo ""; if ($choice->limitanswers) { echo ""; } else { echo ""; } echo ""; echo ""; if ($choice->showunanswered) { echo ""; echo ""; // no limits for not answered echo ""; } $count = 0; echo ""; foreach ($choice->option as $optionid => $optiontext) { echo ""; echo '"; echo '"; echo ''; echo ""; echo ""; } echo ""; /// Print "Select all" etc. if ($viewresponses and has_capability('mod/choice:deleteresponses',$context)) { echo ''; } echo "
"; print_string('options', 'choice'); echo ""; print_string('limits', 'choice'); echo ""; print_string('responses', 'choice'); echo ""; print_string('participants', 'choice'); echo "
"; // added empty row so that when the next iteration is empty, // we do not get
erro from w3c validator // MDL-7861 print_string('notanswered', 'choice'); echo "
$columncount[0]"; echo ""; if (!empty($allresponses[0])) { foreach ($allresponses[0] as $user) { echo ""; echo ""; } } echo "
"; print_user_picture($user->id, $course->id, $user->picture); echo ""; echo "wwwroot/user/view.php?id=$user->id&course=$course->id\">"; echo fullname($user, $hascapfullnames); echo ""; echo "
'; // option text echo $optiontext; echo "'; // limits if ($choice->limitanswers) { echo get_string("taken", "choice").":"; echo $columncount[$optionid]; echo "   "; echo get_string("limit", "choice").":"; $choice_option = get_record("choice_options", "id", $optionid); echo $choice_option->maxanswers; echo "   "; if($columncount[$optionid] >= $choice_option->maxanswers){ echo get_string("full", "choice"); } } else { if (isset($columncount[$optionid])) { echo $columncount[$optionid]; } else { echo 0; } } echo "'; // participants // added empty row so that when the next iteration is empty, // we do not get
erro from w3c validator // MDL-7861 echo ''; if (isset($allresponses[$optionid])) { foreach ($allresponses[$optionid] as $user) { echo ''; } } $count++; echo '
'; if ($viewresponses and has_capability('mod/choice:deleteresponses',$context)) { echo ''; } echo ''; print_user_picture($user->id, $course->id, $user->picture); echo ''; echo "wwwroot/user/view.php?id=$user->id&course=$course->id\">"; echo fullname($user, $hascapfullnames); echo ''; echo '
'; echo ''.get_string('selectall', 'quiz').' / '; echo ''.get_string('selectnone', 'quiz').' '; echo '  '; $options = array('delete' => get_string('delete')); echo choose_from_menu($options, 'action', '', get_string('withselected', 'quiz'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true); echo ''; echo ''; echo '
"; if ($viewresponses) { echo "
"; } break; case CHOICE_PUBLISH_ANONYMOUS: //echo 'do NOT publish names
'; echo '
'; if ($viewresponses) { echo '
'; echo '
'; echo ''; echo ''; } $columncount = countcolumns($choice->option, $allresponses); // number of votes in each column $maxcolumn = max($columncount); // echo "allresponses =
".print_r($allresponses, true)."

"; // echo "columncount =
".print_r($columncount, true)."

"; // echo "maxcolumn = $maxcolumn
"; echo ""; echo ""; // if ($choice->showunanswered) { echo ""; // } if ($choice->limitanswers) { echo ""; } else { echo ""; } echo ""; echo ""; if ($choice->showunanswered) { echo ""; echo ""; // no limits for not answered $width = 0; if ($choice->showunanswered) { if ($maxcolumn) { $width = $COLUMN_HEIGHT * ((float)$columncount[0] / (float)$maxcolumn); } echo ""; } else { echo ""; } } $count = 0; echo ""; foreach ($choice->option as $optionid => $optiontext) { echo ""; echo '"; if ($choice->limitanswers) { echo '"; echo ""; } else { echo ""; } echo ''; echo ""; echo ""; } echo ""; echo "
"; print_string('options', 'choice'); echo ""; print_string('limits', 'choice'); echo ""; print_string('responses', 'choice'); echo ""; print_string('participants', 'choice'); echo "
"; // added empty row so that when the next iteration is empty, // we do not get
erro from w3c validator // MDL-7861 print_string('notanswered', 'choice'); echo "
$columncount[0]"; echo "\"\""; echo "
'; // option text echo $optiontext; echo "'; // limits // echo ""; if ($choice->limitanswers) { echo get_string("taken", "choice").":"; echo $columncount[$optionid]; // echo "
"; echo "   "; echo get_string("limit", "choice").":"; $choice_option = get_record("choice_options", "id", $optionid); echo $choice_option->maxanswers; echo "   "; if($choice_option->maxanswers - $columncount[$optionid]){ echo get_string("available", "choice").":"; echo ($choice_option->maxanswers - $columncount[$optionid]); } else { echo get_string("full", "choice"); } } else { if (isset($columncount[$optionid])) { echo $columncount[$optionid]; } } // echo "
$columncount[$optionid]'; // participants // added empty row so that when the next iteration is empty, // we do not get
erro from w3c validator // MDL-7861 echo ''; $width = 0; if (isset($allresponses[$optionid])) { if ($maxcolumn) { $width = $COLUMN_HEIGHT * ((float)$columncount[$optionid] / (float)$maxcolumn); } } echo ""; $count++; echo '
"; echo "\"\""; echo "
"; if ($viewresponses) { echo "
"; } break; } }