Skip to content

Commit

Permalink
Bugfix : don't allow remove choice after choicegroup has closed
Browse files Browse the repository at this point in the history
  • Loading branch information
ndunand committed Jul 12, 2017
1 parent c366bfd commit 3721cf2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@
class mod_choicegroup_renderer extends plugin_renderer_base {

/**
* Returns HTML to display choicegroups of option
* @param object $options
* @param int $coursemoduleid
* @param $options
* @param $coursemoduleid
* @param bool $vertical
* @param bool $publish
* @param bool $limitanswers
* @param bool $showresults
* @param bool $current
* @param bool $choicegroupopen
* @param bool $disabled
* @param bool $multipleenrollmentspossible
*
* @return string
*/
public function display_options($options, $coursemoduleid, $vertical = true, $publish = false, $limitanswers = false, $showresults = false, $current = false, $choicegroupopen = false, $disabled = false, $multipleenrollmentspossible = false) {
Expand Down Expand Up @@ -166,7 +173,7 @@ public function display_options($options, $coursemoduleid, $vertical = true, $pu
}
}

if (!empty($options['allowupdate']) && ($options['allowupdate']) && !($multipleenrollmentspossible == 1)) {
if (!empty($options['allowupdate']) && ($options['allowupdate']) && !($multipleenrollmentspossible == 1) && !$disabled) {
$url = new moodle_url('view.php', array('id'=>$coursemoduleid, 'action'=>'delchoicegroup', 'sesskey'=>sesskey()));
$html .= ' ' . html_writer::link($url, get_string('removemychoicegroup','choicegroup'));
}
Expand Down
2 changes: 1 addition & 1 deletion view.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
);

$current = choicegroup_get_user_answer($choicegroup, $USER);
if ($action == 'delchoicegroup' and confirm_sesskey() and is_enrolled($context, NULL, 'mod/choicegroup:choose') and $choicegroup->allowupdate) {
if ($action == 'delchoicegroup' and confirm_sesskey() and is_enrolled($context, NULL, 'mod/choicegroup:choose') and $choicegroup->allowupdate and !($choicegroup->timeclose and (time() > $choicegroup->timeclose))) {
// user wants to delete his own choice:
if ($current !== false) {
if (groups_is_member($current->id, $USER->id)) {
Expand Down

0 comments on commit 3721cf2

Please sign in to comment.