Skip to content

Commit

Permalink
MDL-23867 - fixed errors when there are no enrolled users.
Browse files Browse the repository at this point in the history
also fixed incomplete use of moodle_url (MDL-19805).
  • Loading branch information
rwijaya committed Aug 19, 2010
1 parent ed22700 commit 9d624d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
17 changes: 7 additions & 10 deletions mod/choice/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -504,9 +504,9 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
echo "</form></div>";
}
break;
}
}
return $display;
}
}

/**
* @global object
Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 5 additions & 6 deletions mod/choice/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

}
}
Expand All @@ -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'));
Expand Down

0 comments on commit 9d624d6

Please sign in to comment.