mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-9040: Enabled disabling of any buttons that always lead to errors. Javascript dynamically displays/hides buttons depending on which groupings/groups are selected. This required a number of extensive modifications, but degrades nicely without JS.
This commit is contained in:
parent
3c58497b82
commit
bd52a0145e
4 changed files with 161 additions and 106 deletions
114
group/group.php
114
group/group.php
|
@ -76,9 +76,6 @@ if ($success) {
|
|||
*/
|
||||
$success = (bool)$groupid = groups_create_group($courseid); //$groupsettings);
|
||||
|
||||
if ($groupingid != GROUP_NOT_IN_GROUPING) {
|
||||
$success = groups_add_group_to_grouping($groupid, $groupingid);
|
||||
}
|
||||
}
|
||||
elseif ($groupingid != $newgrouping) { //OK, move group.
|
||||
// Allow groups to be created outside of groupings
|
||||
|
@ -159,69 +156,72 @@ if ($success) {
|
|||
"-> $strgroups", '', '', true, '', user_login_string($course, $USER));
|
||||
|
||||
$usehtmleditor = false;
|
||||
?>
|
||||
<h3 class="main"><?php echo $strheading ?></h3>
|
||||
|
||||
<form action="group.php" method="post" enctype="multipart/form-data" class="mform notmform" id="groupform">
|
||||
echo '<h3 class="main">' . $strheading . '</h3>'."\n";
|
||||
|
||||
echo '<form action="group.php" method="post" enctype="multipart/form-data" class="mform notmform" id="groupform">'."\n";
|
||||
echo '<div>'."\n";
|
||||
echo '<input type="hidden" name="sesskey" value="' . s(sesskey()) . '" />'."\n";
|
||||
echo '<input type="hidden" name="courseid" value="' . s($courseid) . '" />'."\n";
|
||||
echo '<input type="hidden" name="grouping" value="' . s($groupingid) . '" />'."\n";
|
||||
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()); ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid); ?>" />
|
||||
<input type="hidden" name="grouping" value="<?php p($groupingid); ?>" />
|
||||
<?php
|
||||
if ($groupid) {
|
||||
echo '<input type="hidden" name="group" value="'. $groupid .'" />';
|
||||
echo '<input type="hidden" name="group" value="'. $groupid .'" />'."\n";
|
||||
}
|
||||
|
||||
if ($delete) {
|
||||
/*echo 'Are you sure you want to delete group X ?';
|
||||
choose_from_menu_yesno('confirmdelete', false, '', true);*/
|
||||
?>
|
||||
|
||||
<p><?php print_string('deletegroupconfirm', 'group', $strname); ?></p>
|
||||
<input type="hidden" name="delete" value="1" />
|
||||
<input type="submit" name="confirmdelete" value="<?php print_string('yes'); ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('no'); ?>" />
|
||||
<?php
|
||||
echo '<p>' . get_string('deletegroupconfirm', 'group', $strname) . '</p>'."\n";
|
||||
echo '<input type="hidden" name="delete" value="1" />'."\n";
|
||||
echo '<input type="submit" name="confirmdelete" value="' . get_string('yes') . '" />'."\n";
|
||||
echo '<input type="submit" name="cancel" value="' . get_string('no') . '" />'."\n";
|
||||
} else {
|
||||
?>
|
||||
echo '<div class="fitem">'."\n";
|
||||
echo '<p><label for="groupname">' . get_string('groupname', 'group');
|
||||
|
||||
<div class="fitem">
|
||||
<p><label for="groupname"><?php
|
||||
print_string('groupname', 'group');
|
||||
if (isset($err['name'])) {
|
||||
echo' ';
|
||||
echo ' ';
|
||||
formerr($err['name']);
|
||||
} ?> </label></p>
|
||||
<p class="felement"><input id="groupname" name="name" type="text" size="40" value="<?php echo $strname; ?>" /></p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<p><label for="edit-description"><?php print_string('groupdescription', 'group'); ?> </label></p>
|
||||
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, 'description', $strdesc); ?></p>
|
||||
echo ' </label></p>'."\n";
|
||||
echo '<p class="felement"><input id="groupname" name="name" type="text" size="40" value="' . $strname . '" /></p>'."\n";
|
||||
echo '</div>'."\n";
|
||||
|
||||
<p><label for="enrolmentkey"><?php print_string('enrolmentkey', 'group'); ?> </label></p>
|
||||
<p><input id="enrolmentkey" name="enrolmentkey" type="text" size="25" /></p>
|
||||
echo '<p><label for="edit-description">' . get_string('groupdescription', 'group') . ' </label></p>'."\n";
|
||||
echo '<p>' . print_textarea($usehtmleditor, 5, 45, 200, 400, 'description', $strdesc, 0, true) . '</p>'."\n";
|
||||
|
||||
<?php if ($printuploadpicture) { ?>
|
||||
<p><label for="menuhidepicture"><?php print_string('hidepicture', 'group'); ?> </label></p>
|
||||
<p><?php $options = array();
|
||||
echo '<p><label for="enrolmentkey">' . get_string('enrolmentkey', 'group') . ' </label></p>'."\n";
|
||||
echo '<p><input id="enrolmentkey" name="enrolmentkey" type="text" size="25" /></p>'."\n";
|
||||
|
||||
if ($printuploadpicture) {
|
||||
echo '<p><label for="menuhidepicture">' . get_string('hidepicture', 'group') . ' </label></p>'."\n";
|
||||
echo '<p>';
|
||||
$options = array();
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
choose_from_menu($options, 'hidepicture', isset($group)? $group->hidepicture: 1, '');?></p>
|
||||
choose_from_menu($options, 'hidepicture', isset($group)? $group->hidepicture: 1, '');
|
||||
echo '</p>'."\n";
|
||||
|
||||
<p><label ><?php /* for="imagefile" */ print_string('newpicture', 'group');
|
||||
echo '<p><label >' . get_string('newpicture', 'group');
|
||||
helpbutton('picture', get_string('helppicture'));
|
||||
print_string('maxsize', '', display_size($maxbytes), 'group');
|
||||
if (isset($err['imagefile'])) formerr($err['imagefile']);
|
||||
?> </label></p>
|
||||
<p><?php upload_print_form_fragment(1, array('imagefile'), null,false,null,0,0,false); ?></p>
|
||||
<?php
|
||||
echo get_string('maxsize', '', display_size($maxbytes), 'group');
|
||||
|
||||
if (isset($err['imagefile'])) {
|
||||
formerr($err['imagefile']);
|
||||
}
|
||||
|
||||
echo ' </label></p>'."\n";
|
||||
echo '<p>' . upload_print_form_fragment(1, array('imagefile'), null,false,null,0,0,true) . '</p>'."\n";
|
||||
}
|
||||
|
||||
if ($groupid) { //OK, editing - option to move grouping.
|
||||
?>
|
||||
<p><label for="groupings"><?php print_string('addgroupstogrouping', 'group'); ?></label></p>
|
||||
<select name="newgrouping" id="groupings" class="select">
|
||||
<?php
|
||||
|
||||
echo '<p><label for="groupings">' . get_string('addgroupstogrouping', 'group'). '</label></p>'."\n";
|
||||
echo '<select name="newgrouping" id="groupings" class="select">'."\n";
|
||||
|
||||
$groupingids = groups_get_groupings($courseid);
|
||||
if (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
$groupingids[] = GROUP_NOT_IN_GROUPING;
|
||||
|
@ -244,24 +244,24 @@ if ($success) {
|
|||
$count++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php } //IF($groupid) ?>
|
||||
|
||||
<p class="fitem">
|
||||
<label for="id_submit"> </label>
|
||||
<span class="f--element fsubmit">
|
||||
<input type="submit" name="update" id="id_submit" value="<?php echo $strbutton; ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel', 'group'); ?>" />
|
||||
</span>
|
||||
</p>
|
||||
echo '</select>'."\n";
|
||||
} //IF($groupid)
|
||||
|
||||
<?php } //IF($delete) ?>
|
||||
echo '<p class="fitem">'."\n";
|
||||
echo '<label for="id_submit"> </label>'."\n";
|
||||
echo '<span class="f--element fsubmit">'."\n";
|
||||
echo '<input type="submit" name="update" id="id_submit" value="' . $strbutton . '" />'."\n";
|
||||
echo '<input type="submit" name="cancel" value="' . get_string('cancel', 'group') . '" />'."\n";
|
||||
echo '</span>'."\n";
|
||||
echo '</p>'."\n";
|
||||
|
||||
<span class="clearer"> </span>
|
||||
} //IF($delete)
|
||||
|
||||
echo '<span class="clearer"> </span>'."\n";
|
||||
echo '</div>';
|
||||
echo '</form>'."\n";
|
||||
|
||||
</form>
|
||||
<?php
|
||||
print_footer($course);
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ if ($success) {
|
|||
*/
|
||||
redirect(groups_group_edit_url($courseid, null, $groupingid, false));
|
||||
break;
|
||||
case 'showcreateorphangroupform':
|
||||
redirect(groups_group_edit_url($courseid, null, null, false));
|
||||
break;
|
||||
case 'addgroupstogroupingform':
|
||||
break;
|
||||
case 'updategroups': //Currently reloading.
|
||||
|
@ -154,8 +157,36 @@ if ($success) {
|
|||
"-> $strgroups", '', '', true, '', user_login_string($course, $USER));
|
||||
|
||||
$usehtmleditor = false;
|
||||
//TODO: eventually we'll implement all buttons, meantime hide the ones we haven't finised.
|
||||
//TODO: eventually we'll implement all buttons, meantime hide the ones we haven't finished.
|
||||
$shownotdone = false;
|
||||
$disabled = 'disabled="disabled"';
|
||||
|
||||
// Pre-disable buttons based on URL variables
|
||||
if (isset($groupingid) && $groupingid > -1) {
|
||||
$showeditgroupsettingsform_disabled = '';
|
||||
$showeditgroupingsettingsform_disabled = '';
|
||||
$deletegroup_disabled = '';
|
||||
$deletegrouping_disabled = '';
|
||||
$printerfriendly_disabled = '';
|
||||
$showcreategroupform_disabled = '';
|
||||
} else {
|
||||
$showeditgroupsettingsform_disabled = $disabled;
|
||||
$showeditgroupingsettingsform_disabled = $disabled;
|
||||
$deletegroup_disabled = $disabled;
|
||||
$deletegrouping_disabled = $disabled;
|
||||
$printerfriendly_disabled = $disabled;
|
||||
$showcreategroupform_disabled = $disabled;
|
||||
}
|
||||
|
||||
if (isset($groupid)) {
|
||||
$showaddmembersform_disabled = '';
|
||||
$showeditgroupsettingsform_disabled = '';
|
||||
$deletegroup_disabled = '';
|
||||
} else {
|
||||
$deletegroup_disabled = $disabled;
|
||||
$showeditgroupsettingsform_disabled = $disabled;
|
||||
$showaddmembersform_disabled = $disabled;
|
||||
}
|
||||
|
||||
print_heading(format_string($course->shortname) .' '.$strgroups, 'center', 3);
|
||||
echo '<form id="groupeditform" action="index.php" method="post">'."\n";
|
||||
|
@ -201,29 +232,30 @@ if ($success) {
|
|||
}
|
||||
echo '</select>'."\n";
|
||||
|
||||
|
||||
echo '<p><input type="submit" name="act_updategroups" id="updategroups" value="'
|
||||
. get_string('showgroupsingrouping', 'group') . '" /></p>'."\n";
|
||||
echo '<p><input type="submit" name="act_showgroupingsettingsform" id="showeditgroupingsettingsform" value="'
|
||||
echo '<p><input type="submit" ' . $showeditgroupingsettingsform_disabled . ' name="act_showgroupingsettingsform" id="showeditgroupingsettingsform" value="'
|
||||
. get_string('editgroupingsettings', 'group') . '" /></p>'."\n";
|
||||
|
||||
if ($shownotdone) {
|
||||
echo '<p><input type="submit" disabled="disabled" name="act_showgroupingpermsform" '
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_showgroupingpermsform" '
|
||||
. 'id="showeditgroupingpermissionsform" value="'
|
||||
. get_string('editgroupingpermissions', 'group') . '" /></p>'."\n";
|
||||
}
|
||||
|
||||
echo '<p><input type="submit" name="act_deletegrouping" id="deletegrouping" value="'
|
||||
echo '<p><input type="submit" ' . $deletegrouping_disabled . ' name="act_deletegrouping" id="deletegrouping" value="'
|
||||
. get_string('deletegrouping', 'group') . '" /></p>'."\n";
|
||||
echo '<p><input type="submit" name="act_showcreategroupingform" id="showcreategroupingform" value="'
|
||||
. get_string('creategrouping', 'group') . '" /></p>'."\n";
|
||||
|
||||
if ($shownotdone) {
|
||||
echo '<p><input type="submit" disabled="disabled" name="act_createautomaticgroupingform" '
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_createautomaticgroupingform" '
|
||||
. 'id="showcreateautomaticgroupingform" value="'
|
||||
. get_string('createautomaticgrouping', 'group') . '" /></p>'."\n";
|
||||
}
|
||||
|
||||
echo '<p><input type="submit" name="act_printerfriendly" id="printerfriendly" value="'
|
||||
echo '<p><input type="submit" ' . $printerfriendly_disabled . ' name="act_printerfriendly" id="printerfriendly" value="'
|
||||
. get_string('printerfriendly', 'group') . '" /></p>'."\n";
|
||||
echo "</td>\n<td>\n";
|
||||
echo '<p><label for="groups" id="groupslabel">' .get_string('groupsinselectedgrouping', 'group') . '</label></p>'."\n";
|
||||
|
@ -257,21 +289,24 @@ if ($success) {
|
|||
echo '</select>'."\n";
|
||||
echo '<p><input type="submit" name="act_updatemembers" id="updatemembers" value="'
|
||||
. get_string('showmembersforgroup', 'group') . '" /></p>'."\n";
|
||||
echo '<p><input type="submit" name="act_showgroupsettingsform" id="showeditgroupsettingsform" value="'
|
||||
echo '<p><input type="submit" '. $showeditgroupsettingsform_disabled . ' name="act_showgroupsettingsform" id="showeditgroupsettingsform" value="'
|
||||
. get_string('editgroupsettings', 'group') . '" /></p>'."\n";
|
||||
echo '<p><input type="submit" name="act_deletegroup" onclick="onDeleteGroup()" id="deletegroup" value="'
|
||||
echo '<p><input type="submit" '. $deletegroup_disabled . ' name="act_deletegroup" onclick="onDeleteGroup()" id="deletegroup" value="'
|
||||
. get_string('deleteselectedgroup', 'group') . '" /></p>'."\n";
|
||||
|
||||
if ($shownotdone) {
|
||||
echo '<p><input type="submit" disabled="disabled" name="act_removegroup" '
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_removegroup" '
|
||||
. 'id="removegroup" value="' . get_string('removegroupfromselectedgrouping', 'group') . '" /></p>'."\n";
|
||||
}
|
||||
|
||||
echo '<p><input type="submit" name="act_showcreategroupform" id="showcreategroupform" value="'
|
||||
echo '<p><input type="submit" ' . $showcreategroupform_disabled . ' name="act_showcreategroupform" id="showcreategroupform" value="'
|
||||
. get_string('creategroupinselectedgrouping', 'group') . '" /></p>'."\n";
|
||||
|
||||
echo '<p><input type="submit" name="act_showcreateorphangroupform" id="showcreateorphangroupform" value="'
|
||||
. get_string('createorphangroup', 'group') . '" /></p>'."\n";
|
||||
|
||||
if ($shownotdone) {
|
||||
echo '<p><input type="submit" disabled="disabled" name="act_addgroupstogroupingform" '
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_addgroupstogroupingform" '
|
||||
. 'id="showaddgroupstogroupingform" value="' . get_string('addgroupstogrouping', 'group') . '" /></p>'."\n";
|
||||
}
|
||||
|
||||
|
@ -298,11 +333,11 @@ if ($success) {
|
|||
echo '</select>'."\n";
|
||||
|
||||
if ($shownotdone) {
|
||||
echo '<p><input type="submit" disabled="disabled" name="act_removemembers" '
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_removemembers" '
|
||||
. 'id="removemembers" value="' . get_string('removeselectedusers', 'group') . '"/></p>'."\n";
|
||||
}
|
||||
|
||||
echo '<p><input type="submit" name="act_showaddmembersform" '
|
||||
echo '<p><input type="submit" ' . $showaddmembersform_disabled . ' name="act_showaddmembersform" '
|
||||
. 'id="showaddmembersform" value="' . get_string('adduserstogroup', 'group'). '" /></p>'."\n";
|
||||
echo '</td>'."\n";
|
||||
echo '</tr>'."\n";
|
||||
|
|
|
@ -80,6 +80,20 @@ UpdatableGroupsCombo.prototype.refreshGroups = function (groupingId) {
|
|||
}
|
||||
}
|
||||
|
||||
if (groupingId > -1) {
|
||||
document.getElementById("showaddmembersform").disabled = true;
|
||||
document.getElementById("showeditgroupingsettingsform").disabled = false;
|
||||
document.getElementById("deletegrouping").disabled = false;
|
||||
document.getElementById("printerfriendly").disabled = false;
|
||||
document.getElementById("showeditgroupsettingsform").disabled = true;
|
||||
document.getElementById("deletegroup").disabled = true;
|
||||
document.getElementById("showcreategroupform").disabled = false;
|
||||
} else {
|
||||
document.getElementById("showeditgroupingsettingsform").disabled = true;
|
||||
document.getElementById("deletegrouping").disabled = true;
|
||||
document.getElementById("showcreategroupform").disabled = true;
|
||||
}
|
||||
|
||||
var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&grouping="+groupingId+"&act_ajax_getgroupsingrouping";
|
||||
YAHOO.util.Connect.asyncRequest('GET', sUrl, this.connectCallback, null);
|
||||
};
|
||||
|
@ -127,6 +141,8 @@ function UpdatableMembersCombo(wwwRoot, courseId) {
|
|||
|
||||
/**
|
||||
* When a group is selected, we need to update the members.
|
||||
* The Add/Remove Users button also needs to be disabled/enabled
|
||||
* depending on whether or not a group is selected
|
||||
*/
|
||||
UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
|
||||
// Add the loader gif image.
|
||||
|
@ -140,6 +156,9 @@ UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
|
|||
}
|
||||
}
|
||||
|
||||
document.getElementById("showaddmembersform").disabled = false;
|
||||
document.getElementById("showeditgroupsettingsform").disabled = false;
|
||||
document.getElementById("deletegroup").disabled = false;
|
||||
var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&group="+groupId+"&act_ajax_getmembersingroup";
|
||||
YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null);
|
||||
};
|
||||
|
|
|
@ -67,6 +67,7 @@ $string['selectnumberofgroups'] = 'Select number of groups';
|
|||
$string['numberofgroups'] = 'Number of groups';
|
||||
$string['creategrouping'] = 'Create grouping';
|
||||
$string['creategroup'] = 'Create group';
|
||||
$string['createorphangroup'] = 'Create Orphan group';
|
||||
|
||||
$string['groupname'] = 'Group name';
|
||||
$string['defaultgroupname'] = 'Group';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue