diff --git a/grade/export/grade_export_form.php b/grade/export/grade_export_form.php
index 439a26e5b53..925a31c3e23 100755
--- a/grade/export/grade_export_form.php
+++ b/grade/export/grade_export_form.php
@@ -45,7 +45,7 @@ class grade_export_form extends moodleform {
$mform->addElement('select', 'previewrows', get_string('previewrows', 'grades'), $options);
$mform->addElement('advcheckbox', 'updatedgradesonly', get_string('updatedgradesonly', 'grades'));
-
+
/// selections for decimal points and format, MDL-11667, defaults to site settings, if set
//$default_gradedisplaytype = $CFG->grade_export_displaytype;
$options = array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
@@ -63,6 +63,15 @@ class grade_export_form extends moodleform {
$mform->addElement('select', 'display', get_string('gradeexportdisplaytype', 'grades'), $options);
$mform->setDefault('display', $CFG->grade_export_displaytype);
+ $mform->addElement('advcheckbox', 'test1', 'Test 1', null, array('group' => 2));
+ $mform->addElement('advcheckbox', 'test2', 'Test 2', null, array('group' => 2));
+ $mform->addElement('selectallornone', 2);
+ $mform->addElement('advcheckbox', 'test3', 'Test 3', null, array('group' => 3));
+ $mform->addElement('advcheckbox', 'test4', 'Test 4', null, array('group' => 3));
+ $mform->addElement('selectallornone', 3, get_string("checkallornone"), array('style' => 'font-weight: bold;'), 1);
+ $mform->setDefault('test3', 1);
+ $mform->setDefault('test4', 1);
+
//$default_gradedecimals = $CFG->grade_export_decimalpoints;
$options = array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
$mform->addElement('select', 'decimals', get_string('gradeexportdecimalpoints', 'grades'), $options);
@@ -125,16 +134,21 @@ class grade_export_form extends moodleform {
$total = $grade_items[1];
unset($grade_items[1]);
$grade_items[] = $total;
+ $needs_multiselect = false;
foreach ($grade_items as $grade_item) {
if (!empty($features['idnumberrequired']) and empty($grade_item->idnumber)) {
$mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), get_string('noidnumber', 'grades'));
$mform->hardFreeze('itemids['.$grade_item->id.']');
-
} else {
- $mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name());
+ $mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), null, array('group' => 1));
$mform->setDefault('itemids['.$grade_item->id.']', 1);
+ $needs_multiselect = true;
}
}
+
+ if ($needs_multiselect) {
+ $mform->addElement('selectallornone', 1, null, null, 1); // 2nd argument is group name, 3rd is link text, 4th is attributes and 5th is original value
+ }
}
$mform->addElement('hidden', 'id', $COURSE->id);
diff --git a/lib/form/advcheckbox.php b/lib/form/advcheckbox.php
index 2c048c0d3d6..79187dafb75 100644
--- a/lib/form/advcheckbox.php
+++ b/lib/form/advcheckbox.php
@@ -17,6 +17,13 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{
* @var string
*/
var $_helpbutton='';
+
+ /**
+ * Group to which this checkbox belongs (for select all/select none button)
+ * @var string $_group
+ */
+ var $_group;
+
/**
* Class constructor
*
@@ -36,6 +43,34 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{
if ($values === null){
$values = array(0, 1);
}
+
+ if (!is_null($attributes['group'])) {
+
+ $select_value = optional_param('select'. $attributes['group'], null, PARAM_INT);
+ if ($select_value == 1) {
+ $this->setValue(1);
+ } elseif ($select_value == 0) {
+ $this->setValue(0);
+ }
+
+ $this->_group = 'checkboxgroup' . $attributes['group'];
+ unset($attributes['group']);
+ if (is_null($attributes)) {
+ $attributes = array();
+ $attributes['class'] .= " $this->_group";
+ } elseif (is_array($attributes)) {
+ if (isset($attributes['class'])) {
+ $attributes['class'] .= " $this->_group";
+ } else {
+ $attributes['class'] = $this->_group;
+ }
+ } elseif ($strpos = stripos($attributes, 'class="')) {
+ $attributes = str_ireplace('class="', 'class="' . $this->_group . ' ', $attributes);
+ } else {
+ $attributes .= ' class="' . $this->_group . '"';
+ }
+ }
+
parent::HTML_QuickForm_advcheckbox($elementName, $elementLabel, $text, $attributes, $values);
} //end constructor
@@ -112,4 +147,4 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{
} //end func getFrozenHtml
}
-?>
\ No newline at end of file
+?>
diff --git a/lib/form/selectallornone.php b/lib/form/selectallornone.php
new file mode 100644
index 00000000000..32e099d00f2
--- /dev/null
+++ b/lib/form/selectallornone.php
@@ -0,0 +1,126 @@
+
+ * @version 1.0
+ * @since PHP4.04pl1
+ * @access public
+ */
+class MoodleQuickForm_selectallornone extends HTML_QuickForm_link {
+ /**
+ * The original state of the checkboxes controlled by this element. This determines whether the first click of this element will switch them all to
+ * checked or to unchecked. It doesn't change the checked state of the original elements (there could be a mixed of checked/unchecked there), but
+ * there has to be a decision as to which action will be taken by clicking "select all/select none" the first time.
+ * @var int $originalValue
+ */
+ var $_originalValue = 0;
+
+ /**
+ * Constructor
+ * @param string $elementName The name of the group of advcheckboxes this element controls
+ * @param string $text The text of the link. Defaults to "select all/none"
+ * @param array $attributes associative array of HTML attributes
+ * @param int $originalValue The original general state of the checkboxes before the user first clicks this element
+ */
+ function MoodleQuickForm_selectallornone($elementName=null, $text=null, $attributes=null, $originalValue=0) {
+ if (is_null($originalValue)) {
+ $originalValue = 0;
+ }
+
+ global $FULLME;
+ $this->_originalValue = $originalValue;
+
+ if (is_null($elementName)) {
+ return;
+ }
+ $elementLabel = ' ';
+ $strselectallornone = get_string('selectallornone', 'form');
+ $attributes['onmouseover'] = "window.status='" . $strselectallornone . "';";
+ $attributes['onmouseout'] = "window.status='';";
+ $attributes['onclick'] = "html_quickform_toggle_checkboxes($elementName); return false;";
+ $select_value = optional_param('select'. $elementName, $originalValue, PARAM_INT);
+
+ if ($select_value == 0) {
+ $new_select_value = 1;
+ } else {
+ $new_select_value = 0;
+ }
+
+ $old_selectstr = "&select$elementName=$select_value";
+ $new_selectstr = "&select$elementName=$new_select_value";
+ $new_fullme = str_replace($old_selectstr, '', $FULLME);
+
+ $href = "$new_fullme$new_selectstr";
+
+ if (empty($text)) {
+ $text = $strselectallornone;
+ }
+ $this->HTML_QuickForm_link($elementName, $elementLabel, $href, $text, $attributes);
+ }
+
+ function toHtml() {
+ if (is_null($this->_originalValue)) {
+ return false;
+ }
+
+ $group = $this->_attributes['name'];
+ if ($this->_flagFrozen) {
+ $js = '';
+ } else {
+ $js = "";
+ }
+ return $js . parent::toHtml();
+ }
+}
+?>
diff --git a/lib/formslib.php b/lib/formslib.php
index dd22a58bb2a..8c3eacb35b2 100644
--- a/lib/formslib.php
+++ b/lib/formslib.php
@@ -1786,6 +1786,7 @@ MoodleQuickForm::registerElementType('passwordunmask', "$CFG->libdir/form/passwo
MoodleQuickForm::registerElementType('radio', "$CFG->libdir/form/radio.php", 'MoodleQuickForm_radio');
MoodleQuickForm::registerElementType('select', "$CFG->libdir/form/select.php", 'MoodleQuickForm_select');
MoodleQuickForm::registerElementType('selectgroups', "$CFG->libdir/form/selectgroups.php", 'MoodleQuickForm_selectgroups');
+MoodleQuickForm::registerElementType('selectallornone', "$CFG->libdir/form/selectallornone.php", 'MoodleQuickForm_selectallornone');
MoodleQuickForm::registerElementType('text', "$CFG->libdir/form/text.php", 'MoodleQuickForm_text');
MoodleQuickForm::registerElementType('textarea', "$CFG->libdir/form/textarea.php", 'MoodleQuickForm_textarea');
MoodleQuickForm::registerElementType('date_selector', "$CFG->libdir/form/dateselector.php", 'MoodleQuickForm_date_selector');
diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php
index 8375bf66e9a..25e8345e234 100644
--- a/lib/grade/grade_category.php
+++ b/lib/grade/grade_category.php
@@ -7,7 +7,7 @@
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
diff --git a/lib/javascript.php b/lib/javascript.php
index bbf26ef6d5f..7d9f2e0b661 100644
--- a/lib/javascript.php
+++ b/lib/javascript.php
@@ -87,5 +87,34 @@ function inserttext(text) {
$focus=false; // Prevent themes from adding it to body tag which breaks addonload(), MDL-10249
} ?>
+function getElementsByClassName(oElm, strTagName, oClassNames){
+ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
+ var arrReturnElements = new Array();
+ var arrRegExpClassNames = new Array();
+ if(typeof oClassNames == "object"){
+ for(var i=0; i