Permalink
Browse files

MDL-23867 - fixed errors when there are no enrolled users.

also fixed incomplete use of moodle_url (MDL-19805).
  • Loading branch information...
1 parent ed22700 commit 9d624d66945c1970f2418fbf18e1a66be504ad20 Rossiani Wijaya committed Aug 19, 2010
Showing with 12 additions and 16 deletions.
  1. +7 −10 mod/choice/lib.php
  2. +5 −6 mod/choice/view.php
View
@@ -339,8 +339,8 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
$display = clone($choice);
$display->coursemoduleid = $cm->id;
- $display->courseid = $course->id;
-
+ $display->courseid = $course->id;
+
//overwrite options value;
$display->options = array();
$totaluser = 0;
@@ -352,7 +352,7 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
if (array_key_exists($optionid, $allresponses)) {
$display->options[$optionid]->user = $allresponses[$optionid]; //->user;
$totaluser += count($allresponses[$optionid]);
- }
+ }
}
unset($display->option);
unset($display->maxanswers);
@@ -362,7 +362,7 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
$display->viewresponsecapability = has_capability('mod/choice:readresponses', $context);
$display->deleterepsonsecapability = has_capability('mod/choice:deleteresponses',$context);
$display->fullnamecapability = has_capability('moodle/site:viewfullnames', $context);
-
+
if (empty($allresponses)) {
echo $OUTPUT->heading(get_string("nousersyet"));
return false;
@@ -504,9 +504,9 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
echo "</form></div>";
}
break;
- }
+ }
return $display;
- }
+}
/**
* @global object
@@ -739,10 +739,7 @@ function choice_get_response_data($choice, $cm, $groupmode) {
unset($allresponses[0][$response->userid]); // Remove from unanswered column
}
}
- }
- if (empty($allresponses[0])) {
- unset($allresponses[0]);
- }
+ }
return $allresponses;
}
View
@@ -128,8 +128,7 @@
if (isguestuser()) {
// Guest account
echo $OUTPUT->confirm(get_string('noguestchoose', 'choice').'<br /><br />'.get_string('liketologin'),
- get_login_url(), new moodle_url);
-
+ get_login_url(), new moodle_url('/course/view.php', array('id'=>$course->id)));
} else if (!is_enrolled($context)) {
// Only people enrolled can make a choice
$SESSION->wantsurl = $FULLME;
@@ -140,7 +139,7 @@
echo $OUTPUT->container_start('continuebutton');
echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id'=>$course->id)), get_string('enrolme', 'core_enrol', format_string($course->shortname)));
echo $OUTPUT->container_end();
- echo $OUTPUT->box_end();
+ echo $OUTPUT->box_end();
}
}
@@ -155,9 +154,9 @@
$choice->maxanswers[0] = 0;
}
- $results = prepare_choice_show_results($choice, $course, $cm, $allresponses);
- $renderer = $PAGE->get_renderer('mod_choice');
-
+ $results = prepare_choice_show_results($choice, $course, $cm, $allresponses);
+ $renderer = $PAGE->get_renderer('mod_choice');
+
echo $renderer->display_result($results);
} else if (!$choiceformshown) {
echo $OUTPUT->box(get_string('noresultsviewable', 'choice'));

0 comments on commit 9d624d6

Please sign in to comment.