From a23f0aaf9570886bf5803459f0018dd68e835328 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Tue, 19 Dec 2006 07:03:08 +0000 Subject: [PATCH] * Added setAdvanced functionality see http://docs.moodle.org/en/Development:lib/formslib.php_setAdvanced * Added MoodleQuickForm method closeHeaderBefore($elementName); http://docs.moodle.org/en/Development:lib/formslib.php_Form_Definition#Use_Fieldsets_to_group_Form_Elements * Added moodleform method add_action_buttons(); see http://docs.moodle.org/en/Development:lib/formslib.php_Form_Definition#add_action_buttons.28.24cancel_.3D_true.2C_.24revert_.3D_true.2C_.24submitlabel.3Dnull.29.3B * is_cancelled method added to moodleform http://docs.moodle.org/en/Development:lib/formslib.php_Usage#Basic_Usage_in_A_Normal_Page * added hidden labels to elements within groups such as the date_selector select boxes and other elements in 'groups' * quiz/mod.html migrated to formslib * glossary/edit.html migrated to formslib * extended registerNoSubmitButton() functionality to automatically add js to onclick to bypass client side js input validation. * added no_submit_button_pressed() function that can be used in a similar way to is_cancelled() as a test in the main script to see if some button in the page has been pressed that is a submit button that is used for some dynamic functionality within the form and not to submit the data for the whole form. * added new condition for disabledIf which allows to disable another form element if no options are selected from within a select element. * added default 'action' for moodleform - strip_querystring(qualified_me()) http://docs.moodle.org/en/Development:lib/formslib.php_Usage#Basic_Usage_in_A_Normal_Page --- course/edit.php | 9 +- course/edit_form.php | 7 +- course/request.php | 16 +- course/request_form.php | 2 +- enrol/authorize/enrol_form.php | 4 +- lang/en_utf8/form.php | 4 + lang/en_utf8/glossary.php | 6 +- lib/form/adv.gif | Bin 0 -> 234 bytes lib/form/adv.png | Bin 0 -> 29186 bytes lib/form/cancel.php | 6 +- lib/form/checkbox.php | 37 ++ lib/form/format.php | 10 +- lib/form/header.php | 64 ++ lib/form/select.php | 12 + lib/form/submit.php | 45 ++ lib/formslib.php | 199 ++++-- lib/javascript-static.js | 22 +- login/change_password_form.php | 10 +- login/forgot_password_form.php | 8 +- login/signup_form.php | 7 +- .../type/online/assignment.class.php | 7 +- .../type/upload/assignment.class.php | 7 +- mod/chat/mod_form.php | 7 +- mod/choice/mod_form.php | 8 +- mod/data/comment_form.php | 7 +- mod/data/mod_form.php | 9 +- mod/exercise/mod_form.php | 9 +- mod/forum/mod_form.php | 9 +- mod/forum/post_form.php | 5 +- mod/glossary/comment_form.php | 8 +- mod/glossary/edit.html | 196 ------ mod/glossary/edit.php | 353 ++++------- mod/glossary/edit_form.php | 141 +++++ mod/glossary/mod_form.php | 10 +- mod/journal/mod_form.php | 8 +- mod/label/mod_form.php | 10 +- mod/lesson/mod_form.php | 9 +- mod/quiz/lib.php | 49 +- mod/quiz/mod.html | 570 ------------------ mod/quiz/mod_form.php | 334 ++++++++++ mod/survey/details.php | 4 +- theme/standard/styles_layout.css | 5 +- 42 files changed, 1007 insertions(+), 1226 deletions(-) create mode 100644 lib/form/adv.gif create mode 100644 lib/form/adv.png create mode 100644 lib/form/header.php create mode 100644 lib/form/submit.php delete mode 100644 mod/glossary/edit.html create mode 100644 mod/glossary/edit_form.php delete mode 100644 mod/quiz/mod.html create mode 100644 mod/quiz/mod_form.php diff --git a/course/edit.php b/course/edit.php index 80d4bb7fb2..886b1a8e0e 100644 --- a/course/edit.php +++ b/course/edit.php @@ -60,10 +60,15 @@ if (!empty($course)) { /// first create the form $editform = new course_edit_form('edit.php', compact('course', 'category')); + if ($editform->is_cancelled()){ + if (empty($course)) { + redirect($CFG->wwwroot); + } else { + redirect($CFG->wwwroot.'/course/view.php?id='.$course->id); + } - + } elseif ($data = $editform->data_submitted()) { /// process data if submitted - if ($data = $editform->data_submitted()) { //preprocess data if ($data->enrolstartdisabled){ diff --git a/course/edit_form.php b/course/edit_form.php index 7660bf9529..cfcb3324a9 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -8,7 +8,6 @@ class course_edit_form extends moodleform { global $USER, $CFG; $mform =& $this->_form; - $renderer =& $mform->defaultRenderer(); $course = $this->_customdata['course']; $category = $this->_customdata['category']; @@ -92,7 +91,7 @@ class course_edit_form extends moodleform { $formcourseformats["$courseformat"] = get_string("format$courseformat","format_$courseformat"); if($formcourseformats["$courseformat"]=="[[format$courseformat]]") { $formcourseformats["$courseformat"] = get_string("format$courseformat"); - } + } } $mform->addElement('select', 'format', get_string('format'), $formcourseformats); $mform->setHelpButton('format', array('courseformats', get_string('courseformats')), true); @@ -356,7 +355,7 @@ class course_edit_form extends moodleform { $mform->setType('restrictmodules', PARAM_INT); //-------------------------------------------------------------------------------- - $mform->addElement('submit', 'submitbutton', get_string('savechanges')); + $this->add_action_buttons(); //-------------------------------------------------------------------------------- $mform->addElement('hidden', 'id', null); $mform->setType('id', PARAM_INT); @@ -368,8 +367,6 @@ class course_edit_form extends moodleform { $mform->addElement('hidden', 'students', get_string('defaultcoursestudents')); -//-------------------------------------------------------------------------------- - $renderer->addStopFieldsetElements('submitbutton'); // now override defaults if course already exists diff --git a/course/request.php b/course/request.php index 4cf58e957c..02589c295d 100644 --- a/course/request.php +++ b/course/request.php @@ -25,8 +25,11 @@ print_simple_box_end(); - if (($data = $requestform->data_submitted())) { + if ($requestform->is_cancelled()){ + redirect($CFG->wwwroot); + + }elseif ($data = $requestform->data_submitted()) { $data->requester = $USER->id; if (insert_record('course_request', $data)) { @@ -34,17 +37,12 @@ } else { notice(get_string('courserequestfailed')); } - print_footer(); - exit; - - } + } else { - $requestform->display(); + $requestform->display(); + } print_footer(); - exit; - - ?> \ No newline at end of file diff --git a/course/request_form.php b/course/request_form.php index 3f183bad8a..8d09ce139e 100644 --- a/course/request_form.php +++ b/course/request_form.php @@ -26,7 +26,7 @@ class course_request_form extends moodleform { $mform->setType('password', PARAM_RAW); - $mform->addElement('submit', '', get_string('savechanges')); + $this->add_action_buttons(); } function validation($data) { diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index 3d8b6c3bff..63a4453259 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -16,7 +16,6 @@ class authorize_enrol_form extends moodleform } $mform =& $this->_form; - $renderer =& $mform->defaultRenderer(); $mform->addElement('header', '', '  ' . get_string('paymentrequired'), ''); if ($othermethodstr = other_method($paymentmethod)) { @@ -173,8 +172,7 @@ class authorize_enrol_form extends moodleform $mform->addRule('cczip', get_string('missingzip', 'enrol_authorize'), 'required', null, 'client'); $mform->addRule('cczip', get_string('missingzip', 'enrol_authorize'), 'numeric', null, 'client'); - $mform->addElement('submit', 'submit', get_string('sendpaymentbutton', 'enrol_authorize')); - $renderer->addStopFieldsetElements('submit'); + $this->add_action_buttons(false, true, get_string('sendpaymentbutton', 'enrol_authorize')); } function validation($data) diff --git a/lang/en_utf8/form.php b/lang/en_utf8/form.php index c1ee2eea58..b230ebbb4f 100644 --- a/lang/en_utf8/form.php +++ b/lang/en_utf8/form.php @@ -27,4 +27,8 @@ $string['minute']='Minute'; $string['advancedelement']='Advanced Element'; $string['hideadvanced']='Hide Advanced'; $string['showadvanced']='Show Advanced'; + +$string['timing'] = 'Timing'; +$string['security'] = 'Security'; +$string['display'] = 'Display'; ?> \ No newline at end of file diff --git a/lang/en_utf8/glossary.php b/lang/en_utf8/glossary.php index 70e50311da..bc7f66cfd7 100644 --- a/lang/en_utf8/glossary.php +++ b/lang/en_utf8/glossary.php @@ -1,4 +1,4 @@ -#sNdEu-AE=3Vp!k!8k)1(+K?kG-WG4e_x`IkyN+cU|;;c>vhQnS$ ztO*L;Hv3L7noMYMO4X8J;Ba7iRKc3U;=m|$lu>3ii-I|WjbJPD;Ug9%qK-G5b{26; s+;wAI$h{}wmQ3=gA{%K2_67zkC3ihm7b`A(rdDN6X8-;vQxzGk0kQBy$^ZZW literal 0 HcmV?d00001 diff --git a/lib/form/adv.png b/lib/form/adv.png new file mode 100644 index 0000000000000000000000000000000000000000..e0694e8452d9125c6a670362a047a40afefea72d GIT binary patch literal 29186 zcmbSybzD`?(=Z?*ilEYsqI8OMN(e{`NP~!gNOxYYh=9`F-ICH>5|_Mm$E7cIsY~8` z`Tl;-?|I+%`SUrS-7~X$X3x&fo}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f(N<5GKbS)Y0pGThBFyeTa$Xf>Rb^_WOv3&fsX#j# literal 0 HcmV?d00001 diff --git a/lib/form/cancel.php b/lib/form/cancel.php index 88ca84e3ab..ed263ec4f8 100644 --- a/lib/form/cancel.php +++ b/lib/form/cancel.php @@ -7,7 +7,7 @@ require_once('HTML/QuickForm/submit.php'); * @author Jamie Pratt * @access public */ -class MoodleQuickForm_cancel extends HTML_QuickForm_submit +class MoodleQuickForm_cancel extends MoodleQuickForm_submit { // {{{ constructor @@ -26,7 +26,7 @@ class MoodleQuickForm_cancel extends HTML_QuickForm_submit if ($value==null){ $value=get_string('cancel'); } - HTML_QuickForm_submit::HTML_QuickForm_submit($elementName, $value, $attributes); + MoodleQuickForm_submit::MoodleQuickForm_submit($elementName, $value, $attributes); $this->updateAttributes(array('onclick'=>'skipClientValidation = true; return true;')); } //end constructor function onQuickFormEvent($event, $arg, &$caller) @@ -43,5 +43,5 @@ class MoodleQuickForm_cancel extends HTML_QuickForm_submit } // end func onQuickFormEvent // }}} -} //end class HTML_QuickForm_submit +} //end class MoodleQuickForm_cancel ?> \ No newline at end of file diff --git a/lib/form/checkbox.php b/lib/form/checkbox.php index 9c13dcaafd..f1eaaa4bd8 100644 --- a/lib/form/checkbox.php +++ b/lib/form/checkbox.php @@ -60,5 +60,42 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{ $this->updateAttributes(array('id' => substr(md5(microtime() . $idx++), 0, 6))); } } // end func _generateId + /** + * Called by HTML_QuickForm whenever form event is made on this element + * + * @param string $event Name of event + * @param mixed $arg event arguments + * @param object $caller calling object + * @since 1.0 + * @access public + * @return void + */ + function onQuickFormEvent($event, $arg, &$caller) + { + //fixes bug in quickforms which lets previous set value override submitted value if checkbox is not checked + // and no value is submitted + switch ($event) { + case 'updateValue': + // constant values override both default and submitted ones + // default values are overriden by submitted + $value = $this->_findValue($caller->_constantValues); + if (null === $value) { + // if no boxes were checked, then there is no value in the array + // yet we don't want to display default value in this case + if ($caller->isSubmitted()) { + $value = $this->_findValue($caller->_submitValues); + } else { + + $value = $this->_findValue($caller->_defaultValues); + } + } + //fix here. setChecked should not be conditional + $this->setChecked($value); + break; + default: + parent::onQuickFormEvent($event, $arg, $caller); + } + return true; + } // end func onQuickFormEvent } ?> \ No newline at end of file diff --git a/lib/form/format.php b/lib/form/format.php index 3d12adbff7..6d8e315863 100644 --- a/lib/form/format.php +++ b/lib/form/format.php @@ -29,9 +29,16 @@ class MoodleQuickForm_format extends MoodleQuickForm_select{ */ function MoodleQuickForm_format($elementName=null, $elementLabel=null, $attributes=null, $useHtmlEditor=null) { + if ($elementName == null){ + $elementName = 'format'; + } + if ($elementLabel == null){ + $elementLabel = get_string('format'); + } HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'format'; + $this->_useHtmlEditor=$useHtmlEditor; if ($this->_useHtmlEditor==null){ $this->_useHtmlEditor=can_use_html_editor(); @@ -39,9 +46,6 @@ class MoodleQuickForm_format extends MoodleQuickForm_select{ if ($this->_useHtmlEditor){ $this->freeze(); } - - - } //end constructor /** diff --git a/lib/form/header.php b/lib/form/header.php new file mode 100644 index 0000000000..d7ef023bc6 --- /dev/null +++ b/lib/form/header.php @@ -0,0 +1,64 @@ +_text .= $this->getHelpButton(); + $renderer->renderHeader($this); + } // end func accept + + // }}} + /** + * set html for help button + * + * @access public + * @param array $help array of arguments to make a help button + * @param string $function function name to call to get html + */ + function setHelpButton($helpbuttonargs, $function='helpbutton'){ + if (!is_array($helpbuttonargs)){ + $helpbuttonargs=array($helpbuttonargs); + }else{ + $helpbuttonargs=$helpbuttonargs; + } + //we do this to to return html instead of printing it + //without having to specify it in every call to make a button. + $defaultargs=array('', '', 'moodle', true, false, '', true); + $helpbuttonargs=$helpbuttonargs + $defaultargs ; + $this->_helpbutton=call_user_func_array($function, $helpbuttonargs); + } + /** + * get html for help button + * + * @access public + * @return string html for help button + */ + function getHelpButton(){ + return $this->_helpbutton; + } +} //end class MoodleQuickForm_header +?> diff --git a/lib/form/select.php b/lib/form/select.php index 63df3f919b..245fa338a2 100644 --- a/lib/form/select.php +++ b/lib/form/select.php @@ -94,6 +94,18 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{ } } } // end func removeOption + /** + * Removes all OPTIONs from the SELECT + * + * @param string $value Value for the OPTION to remove + * @since 1.0 + * @access public + * @return void + */ + function removeOptions() + { + $this->_options = array(); + } // end func removeOption } ?> \ No newline at end of file diff --git a/lib/form/submit.php b/lib/form/submit.php new file mode 100644 index 0000000000..09a5bccac9 --- /dev/null +++ b/lib/form/submit.php @@ -0,0 +1,45 @@ + + * @author Bertrand Mansion + * @version 1.0 + * @since PHP4.04pl1 + * @access public + */ +class MoodleQuickForm_submit extends HTML_QuickForm_submit { + /** + * Called by HTML_QuickForm whenever form event is made on this element + * + * @param string $event Name of event + * @param mixed $arg event arguments + * @param object $caller calling object + * @since 1.0 + * @access public + * @return void + */ + function onQuickFormEvent($event, $arg, &$caller) + { + switch ($event) { + case 'createElement': + parent::onQuickFormEvent($event, $arg, $caller); + if ($caller->isNoSubmitButton($arg[0])){ + //need this to bypass client validation + //for buttons that submit but do not process the + //whole form. + $onClick = $this->getAttribute('onclick'); + $skip = 'skipClientValidation = true;'; + $onClick = ($onClick !== null)?$skip.' '.$onClick:$skip; + $this->updateAttributes(array('onclick'=>$onClick)); + } + return true; + break; + } + return parent::onQuickFormEvent($event, $arg, $caller); + + } // end func onQuickFormEvent +} +?> \ No newline at end of file diff --git a/lib/formslib.php b/lib/formslib.php index 354262dad9..f37f70ca6d 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -34,8 +34,19 @@ require_once $CFG->libdir.'/uploadlib.php'; define('FORM_ADVANCEDIMAGEURL', $CFG->wwwroot.'/lib/form/adv.gif'); define('FORM_REQIMAGEURL', $CFG->wwwroot.'/lib/form/req.gif'); +/** + * Callback called when PEAR throws an error + * + * @param PEAR_Error $error + */ +function pear_handle_error($error){ + echo ''.$error->GetMessage().' '.$error->getUserInfo(); + echo '
Backtrace :'; + print_object($error->backtrace); +} + if ($CFG->debug >= DEBUG_ALL){ - PEAR::setErrorHandling(PEAR_ERROR_PRINT); + PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pear_handle_error'); } /** @@ -79,7 +90,8 @@ class moodleform { * the name you gave the class extending moodleform. You should call your class something * like * - * @param string $action the action attribute for the form. + * @param string $action the action attribute for the form. If empty defaults to auto detect the + * current url. * @param array $customdata if your form defintion method needs access to data such as $course * $cm, etc. to construct the form definition then pass it in this array. You can * use globals for somethings. @@ -91,7 +103,10 @@ class moodleform { * @param mixed $attributes you can pass a string of html attributes here or an array. * @return moodleform */ - function moodleform($action, $customdata=null, $method='post', $target='', $attributes=null) { + function moodleform($action=null, $customdata=null, $method='post', $target='', $attributes=null) { + if (empty($action)){ + $action = strip_querystring(qualified_me()); + } //strip '_form' from the end of class name to make form 'id' attribute. $this->_formname = preg_replace('/_form$/', '', get_class($this), 1); $this->_customdata = $customdata; @@ -257,6 +272,23 @@ class moodleform { return $this->_form->isSubmitted(); } + function no_submit_button_pressed(){ + static $nosubmit = null; // one check is enough + if (!is_null($nosubmit)){ + return $nosubmit; + } + $mform =& $this->_form; + $nosubmit = false; + foreach ($mform->_noSubmitButtons as $nosubmitbutton){ + if (optional_param($nosubmitbutton, 0, PARAM_RAW)){ + $nosubmit = true; + break; + } + } + return $nosubmit; + } + + /** * Check that form data is valid. * @@ -265,21 +297,21 @@ class moodleform { function is_validated() { static $validated = null; // one validation is enough $mform =& $this->_form; - foreach ($mform->_noSubmitButtons as $nosubmitbutton){ - if (optional_param($nosubmitbutton, 0, PARAM_RAW)){ - return false; - } + if ($this->no_submit_button_pressed()){ + return false; } if ($validated === null) { $internal_val = $mform->validate(); $moodle_val = $this->validation($mform->exportValues(null, true)); if ($moodle_val !== true) { - if (!empty($moodle_val)) { + if ((is_array($moodle_val) && count($moodle_val)!==0)) { foreach ($moodle_val as $element=>$msg) { $mform->setElementError($element, $msg); } + $moodle_val = false; + } else { + $moodle_val = true; } - $moodle_val = false; } $file_val = $this->_validate_files(); if ($file_val !== true) { @@ -302,9 +334,11 @@ class moodleform { */ function is_cancelled(){ $mform =& $this->_form; - foreach ($mform->_cancelButtons as $cancelbutton){ - if (optional_param($cancelbutton, 0, PARAM_RAW)){ - return true; + if ($mform->isSubmitted()){ + foreach ($mform->_cancelButtons as $cancelbutton){ + if (optional_param($cancelbutton, 0, PARAM_RAW)){ + return true; + } } } return false; @@ -390,6 +424,7 @@ class moodleform { + /** * Method to add a repeating group of elements to a form. * @@ -408,6 +443,7 @@ class moodleform { * @param int $addfieldsno how many fields to add at a time * @param array $addstring array of params for get_string for name of button, $a is no of fields that * will be added. + * @return int no of repeats of element in this page */ function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $addfieldsname, $addfieldsno=5, $addstring=array('addfields', 'form')){ $repeats = optional_param($repeathiddenname, $repeats, PARAM_INT); @@ -416,7 +452,7 @@ class moodleform { $repeats += $addfieldsno; } $mform =& $this->_form; - $mform->_registerNoSubmitButton($addfieldsname); + $mform->registerNoSubmitButton($addfieldsname); $mform->addElement('hidden', $repeathiddenname, $repeats); //value not to be overridden by submitted value $mform->setConstants(array($repeathiddenname=>$repeats)); @@ -462,13 +498,45 @@ class moodleform { } } } - $mform->addElement('submit', $addfieldsname, get_string('addfields', 'form', $addfieldsno), - array('onclick'=>'skipClientValidation = true; return true;'));//need this to bypass client validation + $mform->addElement('submit', $addfieldsname, get_string('addfields', 'form', $addfieldsno)); + + $mform->closeHeaderBefore($addfieldsname); - $renderer =& $mform->defaultRenderer(); - $renderer->addStopFieldsetElements($addfieldsname); return $repeats; } + /** + * Use this method to add the standard buttons to the end of your form. Pass a param of false + * if you don't want a cancel button in your form. If you have a cancel button make sure you + * check for it being pressed using is_cancelled() and redirecting if it is true before trying to + * get data with data_submitted(). + * + * @param boolean $cancel whether to show cancel button, default true + * @param boolean $revert whether to show revert button, default true + * @param string $submitlabel label for submit button, defaults to get_string('savechanges') + */ + function add_action_buttons($cancel = true, $revert = true, $submitlabel=null){ + if (is_null($submitlabel)){ + $submitlabel = get_string('savechanges'); + } + $mform =& $this->_form; + if ($revert || $cancel){ + //when two or more elements we need a group + $buttonarray=array(); + $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); + if ($revert){ + $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); + } + if ($cancel){ + $buttonarray[] = &$mform->createElement('cancel'); + } + $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $mform->closeHeaderBefore('buttonar'); + } else { + //no group needed + $mform->addElement('submit', 'submitbutton', $submitlabel); + $mform->closeHeaderBefore('submitbutton'); + } + } } /** @@ -542,8 +610,62 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { FORM_REQIMAGEURL.'" />'))); } - function setShowAdvanced($showadvancedNow){ - $this->_showAdvanced=$showadvancedNow; + /** + * Use this method to indicate an element in a form is an advanced field. If items in a form + * are marked as advanced then 'Hide/Show Advanced' buttons will automatically be displayed in the + * form so the user can decide whether to display advanced form controls. + * + * If you set a header element to advanced then all elements it contains will also be set as advanced. + * + * @param string $elementName group or element name (not the element name of something inside a group). + * @param boolean $advanced default true sets the element to advanced. False removes advanced mark. + */ + function setAdvanced($elementName, $advanced=true){ + if ($advanced){ + $this->_advancedElements[$elementName]=''; + } elseif (isset($this->_advancedElements[$elementName])) { + unset($this->_advancedElements[$elementName]); + } + if ($advanced && $this->getElementType('mform_showadvanced_last')===false){ + $this->setShowAdvanced(); + $this->registerNoSubmitButton('mform_showadvanced'); + + $this->addElement('hidden', 'mform_showadvanced_last'); + } + } + /** + * Set whether to show advanced elements in the form on first displaying form. Default is not to + * display advanced elements in the form until 'Show Advanced' is pressed. + * + * You can get the last state of the form and possibly save it for this user by using + * value 'mform_showadvanced_last' in submitted data. + * + * @param boolean $showadvancedNow + */ + function setShowAdvanced($showadvancedNow = null){ + if ($showadvancedNow === null){ + if ($this->_showAdvanced !== null){ + return; + } else { //if setShowAdvanced is called without any preference + //make the default to not show advanced elements. + $showadvancedNow = 0; + } + + } + //value of hidden element + $hiddenLast = optional_param('mform_showadvanced_last', -1, PARAM_INT); + //value of button + $buttonPressed = optional_param('mform_showadvanced', 0, PARAM_RAW); + //toggle if button pressed or else stay the same + if ($hiddenLast == -1) { + $next = $showadvancedNow; + } elseif ($buttonPressed) { //toggle on button press + $next = !$hiddenLast; + } else { + $next = $hiddenLast; + } + $this->_showAdvanced = $next; + $this->setConstants(array('mform_showadvanced_last'=>$next)); } function getShowAdvanced(){ return $this->_showAdvanced; @@ -616,34 +738,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { parent::accept($renderer); } - function setAdvanced($elementName, $advanced=true){ - if ($advanced){ - $this->_advancedElements[$elementName]=''; - } elseif (isset($this->_advancedElements[$elementName])) { - unset($this->_advancedElements[$elementName]); - } - if ($advanced && $this->getShowAdvanced()===null){ - //hidden element - $showadvanced_last = optional_param('mform_showadvanced_last', 0, PARAM_INT); - //button - $showadvanced = optional_param('mform_showadvanced', 0, PARAM_RAW); - //toggle if button pressed or else stay the same - if ($showadvanced && $showadvanced_last){ - $showadvanced_now = 0; - } elseif ($showadvanced && !$showadvanced_last) { - $showadvanced_now = 1; - } else { - $showadvanced_now = $showadvanced_last; - } - - $this->setConstants(array('mform_showadvanced_last'=>$showadvanced_now)); - //below tells form whether to display elements or not - $this->setShowAdvanced($showadvanced_now); - $this->_registerNoSubmitButton('mform_showadvanced'); - $this->addElement('hidden', 'mform_showadvanced_last'); - } - } function closeHeaderBefore($elementName){ $renderer =& $this->defaultRenderer(); @@ -1040,8 +1135,11 @@ function validate_' . $this->_attributes['id'] . '(frm) { $this->_dependencies[$dependentOn][] = array('dependent'=>$elementName, 'condition'=>$condition, 'value'=>$value); } - function _registerNoSubmitButton($addfieldsname){ - $this->_noSubmitButtons[]=$addfieldsname; + function registerNoSubmitButton($buttonname){ + $this->_noSubmitButtons[]=$buttonname; + } + function isNoSubmitButton($buttonname){ + return (array_search($buttonname, $this->_noSubmitButtons)!==FALSE); } function _registerCancelButton($addfieldsname){ $this->_cancelButtons[]=$addfieldsname; @@ -1079,7 +1177,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ * @access private */ var $_headerTemplate = - "\n\t\t{header}{advancedimg}{button}\n\t\t"; + "\n\t\t{header}\n\t\t
{advancedimg}{button}
\n\t\t"; /** * Template used when closing a fieldset @@ -1311,6 +1409,7 @@ MoodleQuickForm::registerElementType('modgrade', "$CFG->libdir/form/modgrade.php MoodleQuickForm::registerElementType('cancel', "$CFG->libdir/form/cancel.php", 'MoodleQuickForm_cancel'); MoodleQuickForm::registerElementType('button', "$CFG->libdir/form/button.php", 'MoodleQuickForm_button'); MoodleQuickForm::registerElementType('choosecoursefile', "$CFG->libdir/form/choosecoursefile.php", 'MoodleQuickForm_choosecoursefile'); -//MoodleQuickForm::registerElementType('header', "$CFG->libdir/form/header.php", 'MoodleQuickForm_header'); // where is it? +MoodleQuickForm::registerElementType('header', "$CFG->libdir/form/header.php", 'MoodleQuickForm_header'); +MoodleQuickForm::registerElementType('submit', "$CFG->libdir/form/submit.php", 'MoodleQuickForm_submit'); ?> diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 2a26f354b2..eb0b8e8e8b 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -69,6 +69,8 @@ function lockoptionsall(formid) { thislock=!form.elements[master].checked; } else if (items[master].condition=='checked'){ thislock=form.elements[master].checked; + } else if (items[master].condition=='noitemselected'){ + thislock=(form.elements[master].selectedIndex==-1); } else if (items[master].condition=='eq'){ thislock=(form.elements[master].value==items[master].value); } else { @@ -200,21 +202,33 @@ function findParentNode(el, elName, elClass, elId) { Travels down the DOM hierarchy to find all child elements with the specified tag name, class, and id. All conditions must be met, but any can be ommitted. + Doesn't examine children of matches. */ function findChildNodes(start, tagName, elementClass, elementID, elementName) { var children = new Array(); for (var childIndex in start.childNodes) { + var classfound = false; var child = start.childNodes[childIndex]; - if( - (child.nodeType == 1) &&//element node type + if((child.nodeType == 1) &&//element node type + (elementClass && (typeof(child.className)=='string'))){ + var childClasses = child.className.split(/\s+/); + for (var childClassIndex in childClasses){ + if (childClasses[childClassIndex]==elementClass){ + classfound = true; + break; + } + } + } + if( (child.nodeType == 1) &&//element node type (!tagName || child.nodeName == tagName) && - (!elementClass || child.className.indexOf(elementClass) != -1) && + (!elementClass || classfound)&& (!elementID || child.id == elementID) && (!elementName || child.name == elementName)) { children = children.concat(child); + } else { + children = children.concat(findChildNodes(child, tagName, elementClass, elementID, elementName)); } - children = children.concat(findChildNodes(child, tagName, elementClass, elementID, elementName)); } return children; } diff --git a/login/change_password_form.php b/login/change_password_form.php index a6f9b94662..1a3438dda9 100644 --- a/login/change_password_form.php +++ b/login/change_password_form.php @@ -8,7 +8,6 @@ class change_password_form extends moodleform { global $USER; $mform =& $this->_form; - $renderer =& $mform->defaultRenderer(); $mform->addElement('header', '', get_string('changepassword'), ''); $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); @@ -47,14 +46,9 @@ class change_password_form extends moodleform { // buttons if (empty($USER->preference['auth_forcepasswordchange'])) { - $buttonarray = array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $renderer->addStopFieldsetElements('buttonar'); + $this->add_action_buttons(true, false); } else { - $mform->addElement('submit', 'submitbutton', get_string('savechanges')); - $renderer->addStopFieldsetElements('submitbutton'); + $this->add_action_buttons(false, false); } } diff --git a/login/forgot_password_form.php b/login/forgot_password_form.php index bc64b74d57..bf2b386e60 100644 --- a/login/forgot_password_form.php +++ b/login/forgot_password_form.php @@ -20,13 +20,7 @@ class forgot_password_form extends moodleform { $mform->addElement('hidden', 'action', 'find'); $mform->setType('action', PARAM_ALPHA); - // buttons - $buttonarray = array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('ok')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - - $renderer->addStopFieldsetElements('buttonar'); + $this->add_action_buttons(true, false, get_string('ok')); } } diff --git a/login/signup_form.php b/login/signup_form.php index d3979bbe36..1d559fffe4 100644 --- a/login/signup_form.php +++ b/login/signup_form.php @@ -7,7 +7,6 @@ class login_signup_form extends moodleform { global $USER, $CFG; $mform =& $this->_form; - $renderer =& $mform->defaultRenderer(); $mform->addElement('header', '', get_string('createuserandpass'), ''); @@ -50,12 +49,8 @@ class login_signup_form extends moodleform { $mform->setDefault('country', ''); // buttons - $buttonarray = array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('createaccount')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $this->add_action_buttons(true, false, get_string('createaccount')); - $renderer->addStopFieldsetElements('buttonar'); } function definition_after_data(){ diff --git a/mod/assignment/type/online/assignment.class.php b/mod/assignment/type/online/assignment.class.php index 95988a90f8..592cc73799 100644 --- a/mod/assignment/type/online/assignment.class.php +++ b/mod/assignment/type/online/assignment.class.php @@ -256,12 +256,7 @@ class assignment_online_edit_form extends moodleform { $mform->setType('id', PARAM_INT); // buttons - $buttonarray = array(); - $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] =& $mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] =& $mform->createElement('cancel'); - - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $this->add_action_buttons(); } } diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index 4e7814ecb8..274f2ce568 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -929,12 +929,7 @@ class assignment_upload_notes_form extends moodleform { $mform->setType('id', PARAM_ALPHA); // buttons - $buttonarray = array(); - $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] =& $mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] =& $mform->createElement('cancel'); - - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $this->add_action_buttons(); } } diff --git a/mod/chat/mod_form.php b/mod/chat/mod_form.php index a6916be04f..047913bf9b 100644 --- a/mod/chat/mod_form.php +++ b/mod/chat/mod_form.php @@ -48,12 +48,7 @@ class chat_mod_form extends moodleform_mod { $this->standard_coursemodule_elements(); - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); + $this->add_action_buttons(); } diff --git a/mod/choice/mod_form.php b/mod/choice/mod_form.php index 38256ee899..810adc912e 100644 --- a/mod/choice/mod_form.php +++ b/mod/choice/mod_form.php @@ -83,13 +83,7 @@ class choice_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- - - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); + $this->add_action_buttons(); } function defaults_preprocessing(&$default_values){ diff --git a/mod/data/comment_form.php b/mod/data/comment_form.php index b6a5754e43..dafebf00ce 100644 --- a/mod/data/comment_form.php +++ b/mod/data/comment_form.php @@ -27,13 +27,10 @@ class data_comment_form extends moodleform { $mform->addElement('hidden', 'commentid', 0); $mform->setType('commentid', PARAM_INT); +//------------------------------------------------------------------------------- // buttons - $buttonarray = array(); - $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] =& $mform->createElement('reset', 'reset', get_string('revert')); - $buttonarray[] =& $mform->createElement('cancel'); + $this->add_action_buttons(); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); } } ?> \ No newline at end of file diff --git a/mod/data/mod_form.php b/mod/data/mod_form.php index 358cdb1a94..695bc78321 100644 --- a/mod/data/mod_form.php +++ b/mod/data/mod_form.php @@ -57,12 +57,9 @@ class data_mod_form extends moodleform_mod { $this->standard_coursemodule_elements(); - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); +//------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(); } diff --git a/mod/exercise/mod_form.php b/mod/exercise/mod_form.php index 58121214a3..a8d0f736fa 100644 --- a/mod/exercise/mod_form.php +++ b/mod/exercise/mod_form.php @@ -100,13 +100,8 @@ class exercise_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- - - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); + // buttons + $this->add_action_buttons(); } diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index cc4fe0c1c6..58576ecc63 100644 --- a/mod/forum/mod_form.php +++ b/mod/forum/mod_form.php @@ -124,13 +124,10 @@ class forum_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); +//------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(); - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); } function definition_after_data(){ diff --git a/mod/forum/post_form.php b/mod/forum/post_form.php index 3a6ba948e4..a578aefa04 100644 --- a/mod/forum/post_form.php +++ b/mod/forum/post_form.php @@ -79,13 +79,14 @@ class forum_post_form extends moodleform { $mform->setType('timeend', PARAM_INT); $mform->setConstants(array('timestart'=> 0, 'timeend'=>0)); } +//------------------------------------------------------------------------------- + // buttons if (isset($post->edit)) { $submit_string = get_string('savechanges'); } else { $submit_string = get_string('posttoforum', 'forum'); } - $mform->addElement('submit', 'submitbutton', $submit_string); - $mform->closeHeaderBefore('submitbutton'); + $this->add_action_buttons(false, true, $submit_string); $mform->addElement('hidden', 'course'); $mform->setType('course', PARAM_INT); diff --git a/mod/glossary/comment_form.php b/mod/glossary/comment_form.php index dec379e3ef..b1667d6e24 100644 --- a/mod/glossary/comment_form.php +++ b/mod/glossary/comment_form.php @@ -24,13 +24,9 @@ class glossary_comment_form extends moodleform { $mform->addElement('hidden', 'action', ''); $mform->setType('action', PARAM_ACTION); +//------------------------------------------------------------------------------- // buttons - $buttonarray = array(); - $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] =& $mform->createElement('reset', 'reset', get_string('revert')); - $buttonarray[] =& $mform->createElement('cancel'); - - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $this->add_action_buttons(false); } } ?> \ No newline at end of file diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html deleted file mode 100644 index 921696296c..0000000000 --- a/mod/glossary/edit.html +++ /dev/null @@ -1,196 +0,0 @@ -format)) { - $newentry->format = $defaultformat; - } - - trusttext_prepare_edit($newentry->definition, $newentry->format, $usehtmleditor, $context); - -?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - - - - -
:" />
: - id,'name ASC'); - echo "\n"; - ?> -
- - - - - - - -
- '; - helpbutton("aliases2", strip_tags(get_string("aliases", "glossary")), "glossary"); - ?> - - -
-usedynalink ) { - echo ''; - echo ''; - echo ''; - } else { - echo ''; - - if (!empty($newentry->usedynalink)) { - $selected = "checked=\"checked\""; - } else { - $selected = ""; - } - echo ' '; - print_string("entryusedynalink","glossary"); - echo helpbutton("usedynalinkentry", strip_tags(get_string("usedynalink", "glossary")), "glossary"); - echo '
'; - - if (!empty($newentry->casesensitive)) { - $selected = "checked"; - } else { - $selected = ""; - } - echo ' '; - print_string("casesensitive","glossary"); - echo helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary"); - echo '
'; - - - if (!empty($newentry->fullmatch)) { - $selected = "checked"; - } else { - $selected = ""; - } - echo ' '; - print_string("fullmatch","glossary"); - echo helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary"); - echo '
'; - } -?> -
-
- : - - definition); ?> -
- - "; - if ($usehtmleditor) { - helpbutton("richtext", get_string("helprichtext"), "moodle", true, true); - } else { - emoticonhelpbutton("form", "text"); - } - echo "
"; - ?> - -
: - '; - } else { - choose_from_menu(format_text_menu(), "format", $newentry->format, ""); - } - helpbutton("textformat", get_string("helpformatting")); - ?> -
:
- maxbytes, $course->maxbytes))); - echo ')
'; - print_string("optional"); - echo ' '; - helpbutton("attachment", get_string("attachment", "glossary"), "glossary"); - ?>
-
- dirroot.'/lib/uploadlib.php'); - upload_print_form_fragment(1,array('attachment'),null,false,null,$course->maxbytes,0,false); - ?> -
-

- id)) { - echo "id\" />"; - } - ?> - - - - - - - - - - - " /> - " /> -

-
-
diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 45e84a91e2..05b7c05653 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -2,6 +2,7 @@ require_once('../../config.php'); require_once('lib.php'); +require_once('edit_form.php'); global $CFG, $USER; @@ -32,322 +33,196 @@ if (! $glossary = get_record("glossary", "id", $cm->instance)) { error("Course module is incorrect"); } -if ($e) { // if entry is sepcified +if ($e) { // if entry is specified require_capability('mod/glossary:manageentries', $context); } else { // new entry require_capability('mod/glossary:write', $context); } -if ( $confirm ) { - $form = data_submitted(); - trusttext_after_edit($form->text, $context); +$mform =& new glossary_entry_form(null, compact('cm', 'glossary', 'hook', 'mode', 'e', 'context')); +if ($mform->is_cancelled()){ + if ($e){ + redirect("view.php?id=$cm->id&mode=entry&hook=$e"); + } else { + redirect("view.php?id=$cm->id"); + } + +} elseif ($fromform = $mform->data_submitted()) { + trusttext_after_edit($fromform->definition, $context); - if ( !isset($form->usedynalink) ) { - $form->usedynalink = 0; + if ( !isset($fromform->usedynalink) ) { + $fromform->usedynalink = 0; } - if ( !isset($form->casesensitive) ) { - $form->casesensitive = 0; + if ( !isset($fromform->casesensitive) ) { + $fromform->casesensitive = 0; } - if ( !isset($form->fullmatch) ) { - $form->fullmatch = 0; + if ( !isset($fromform->fullmatch) ) { + $fromform->fullmatch = 0; } $timenow = time(); - //$form->text = clean_text($form->text, $form->format); - - $newentry->course = $glossary->course; - $newentry->glossaryid = $glossary->id; - - $newentry->concept = clean_text(trim($form->concept)); - $newentry->definition = $form->text; - $newentry->format = $form->format; - $newentry->usedynalink = $form->usedynalink; - $newentry->casesensitive = $form->casesensitive; - $newentry->fullmatch = $form->fullmatch; - $newentry->timemodified = $timenow; - $newentry->approved = 0; - $newentry->aliases = ""; - if ( $glossary->defaultapproval or has_capability('mod/glossary:approve', $context) ) { - $newentry->approved = 1; - } - - $strglossary = get_string("modulename", "glossary"); - $strglossaries = get_string("modulenameplural", "glossary"); - $stredit = get_string("edit"); - - if ($form->concept == '' or trim($form->text) == '' ) { - $errors = get_string('fillfields','glossary'); - if ($usehtmleditor = can_use_richtext_editor()) { - $defaultformat = FORMAT_HTML; - } else { - $defaultformat = FORMAT_MOODLE; - } - - print_header_simple(format_string($glossary->name), "", - "id\">$strglossaries -> - id\">".format_string($glossary->name,true)." -> $stredit", "form.text", - "", true, "", navmenu($course, $cm)); - - print_heading(format_string($glossary->name)); - - /// Info box - if ( $glossary->intro ) { - print_simple_box(format_text($glossary->intro), 'center', '70%', '', 5, 'generalbox', 'intro'); - } - echo '
'; - $tab = GLOSSARY_ADDENTRY_VIEW; - include("tabs.html"); - - include("edit.html"); - - echo ''; - - glossary_print_tabbed_table_end(); - - // Lets give IE more time to load the whole page - // before trying to load the editor. - if ($usehtmleditor) { - use_html_editor("text"); - } - - print_footer($course); - die; + $todb = new object(); + $todb->course = $glossary->course; + $todb->glossaryid = $glossary->id; + + $todb->concept = trim($fromform->concept); + $todb->definition = $fromform->definition; + $todb->format = $fromform->format; + $todb->usedynalink = $fromform->usedynalink; + $todb->casesensitive = $fromform->casesensitive; + $todb->fullmatch = $fromform->fullmatch; + $todb->timemodified = $timenow; + $todb->approved = 0; + $todb->aliases = ""; + if ( $glossary->defaultapproval or has_capability('mod/glossary:approve', $context) ) { + $todb->approved = 1; } if ($e) { - //We are updating an entry, so we compare current session user with - //existing entry user to avoid some potential problems if secureforms=off - //Perhaps too much security? Anyway thanks to skodak (Bug 1823) - $old = get_record('glossary_entries', 'id', $e); - $ineditperiod = ((time() - $old->timecreated < $CFG->maxeditingtime) || $glossary->editalways); - if ( (!$ineditperiod || $USER->id != $old->userid) and !has_capability('mod/glossary:manageentries', $context) and $e) { - if ( $USER->id != $old->userid ) { - error("You can't edit other people's entries!"); - } elseif (!$ineditperiod) { - error("You can't edit this. Time expired!"); - } - die; + /* TODO process file uploads + $todb->attachment = $_FILES["attachment"]; + if ($newfilename = glossary_add_attachment($todb, 'attachment')) { + $todb->attachment = $newfilename; + } else { + unset($todb->attachment); + }*/ + $todb->id = $e; + print_object($todb); + if (update_record('glossary_entries', $todb)) { + add_to_log($course->id, "glossary", "update entry", + "view.php?id=$cm->id&mode=entry&hook=$todb->id", + $todb->id, $cm->id); + } else { + error("Could not update your glossary"); } + } else { - $newentry->id = $e; - - $permissiongranted = 1; - if ( !$glossary->allowduplicatedentries ) { - if ($dupentries = get_records("glossary_entries","lower(concept)", moodle_strtolower($newentry->concept))) { - foreach ($dupentries as $curentry) { - if ( $glossary->id == $curentry->glossaryid ) { - if ( $curentry->id != $e ) { - $permissiongranted = 0; - break; - } - } - } - } - } + $todb->userid = $USER->id; + $todb->timecreated = $timenow; + $todb->sourceglossaryid = 0; + $todb->teacherentry = has_capability('mod/glossary:manageentries', $context); - if ( $permissiongranted ) { - $newentry->attachment = $_FILES["attachment"]; - if ($newfilename = glossary_add_attachment($newentry, 'attachment')) { - $newentry->attachment = $newfilename; - } else { - unset($newentry->attachment); - } - if (update_record("glossary_entries", $newentry)) { - add_to_log($course->id, "glossary", "update entry", - "view.php?id=$cm->id&mode=entry&hook=$newentry->id", - $newentry->id, $cm->id); - $redirectmessage = get_string('entryupdated','glossary'); + if ($todb->id = insert_record("glossary_entries", $todb)) { + $e = $todb->id; + /* TODO process file uploads + $todb->attachment = $_FILES["attachment"]; + if ($newfilename = glossary_add_attachment($todb, 'attachment')) { + $todb->attachment = $newfilename; } else { - error("Could not update your glossary"); + unset($todb->attachment); } + set_field("glossary_entries", "attachment", $newfilename, "id", $todb->id);*/ + add_to_log($course->id, "glossary", "add entry", + "view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id,$cm->id); } else { - error("Could not update this glossary entry because this concept already exist."); - } - } else { - - $newentry->userid = $USER->id; - $newentry->timecreated = $timenow; - $newentry->sourceglossaryid = 0; - $newentry->teacherentry = has_capability('mod/glossary:manageentries', $context); - - $permissiongranted = 1; - if ( !$glossary->allowduplicatedentries ) { - if ($dupentries = get_record("glossary_entries","lower(concept)", moodle_strtolower($newentry->concept), "glossaryid", $glossary->id)) { - $permissiongranted = 0; - } - } - if ( $permissiongranted ) { - if ($newentry->id = insert_record("glossary_entries", $newentry)) { - $e = $newentry->id; - $newentry->attachment = $_FILES["attachment"]; - if ($newfilename = glossary_add_attachment($newentry, 'attachment')) { - $newentry->attachment = $newfilename; - } else { - unset($newentry->attachment); - } - set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id); - add_to_log($course->id, "glossary", "add entry", - "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id,$cm->id); - $redirectmessage = get_string('entrysaved','glossary'); - } else { - error("Could not insert this new entry"); - } - } else { - error("Could not insert this glossary entry because this concept already exist."); + error("Could not insert this new entry"); } + } - delete_records("glossary_entries_categories","entryid",$e); - delete_records("glossary_alias","entryid",$e); + delete_records("glossary_entries_categories", "entryid", $e); + delete_records("glossary_alias", "entryid", $e); - if ( isset($form->categories) ) { + if (empty($fromform->notcategorised) && isset($fromform->categories)) { $newcategory->entryid = $e; - foreach ($form->categories as $category) { + foreach ($fromform->categories as $category) { if ( $category > 0 ) { $newcategory->categoryid = $category; - insert_record("glossary_entries_categories",$newcategory, false); + insert_record("glossary_entries_categories", $newcategory, false); } else { break; } } } - if ( isset($form->aliases) ) { - if ( $aliases = explode("\n",clean_text($form->aliases)) ) { + if ( isset($fromform->aliases) ) { + if ( $aliases = explode("\n", $fromform->aliases) ) { foreach ($aliases as $alias) { $alias = trim($alias); if ($alias) { unset($newalias); $newalias->entryid = $e; $newalias->alias = $alias; - insert_record("glossary_alias",$newalias, false); + insert_record("glossary_alias", $newalias, false); } } } } - redirect("view.php?id=$cm->id&mode=entry&hook=$newentry->id", $redirectmessage); + redirect("view.php?id=$cm->id&mode=entry&hook=$todb->id"); } else { if ($e) { - $form = get_record("glossary_entries", "id", $e); - - $newentry->id = $form->id; - $newentry->concept = $form->concept; - $newentry->definition = $form->definition; - $newentry->format = $form->format; - $newentry->timemodified = time(); - $newentry->approved = $glossary->defaultapproval or has_capability('mod/glossary:approve', $context); - $newentry->usedynalink = $form->usedynalink; - $newentry->casesensitive = $form->casesensitive; - $newentry->fullmatch = $form->fullmatch; - $newentry->aliases = ""; - $newentry->userid = $form->userid; - $newentry->timecreated = $form->timecreated; - - - if ( $aliases = get_records("glossary_alias","entryid",$e) ) { - foreach ($aliases as $alias) { - $newentry->aliases .= $alias->alias . "\n"; + $fromdb = get_record("glossary_entries", "id", $e); + + $toform = new object(); + + if ($categoriesarr = get_records_menu("glossary_entries_categories", "entryid", $e, '', 'id, categoryid')){ + $toform->categories = array_values($categoriesarr); + } else { + $toform->categories = array(0); + } + $toform->concept = $fromdb->concept; + $toform->definition = $fromdb->definition; + $toform->format = $fromdb->format; + trusttext_prepare_edit($toform->definition, $toform->format, can_use_html_editor(), $context); + $toform->approved = $glossary->defaultapproval or has_capability('mod/glossary:approve', $context); + $toform->usedynalink = $fromdb->usedynalink; + $toform->casesensitive = $fromdb->casesensitive; + $toform->fullmatch = $fromdb->fullmatch; + $toform->aliases = ''; + $ineditperiod = ((time() - $fromdb->timecreated < $CFG->maxeditingtime) || $glossary->editalways); + if ((!$ineditperiod || $USER->id != $fromdb->userid) and !has_capability('mod/glossary:manageentries', $context)) { + if ( $USER->id != $fromdb->userid ) { + error(get_string('errcannoteditothers', 'glossary')); + } elseif (!$ineditperiod) { + error(get_string('erredittimeexpired', 'glossary')); } + die; } - } -} - -//Fill and print the form. -//We check every field has a default values here!! -if (!isset($newentry->concept)) { - $newentry->concept = ""; -} -if (!isset($newentry->aliases)) { - $newentry->aliases = ""; -} -if (!isset($newentry->usedynalink)) { - if (isset($CFG->glossary_linkentries)) { - $newentry->usedynalink = $CFG->glossary_linkentries; - } else { - $newentry->usedynalink = 0; - } -} -if (!isset($newentry->casesensitive)) { - if (isset($CFG->glossary_casesensitive)) { - $newentry->casesensitive = $CFG->glossary_casesensitive; - } else { - $newentry->casesensitive = 0; - } -} -if (!isset($newentry->fullmatch)) { - if (isset($CFG->glossary_fullmatch)) { - $newentry->fullmatch = $CFG->glossary_fullmatch; - } else { - $newentry->fullmatch = 0; + if ( $aliases = get_records_menu("glossary_alias", "entryid", $e, '', 'id, alias') ) { + $toform->aliases = implode("\n", $aliases) . "\n"; + } + $mform->set_defaults($toform); } } -if (!isset($newentry->definition)) { - $newentry->definition = ""; -} -if (!isset($newentry->timecreated)) { - $newentry->timecreated = 0; -} -if (!isset($newentry->userid)) { - $newentry->userid = $USER->id; -} + $strglossary = get_string("modulename", "glossary"); $strglossaries = get_string("modulenameplural", "glossary"); $stredit = get_string("edit"); -if ($usehtmleditor = can_use_richtext_editor()) { - $defaultformat = FORMAT_HTML; -} else { - $defaultformat = FORMAT_MOODLE; -} print_header_simple(format_string($glossary->name), "", "id\">$strglossaries -> id\">".format_string($glossary->name,true)." -> $stredit", "", "", true, "", navmenu($course, $cm)); -$ineditperiod = ((time() - $newentry->timecreated < $CFG->maxeditingtime) || $glossary->editalways); -if ( (!$ineditperiod || $USER->id != $newentry->userid) and !has_capability('mod/glossary:manageentries', $context) and $e) { - if ( $USER->id != $newentry->userid ) { - error("You can't edit other people's entries!"); - } elseif (!$ineditperiod) { - error("You can't edit this. Time expired!"); - } - die; -} - print_heading(format_string($glossary->name)); + +print_heading(format_string($glossary->name)); /// Info box - if ( $glossary->intro ) { - print_simple_box(format_text($glossary->intro), 'center', '70%', '', 5, 'generalbox', 'intro'); - } +if ( $glossary->intro ) { + print_simple_box(format_text($glossary->intro), 'center', '70%', '', 5, 'generalbox', 'intro'); +} - echo '
'; +echo '
'; /// Tabbed browsing sections $tab = GLOSSARY_ADDENTRY_VIEW; include("tabs.html"); if (!$e) { - require_capability('mod/glossary:write', $context); + require_capability('mod/glossary:write', $context); } -include("edit.html"); - -echo ''; +$mform->display(); +echo ''; //TODO remove center tag from here and tabs.html glossary_print_tabbed_table_end(); - // Lets give IE more time to load the whole page - // before trying to load the editor. - if ($usehtmleditor) { - use_html_editor("text"); - } - print_footer($course); -?> +?> \ No newline at end of file diff --git a/mod/glossary/edit_form.php b/mod/glossary/edit_form.php new file mode 100644 index 0000000000..d803c3d485 --- /dev/null +++ b/mod/glossary/edit_form.php @@ -0,0 +1,141 @@ +dirroot.'/lib/formslib.php'); + +class glossary_entry_form extends moodleform { + + function definition() { + + global $CFG, $COURSE; + $mform =& $this->_form; + + $glossary =& $this->_customdata['glossary']; + $mode =& $this->_customdata['mode']; + $cm =& $this->_customdata['cm']; + $hook =& $this->_customdata['hook']; + $e =& $this->_customdata['e']; + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'general', get_string('general', 'form')); + + $mform->addElement('text', 'concept', get_string('concept', 'glossary')); + $mform->setType('concept', PARAM_TEXT); + $mform->addRule('concept', null, 'required', null, 'client'); + + $mform->addElement('htmleditor', 'definition', get_string('definition', 'glossary'), array('rows'=>20)); + $mform->setType('definition', PARAM_RAW); + $mform->addRule('definition', null, 'required', null, 'client'); + + $mform->addElement('format'); + + $categories = array(); + if ($categories = get_records_menu('glossary_categories', 'glossaryid', $glossary->id, 'name ASC', 'id, name')){ + $categories = array(0 => get_string('notcategorised', 'glossary')) + $categories; + } else { + $categories = array(0 => get_string('notcategorised', 'glossary')); + } + + $categoriesEl = $mform->addElement('select', 'categories', get_string('categories', 'glossary'), $categories); + $categoriesEl->setMultiple(true); + $categoriesEl->setSize(5); + + $mform->addElement('textarea', 'aliases', get_string('aliases', 'glossary'), 'rows="2" cols="40"'); + $mform->setType('aliases', PARAM_TEXT); + $mform->setHelpButton('aliases', array('aliases2', strip_tags(get_string('aliases', 'glossary')), 'glossary')); + + $this->set_max_file_size(); + $this->_upload_manager = new upload_manager('attachment', true, false, $COURSE, false, 0, true, true); + $mform->addElement('file', 'attachment', get_string('attachment', 'forum')); + $mform->setHelpButton('attachment', array('attachment', get_string('attachment', 'glossary'), 'glossary')); + + if (isset($CFG->glossary_linkentries)) { + $usedynalink = $CFG->glossary_linkentries; + } else { + $usedynalink = 0; + } + if (isset($CFG->glossary_casesensitive)) { + $casesensitive = $CFG->glossary_casesensitive; + } else { + $casesensitive = 0; + } + if (isset($CFG->glossary_fullmatch)) { + $fullmatch = $CFG->glossary_fullmatch; + } else { + $fullmatch = 0; + } + if ( !$glossary->usedynalink ) { + $mform->addElement('hidden', 'usedynalink', $usedynalink); + $mform->addElement('hidden', 'casesensitive', $casesensitive); + $mform->addElement('hidden', 'fullmatch', $fullmatch); + } else { +//------------------------------------------------------------------------------- + $mform->addElement('header', 'linkinghdr', get_string('linking', 'glossary')); + + $mform->addElement('checkbox', 'usedynalink', get_string('entryusedynalink', 'glossary')); + $mform->setHelpButton('usedynalink', array('usedynalinkentry', strip_tags(get_string('usedynalink', 'glossary')), 'glossary')); + $mform->setDefault('usedynalink', $usedynalink); + + $mform->addElement('checkbox', 'casesensitive', get_string('casesensitive', 'glossary')); + $mform->setHelpButton('casesensitive', array('casesensitive', strip_tags(get_string('casesensitive', 'glossary')), 'glossary')); + $mform->disabledIf('casesensitive', 'usedynalink'); + $mform->setDefault('casesensitive', $casesensitive); + + $mform->addElement('checkbox', 'fullmatch', get_string('fullmatch', 'glossary')); + $mform->setHelpButton('fullmatch', array('fullmatch', strip_tags(get_string('fullmatch', 'glossary')), 'glossary')); + $mform->disabledIf('fullmatch', 'usedynalink'); + $mform->setDefault('fullmatch', $fullmatch); + } + + $mform->addElement('hidden', 'e', $e); + $mform->addElement('hidden', 'id', $cm->id); + $mform->addElement('hidden', 'mode', $mode); + $mform->addElement('hidden', 'hook', $hook); + +//------------------------------------------------------------------------------- + $this->add_action_buttons(); + } + + function validation($data){ + global $CFG, $USER; + $errors = array(); + $e = $this->_customdata['e']; + $glossary = $this->_customdata['glossary']; + $context = $this->_customdata['context']; + $data['concept'] = trim($data['concept']); + if ($e) { + //We are updating an entry, so we compare current session user with + //existing entry user to avoid some potential problems if secureforms=off + //Perhaps too much security? Anyway thanks to skodak (Bug 1823) + $old = get_record('glossary_entries', 'id', $e); + $ineditperiod = ((time() - $old->timecreated < $CFG->maxeditingtime) || $glossary->editalways); + if ( (!$ineditperiod || $USER->id != $old->userid) and !has_capability('mod/glossary:manageentries', $context)) { + if ( $USER->id != $old->userid ) { + $errors['concept'] = get_string('errcannoteditothers', 'glossary'); + } elseif (!$ineditperiod) { + $errors['concept'] = get_string('erredittimeexpired', 'glossary'); + } + } + if ( !$glossary->allowduplicatedentries ) { + if ($dupentries = get_records('glossary_entries', 'lower(concept)', moodle_strtolower($data['concept']))) { + foreach ($dupentries as $curentry) { + if ( $glossary->id == $curentry->glossaryid ) { + if ( $curentry->id != $e ) { + $errors['concept'] = get_string('errconceptalreadyexists', 'glossary'); + break; + } + } + } + } + } + + } else { + if ( !$glossary->allowduplicatedentries ) { + if ($dupentries = get_record('glossary_entries', 'lower(concept)', moodle_strtolower($data['concept']), 'glossaryid', $glossary->id)) { + $errors['concept'] = get_string('errconceptalreadyexists', 'glossary'); + } + } + } + return $errors; + } + +} +?> \ No newline at end of file diff --git a/mod/glossary/mod_form.php b/mod/glossary/mod_form.php index ccd523f996..ce99e581ce 100644 --- a/mod/glossary/mod_form.php +++ b/mod/glossary/mod_form.php @@ -34,7 +34,7 @@ class glossary_mod_form extends moodleform_mod { $options = array(1=>get_string('mainglossary', 'glossary'), 0=>get_string('secondaryglossary', 'glossary')); $mform->addElement('select', 'mainglossary', get_string('glossarytype', 'glossary'), $options); - $mform->setHelpButton('mainglossary', array('mainglossary', get_string('mainglossary', 'glossary'), 'glossary'));$mform->setDefault('allowduplicatedentries', $CFG->glossary_dupentries); + $mform->setHelpButton('mainglossary', array('mainglossary', get_string('mainglossary', 'glossary'), 'glossary')); $mform->setDefault('mainglossary', 0); $mform->addElement('selectyesno', 'allowduplicatedentries', get_string('allowduplicatedentries', 'glossary'), $options); @@ -145,12 +145,8 @@ class glossary_mod_form extends moodleform_mod { $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); + // buttons + $this->add_action_buttons(); } function definition_after_data(){ diff --git a/mod/journal/mod_form.php b/mod/journal/mod_form.php index 137f2d1208..d8ab781c36 100644 --- a/mod/journal/mod_form.php +++ b/mod/journal/mod_form.php @@ -44,13 +44,9 @@ class journal_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(); - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); } diff --git a/mod/label/mod_form.php b/mod/label/mod_form.php index 48069acd81..350d180114 100644 --- a/mod/label/mod_form.php +++ b/mod/label/mod_form.php @@ -15,12 +15,10 @@ class label_mod_form extends moodleform_mod { $mform->addElement('modvisible', 'visible', get_string('visible')); - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); +//------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(); + } } diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index 3f340e159b..f2c9807072 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -273,13 +273,8 @@ class lesson_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(false); //------------------------------------------------------------------------------- - - $buttonarray=array(); - $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges')); - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); - $mform->closeHeaderBefore('buttonar'); + // buttons + $this->add_action_buttons(); } diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 9a4366288b..f5f3c27da8 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -56,7 +56,7 @@ define("QUIZ_MAX_EVENT_LENGTH", "432000"); // 5 days maximum * (defined by the form in mod.html) this function * will create a new instance and return the id number * of the new instance. - * + * * @param object $quiz the data that came from the form. * @return mixed the id of the new instance on success, * false or a string error message on failure. @@ -78,7 +78,7 @@ function quiz_add_instance($quiz) { // Do the processing required after an add or an update. quiz_after_add_or_update($quiz); - + return $quiz->id; } @@ -86,7 +86,7 @@ function quiz_add_instance($quiz) { * Given an object containing all the necessary data, * (defined by the form in mod.html) this function * will update an existing instance with new data. - * + * * @param object $quiz the data that came from the form. * @return mixed true on success, false or a string error message on failure. */ @@ -175,7 +175,7 @@ function quiz_user_outline($course, $user, $mod, $quiz) { /// $return->time = the time they did it /// $return->info = a short text description if ($grade = get_record('quiz_grades', 'userid', $user->id, 'quiz', $quiz->id)) { - + $result = new stdClass; if ((float)$grade->grade) { $result->info = get_string('grade').': '.round($grade->grade, $quiz->decimalpoints); @@ -464,25 +464,8 @@ function quiz_process_options(&$quiz) { $quiz->timemodified = time(); // Quiz open time. - if (empty($quiz->availableenable)) { - $quiz->timeopen = 0; + if (empty($quiz->timeopen)) { $quiz->preventlate = 0; - } else { - $quiz->timeopen = make_timestamp($quiz->availableyear, $quiz->availablemonth, - $quiz->availableday, $quiz->availablehour, $quiz->availableminute); - } - - // Quiz close time. - if (empty($quiz->dueenable)) { - $quiz->timeclose = 0; - } else { - $quiz->timeclose = make_timestamp($quiz->dueyear, $quiz->duemonth, - $quiz->dueday, $quiz->duehour, $quiz->dueminute); - } - - // Check open and close times are consistent. - if ($quiz->timeopen != 0 && $quiz->timeclose != 0 && $quiz->timeclose < $quiz->timeopen) { - return get_string('closebeforeopen', 'quiz'); } // Quiz name. (Make up a default if one was not given.) @@ -494,15 +477,15 @@ function quiz_process_options(&$quiz) { } } $quiz->name = trim($quiz->name); - + // Time limit. (Get rid of it if the checkbox was not ticked.) - if (empty($quiz->timelimitenable) or empty($quiz->timelimit) or $quiz->timelimit < 0) { + if (empty($quiz->timelimitenable)) { $quiz->timelimit = 0; } $quiz->timelimit = round($quiz->timelimit); - + // Quiz feedback - + // Clean up the boundary text. for ($i = 0; $i < count($quiz->feedbacktext); $i += 1) { if (empty($quiz->feedbacktext[$i])) { @@ -511,7 +494,7 @@ function quiz_process_options(&$quiz) { $quiz->feedbacktext[$i] = trim($quiz->feedbacktext[$i]); } } - + // Check the boundary value is a number or a percentage, and in range. $i = 0; while (!empty($quiz->feedbackboundaries[$i])) { @@ -536,7 +519,7 @@ function quiz_process_options(&$quiz) { $i += 1; } $numboundaries = $i; - + // Check there is nothing in the remaining unused fields. for ($i = $numboundaries; $i < count($quiz->feedbackboundaries); $i += 1) { if (!empty($quiz->feedbackboundaries[$i]) && trim($quiz->feedbackboundaries[$i]) != '') { @@ -551,7 +534,7 @@ function quiz_process_options(&$quiz) { $quiz->feedbackboundaries[-1] = $quiz->grade + 1; // Needs to be bigger than $quiz->grade because of '<' test in quiz_feedback_for_grade(). $quiz->feedbackboundaries[$numboundaries] = 0; $quiz->feedbackboundarycount = $numboundaries; - + // Settings that get combined to go into the optionflags column. $quiz->optionflags = 0; if (!empty($quiz->adaptive)) { @@ -644,14 +627,14 @@ function quiz_process_options(&$quiz) { /** * This function is called at the end of quiz_add_instance * and quiz_update_instance, to do the common processing. - * + * * @param object $quiz the quiz object. */ function quiz_after_add_or_update($quiz) { // Save the feedback delete_records('quiz_feedback', 'quizid', $quiz->id); - + for ($i = 0; $i <= $quiz->feedbackboundarycount; $i += 1) { $feedback = new stdClass; $feedback->quizid = $quiz->id; @@ -664,9 +647,7 @@ function quiz_after_add_or_update($quiz) { } // Remember whether this user likes the advanced settings visible or hidden. - if (isset($quiz->optionsettingspref)) { - set_user_preference('quiz_optionsettingspref', $quiz->optionsettingspref); - } + set_user_preference('quiz_optionsettingspref', $quiz->mform_showadvanced_last); // Update the events relating to this quiz. // This is slightly inefficient, deleting the old events and creating new ones. However, diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html deleted file mode 100644 index eceb7f6f4f..0000000000 --- a/mod/quiz/mod.html +++ /dev/null @@ -1,570 +0,0 @@ - -// It is used from /course/mod.php. The whole instance is available as $form. --> - - require_once("$CFG->dirroot/mod/quiz/locallib.php"); - - // Set any form variables that have not been initialized to their default value. - if (!isset($form->name)) { - $form->name = ""; - } - if (!isset($form->intro)) { - $form->intro = ""; - } - if (!isset($form->timeopen)) { - $form->timeopen = ""; - } - if (!isset($form->timeclose)) { - $form->timeclose = ""; - } - if (!isset($form->attempts)) { - $form->attempts = $CFG->quiz_attempts; - } - if (!isset($form->attemptonlast)) { - $form->attemptonlast = $CFG->quiz_attemptonlast; - } - if (!isset($form->grademethod)) { - $form->grademethod = $CFG->quiz_grademethod; - } - if (!isset($form->decimalpoints)) { - $form->decimalpoints = $CFG->quiz_decimalpoints; - } - if (!isset($form->review)) { - $form->review = $CFG->quiz_review; - } - if (!isset($form->questionsperpage)) { - $form->questionsperpage = $CFG->quiz_questionsperpage; - } - if (!isset($form->shufflequestions)) { - $form->shufflequestions = $CFG->quiz_shufflequestions; - } - if (!isset($form->shuffleanswers)) { - $form->shuffleanswers = $CFG->quiz_shuffleanswers; - } - if (!isset($form->grade)) { - $form->grade = $CFG->quiz_maximumgrade; - } - if (!isset($form->questions)) { - $form->questions = ""; - } - if (!isset($form->password)) { - $form->password = $CFG->quiz_password; - } - if (!isset($form->subnet)) { - $form->subnet = $CFG->quiz_subnet; - } - if (!isset($form->timelimit)) { - $form->timelimit = $CFG->quiz_timelimit; - } - if (!isset($form->popup)) { - $form->popup = $CFG->quiz_popup; - } - if (!isset($form->optionflags)) { - $form->optionflags = $CFG->quiz_optionflags; - } - if (!isset($form->penaltyscheme)) { - $form->penaltyscheme = $CFG->quiz_penaltyscheme; - } - if (empty($form->timedue)) { - $form->timedue = ""; - } - //enforced time delay between quiz attempts - //delay1: time delay between first and second attempt - //delay2: time delay between second and additional quiz attempt - if (!isset($form->delay1)) { - $form->delay1 = $CFG->quiz_delay1; - } - if (!isset($form->delay2)) { - $form->delay2 = $CFG->quiz_delay2; - } - - // Get any existing feedback text out of the database. - if (!empty($form->id)) { - $feedbacks = get_records('quiz_feedback', 'quizid', $form->id, 'mingrade DESC'); - } else { - $feedbacks = array(); - } - $form->feedbacktext = array(); - $form->feedbackboundaries = array(); - foreach ($feedbacks as $feedback) { - $form->feedbacktext[] = $feedback->feedbacktext; - if ($feedback->mingrade > 0) { - $form->feedbackboundaries[] = (100.0 * $feedback->mingrade / $form->grade) . '%'; - } - } - - // Make sure there are at least 5 feedbacktexts, or a bit more than the current nubmer. - $numfeedbacks = max( - count($form->feedbacktext) * 1.5, - count($form->feedbackboundaries) * 1.5, - 5 - ); - - for ($i = 0; $i < $numfeedbacks; $i += 1) { - if (!array_key_exists($i, $form->feedbacktext)) { - $form->feedbacktext[$i] = ''; - } - if (!array_key_exists($i, $form->feedbackboundaries)) { - $form->feedbackboundaries[$i] = ''; - } - } - - // The following are used for drop-down menus - $yesnooptions = array(get_string("no"), get_string("yes")); - - $attemptoptions = array(); - $attemptoptions[0] = get_string("attemptsunlimited", "quiz"); - $attemptoptions[1] = "1 ".moodle_strtolower(get_string("attempt", "quiz")); - for ($i=2;$i<=6;$i++) { - $attemptoptions[$i] = "$i ".moodle_strtolower(get_string("attempts", "quiz")); - } - - //enforced time delay between quiz attempts add-on - $timedelayoptions = array(); - $timedelayoptions[0] = get_string('none'); - $timedelayoptions[1800] = get_string('numminutes', '', 30); - $timedelayoptions[3600] = get_string('numminutes', '', 60); - for($i=2; $i<=23; $i++) { - $seconds = $i*3600; - $timedelayoptions[$seconds] = get_string('numhours', '', $i); - } - $timedelayoptions[86400] = get_string('numhours', '', 24); - for($i=2; $i<=7; $i++) { - $seconds = $i*86400; - $timedelayoptions[$seconds] = get_string('numdays', '', $i); - } - -?> - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -feedbacktext); $i = $i + 1) { ?> - - - - - - -feedbacktext) - 1) { ?> - - - - - - - - - - - - - - - - - - - - - - -
: - -
:

- '; - emoticonhelpbutton("form", "description"); - echo '
'; - } - ?> -
- intro); - ?> -
: - " onclick="return lockoptions('form', 'availableenable', availableitems)" timeopen) echo 'checked="checked"' ?> /> - timeopen); - echo " - "; - print_time_selector("availablehour", "availableminute", $form->timeopen); - helpbutton('timeopen', get_string('quizopens', 'quiz'), 'quiz'); - ?> - - - - - -
: - " onclick="return lockoptions('form', 'dueenable', dueitems)" timeclose) echo 'checked="checked"' ?> /> - timeclose); - echo " - "; - print_time_selector("duehour", "dueminute", $form->timeclose); - helpbutton('timeopen', get_string('quizcloses', 'quiz'), 'quiz'); - ?> - - - - - -
- -
:100%
: - -
: - -
:0%
: - - - - - -
-
-
- - - -
- -
-
- - - - - - - - - - - - -instance) { ?> -wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" /> -" /> - -" /> - -" /> -
-
- - - - - -quiz_fix_timelimit == $showfixed) { ?> - - : - - timelimit) echo 'checked="checked"' ?> /> - - - - - - - -quiz_fix_questionsperpage == $showfixed) { ?> - - : - - questionsperpage, ''); - helpbutton('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz'); - ?> - - - - -quiz_fix_shufflequestions == $showfixed) { ?> - - : - - shufflequestions", ""); - helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); - ?> - - - - -quiz_fix_shuffleanswers == $showfixed) { ?> - - : - - shuffleanswers", ""); - helpbutton("shufflewithin", get_string("shufflewithin","quiz"), "quiz"); - ?> - - - - -quiz_fix_attempts == $showfixed) { ?> - - : - - attempts", ""); - helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); - ?> - - - - -quiz_fix_attemptonlast == $showfixed) { ?> - - : - - attemptonlast", ""); - helpbutton("repeatattempts", - get_string("eachattemptbuildsonthelast", "quiz"), - "quiz"); - ?> - - - - -quiz_fix_grademethod == $showfixed) { ?> - - : - - grademethod", ""); - helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); - ?> - - - - -quiz_fix_adaptive == $showfixed) { ?> - - : - - optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); - helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); - ?> - - - - -quiz_fix_penaltyscheme == $showfixed) { ?> - - : - - penaltyscheme", ""); - helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); - ?> - - - - -quiz_fix_decimalpoints == $showfixed) { ?> - - : - - '0', - 1 => '1', - 2 => '2', - 3 => '3' - ); - choose_from_menu($options, "decimalpoints", "$form->decimalpoints", ""); - helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz"); - ?> - - - - -quiz_fix_review == $showfixed) { - echo ''; - include($CFG->dirroot . '/mod/quiz/reviewoptions.html'); - echo ''; - $output = true; -} ?> - -quiz_fix_delay1 == $showfixed) { ?> - - : - - delay1", ""); - helpbutton("timedelay1", get_string("delay1","quiz"), "quiz"); - ?> - - - - -quiz_fix_delay2 == $showfixed) { ?> - - : - - delay2", ""); - helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); - ?> - - - - -quiz_fix_popup == $showfixed) { ?> - - : - - popup", ""); - helpbutton("popup", get_string("popup","quiz"), "quiz"); - ?> - - - - -quiz_fix_password == $showfixed) { ?> - - : - - - - - - - -quiz_fix_subnet == $showfixed) { ?> - - : - - - - - - - \ No newline at end of file diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php new file mode 100644 index 0000000000..d083a9c67f --- /dev/null +++ b/mod/quiz/mod_form.php @@ -0,0 +1,334 @@ +dirroot/mod/quiz/locallib.php"); + +class quiz_mod_form extends moodleform_mod { + var $_feedbacks; + + function definition() { + + global $COURSE, $CFG, $QUIZ_GRADE_METHOD; + $mform =& $this->_form; + + $mform->setShowAdvanced(get_user_preferences('quiz_optionsettingspref', 0)); +//------------------------------------------------------------------------------- + $mform->addElement('header', 'general', get_string('general', 'form')); + + $mform->addElement('text', 'name', get_string('name')); + $mform->setType('name', PARAM_TEXT); + + $mform->addElement('htmleditor', 'intro', get_string("introduction", "quiz")); + $mform->setType('intro', PARAM_RAW); + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'timinghdr', get_string('timing', 'form')); + $mform->addElement('date_selector', 'timeopen', get_string("quizopen", "quiz"), array('optional'=>true)); + $mform->setHelpButton('timeopen', array('timeopen', get_string('quizopens', 'quiz'), 'quiz')); + + $mform->addElement('date_selector', 'timeclose', get_string("quizcloses", "quiz"), array('optional'=>true)); + $mform->setHelpButton('timeclose', array('timeopen', get_string('quizcloses', 'quiz'), 'quiz')); + + + $timelimitgrp=array(); + $timelimitgrp[] = &$mform->createElement('text', 'timelimit'); + $timelimitgrp[] = &$mform->createElement('checkbox', 'timelimitenable', '', get_string('enable')); + $mform->addGroup($timelimitgrp, 'timelimitgrp', get_string("timelimit", "quiz"), array(' '), false); + $mform->setType('timelimit', PARAM_TEXT); + $timelimitgrprules = array(); + $timelimitgrprules['timelimit'][] = array(null, 'numeric', null, 'client'); + $mform->addGroupRule('timelimitgrp', $timelimitgrprules); + $mform->disabledIf('timelimitgrp', 'timelimitenable'); + $mform->setAdvanced('timelimitgrp', $CFG->quiz_fix_timelimit); + $mform->setHelpButton('timelimitgrp', array("timelimit", get_string("quiztimer","quiz"), "quiz")); + $mform->setDefault('timelimit', $CFG->quiz_timelimit); + + + //enforced time delay between quiz attempts add-on + $timedelayoptions = array(); + $timedelayoptions[0] = get_string('none'); + $timedelayoptions[1800] = get_string('numminutes', '', 30); + $timedelayoptions[3600] = get_string('numminutes', '', 60); + for($i=2; $i<=23; $i++) { + $seconds = $i*3600; + $timedelayoptions[$seconds] = get_string('numhours', '', $i); + } + $timedelayoptions[86400] = get_string('numhours', '', 24); + for($i=2; $i<=7; $i++) { + $seconds = $i*86400; + $timedelayoptions[$seconds] = get_string('numdays', '', $i); + } + $mform->addElement('select', 'delay1', get_string("delay1", "quiz"), $timedelayoptions); + $mform->setHelpButton('delay1', array("timedelay1", get_string("delay1", "quiz"), "quiz")); + $mform->setAdvanced('delay1', $CFG->quiz_fix_delay1); + $mform->setDefault('delay1', $CFG->quiz_delay1); + + $mform->addElement('select', 'delay2', get_string("delay2", "quiz"), $timedelayoptions); + $mform->setHelpButton('delay2', array("timedelay2", get_string("delay2", "quiz"), "quiz")); + $mform->setAdvanced('delay2', $CFG->quiz_fix_delay2); + $mform->setDefault('delay2', $CFG->quiz_delay2); + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'displayhdr', get_string('display', 'form')); + $perpage = array(); + for ($i = 0; $i <= 50; ++$i) { + $perpage[$i] = $i; + } + $perpage[0] = get_string('allinone', 'quiz'); + $mform->addElement('select', 'questionsperpage', get_string('questionsperpage', 'quiz'), $perpage); + $mform->setHelpButton('questionsperpage', array('questionsperpage', get_string('questionsperpage', 'quiz'), 'quiz')); + $mform->setAdvanced('questionsperpage', $CFG->quiz_fix_questionsperpage); + $mform->setDefault('questionsperpage', $CFG->quiz_questionsperpage); + + $mform->addElement('selectyesno', 'shufflequestions', get_string("shufflequestions", "quiz")); + $mform->setHelpButton('shufflequestions', array("shufflequestions", get_string("shufflequestions","quiz"), "quiz")); + $mform->setAdvanced('shufflequestions', $CFG->quiz_fix_shufflequestions); + $mform->setDefault('shufflequestions', $CFG->quiz_shufflequestions); + + $mform->addElement('selectyesno', 'shuffleanswers', get_string("shufflewithin", "quiz")); + $mform->setHelpButton('shuffleanswers', array("shufflewithin", get_string("shufflewithin","quiz"), "quiz")); + $mform->setAdvanced('shuffleanswers', $CFG->quiz_fix_shuffleanswers); + $mform->setDefault('shuffleanswers', $CFG->quiz_shuffleanswers); + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'attemptshdr', get_string('attempts', 'quiz')); + $attemptoptions = array(); + $attemptoptions[0] = get_string("attemptsunlimited", "quiz"); + $attemptoptions[1] = "1 ".moodle_strtolower(get_string("attempt", "quiz")); + for ($i=2;$i<=6;$i++) { + $attemptoptions[$i] = "$i ".moodle_strtolower(get_string("attempts", "quiz")); + } + $mform->addElement('select', 'attempts', get_string("attemptsallowed", "quiz"), $attemptoptions); + $mform->setHelpButton('attempts', array("attempts", get_string("attemptsallowed","quiz"), "quiz")); + $mform->setAdvanced('attempts', $CFG->quiz_fix_attempts); + $mform->setDefault('attempts', $CFG->quiz_attempts); + + $mform->addElement('selectyesno', 'attemptonlast', get_string("eachattemptbuildsonthelast", "quiz")); + $mform->setHelpButton('attemptonlast', array("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz")); + $mform->setAdvanced('attemptonlast', $CFG->quiz_fix_attemptonlast); + $mform->setDefault('attemptonlast', $CFG->quiz_attemptonlast); + + $mform->addElement('selectyesno', 'adaptive', get_string("adaptive", "quiz")); + $mform->setHelpButton('adaptive', array("adaptive", get_string("adaptive","quiz"), "quiz")); + $mform->setAdvanced('adaptive', $CFG->quiz_fix_adaptive); + $mform->setDefault('adaptive', $CFG->quiz_optionflags & QUESTION_ADAPTIVE); + + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'gradeshdr', get_string('grades', 'grades')); + $mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), $QUIZ_GRADE_METHOD); + $mform->setHelpButton('grademethod', array("grademethod", get_string("grademethod","quiz"), "quiz")); + $mform->setAdvanced('grademethod', $CFG->quiz_fix_grademethod); + $mform->setDefault('grademethod', $CFG->quiz_grademethod); + + $mform->addElement('selectyesno', 'penaltyscheme', get_string("penaltyscheme", "quiz")); + $mform->setHelpButton('penaltyscheme', array("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz")); + $mform->setAdvanced('penaltyscheme', $CFG->quiz_fix_penaltyscheme); + $mform->setDefault('penaltyscheme', $CFG->quiz_penaltyscheme); + + $options = array( + 0 => '0', + 1 => '1', + 2 => '2', + 3 => '3'); + $mform->addElement('select', 'decimalpoints', get_string("decimaldigits", "quiz"), $options); + $mform->setHelpButton('decimalpoints', array("decimalpoints", get_string("decimaldigits","quiz"), "quiz")); + $mform->setAdvanced('decimalpoints', $CFG->quiz_fix_decimalpoints); + + $mform->addElement('hidden', 'grade', $CFG->quiz_maximumgrade); + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'reviewoptionshdr', get_string("reviewoptions", "quiz")); + $mform->setHelpButton('reviewoptionshdr', array("review2", get_string("allowreview","quiz"), "quiz")); + $mform->setAdvanced('reviewoptionshdr', $CFG->quiz_fix_review); + + $immediatelyoptionsgrp=array(); + $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'responsesimmediately', '', get_string('responses', 'quiz')); + $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'scoreimmediately', '', get_string('scores', 'quiz')); + $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackimmediately', '', get_string('feedback', 'quiz')); + $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'answersimmediately', '', get_string('answers', 'quiz')); + $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackimmediately', '', get_string('generalfeedback', 'quiz')); + $mform->addGroup($immediatelyoptionsgrp, 'immediatelyoptionsgrp', get_string("reviewimmediately", "quiz"), null, false); + $mform->setDefault('responsesimmediately', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('scoreimmediately', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('feedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('answersimmediately', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('generalfeedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY); + + $openoptionsgrp=array(); + $openoptionsgrp[] = &$mform->createElement('checkbox', 'responsesopen', '', get_string('responses', 'quiz')); + $openoptionsgrp[] = &$mform->createElement('checkbox', 'scoreopen', '', get_string('scores', 'quiz')); + $openoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackopen', '', get_string('feedback', 'quiz')); + $openoptionsgrp[] = &$mform->createElement('checkbox', 'answersopen', '', get_string('answers', 'quiz')); + $openoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackopen', '', get_string('generalfeedback', 'quiz')); + $mform->addGroup($openoptionsgrp, 'openoptionsgrp', get_string("reviewopen", "quiz"), array(' '), false); + $mform->setDefault('responsesopen', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN); + $mform->setDefault('scoreopen', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN); + $mform->setDefault('feedbackopen', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN); + $mform->setDefault('answersopen', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN); + $mform->setDefault('generalfeedbackopen', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN); + + + $closedoptionsgrp=array(); + $closedoptionsgrp[] = &$mform->createElement('checkbox', 'responsesclosed', '', get_string('responses', 'quiz')); + $closedoptionsgrp[] = &$mform->createElement('checkbox', 'scoreclosed', '', get_string('scores', 'quiz')); + $closedoptionsgrp[] = &$mform->createElement('checkbox', 'feedbackclosed', '', get_string('feedback', 'quiz')); + $closedoptionsgrp[] = &$mform->createElement('checkbox', 'answersclosed', '', get_string('answers', 'quiz')); + $closedoptionsgrp[] = &$mform->createElement('checkbox', 'generalfeedbackclosed', '', get_string('generalfeedback', 'quiz')); + $mform->addGroup($closedoptionsgrp, 'closedoptionsgrp', get_string("reviewclosed", "quiz"), array(' '), false); + $mform->setDefault('responsesclosed', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED); + $mform->setDefault('scoreclosed', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED); + $mform->setDefault('feedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED); + $mform->setDefault('answersclosed', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED); + $mform->setDefault('generalfeedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED); + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'security', get_string('security', 'form')); + + $mform->addElement('selectyesno', 'popup', get_string("popup", "quiz")); + $mform->setHelpButton('popup', array("popup", get_string("popup", "quiz"), "quiz")); + $mform->setAdvanced('popup', $CFG->quiz_fix_popup); + $mform->setDefault('popup', $CFG->quiz_popup); + + $mform->addElement('text', 'password', get_string("requirepassword", "quiz")); + $mform->setType('password', PARAM_TEXT); + $mform->setHelpButton('password', array("requirepassword", get_string("requirepassword", "quiz"), "quiz")); + $mform->setAdvanced('password', $CFG->quiz_fix_password); + $mform->setDefault('password', $CFG->quiz_password); + + $mform->addElement('text', 'subnet', get_string("requiresubnet", "quiz")); + $mform->setType('subnet', PARAM_TEXT); + $mform->setHelpButton('subnet', array("requiresubnet", get_string("requiresubnet", "quiz"), "quiz")); + $mform->setAdvanced('subnet', $CFG->quiz_fix_subnet); + $mform->setDefault('subnet', $CFG->quiz_subnet); + +//------------------------------------------------------------------------------- + $this->standard_coursemodule_elements(); +//------------------------------------------------------------------------------- + $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz')); + $mform->setHelpButton('overallfeedbackhdr', array('overallfeedback', get_string('overallfeedback', 'quiz'), 'quiz')); + + $mform->addElement('static', 'gradeboundarystatic1', get_string('gradeboundary', 'quiz'), '100%'); + + $repeatarray=array(); + $repeatarray[] = &MoodleQuickForm::createElement('text', 'feedbacktext', get_string('feedback', 'quiz')); + $repeatarray[] = &MoodleQuickForm::createElement('text', 'feedbackboundaries', get_string('gradeboundary', 'quiz')); + + if (!empty($this->_instance)) { + $this->_feedbacks = get_records('quiz_feedback', 'quizid', $this->_instance, 'mingrade DESC'); + } else { + $this->_feedbacks = array(); + } + $numfeedbacks = max(count($this->_feedbacks) * 1.5, 5); + $nextel=$this->repeat_elements($repeatarray, $numfeedbacks-1, + array('feedbacktext'=> array('type'=>PARAM_TEXT), + 'feedbackboundaries' => array('type'=>PARAM_TEXT)), + 'boundary_repeats', 'boundary_add_fields', 3); + + //put some extra elements in before the button + $insertEl = &MoodleQuickForm::createElement('text', "feedbacktext[$nextel]", get_string('feedback', 'quiz')); + $mform->insertElementBefore($insertEl, 'boundary_add_fields'); + $mform->setType("feedbacktext[$nextel]", PARAM_TEXT); + $mform->setHelpButton("feedbacktext[$nextel]", array('options', get_string('modulenameplural', 'choice'), 'choice')); + + $insertEl = &MoodleQuickForm::createElement('static', 'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%'); + $mform->insertElementBefore($insertEl, 'boundary_add_fields'); + +//------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(); + } + + function defaults_preprocessing(&$default_values){ + if (count($this->_feedbacks)) { + $key = 0; + foreach ($this->_feedbacks as $feedback){ + $default_values['feedbacktext['.$key.']'] = $feedback->feedbacktext; + if ($feedback->mingrade > 0) { + $default_values['feedbackboundaries['.$key.']'] = (100.0 * $feedback->mingrade / $default_values['grade']) . '%'; + } + $key++; + } + + } + if (empty($default_values['timelimit'])) { + $default_values['timelimitenable'] = 0; + } else { + $default_values['timelimitenable'] = 1; + } + + if (isset($default_values['review'])){ + $review = (int)$default_values['review']; + unset($default_values['review']); + + $default_values['responsesimmediately'] = $review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY; + $default_values['scoreimmediately'] = $review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY; + $default_values['feedbackimmediately'] = $review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY; + $default_values['answersimmediately'] = $review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY; + $default_values['generalfeedbackimmediately'] = $review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY; + + $default_values['responsesopen'] = $review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN; + $default_values['scoreopen'] = $review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN; + $default_values['feedbackopen'] = $review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN; + $default_values['answersopen'] = $review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN; + $default_values['generalfeedbackopen'] = $review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN; + + $default_values['responsesclosed'] = $review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED; + $default_values['scoreclosed'] = $review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED; + $default_values['feedbackclosed'] = $review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED; + $default_values['answersclosed'] = $review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED; + $default_values['generalfeedbackclosed'] = $review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED; + } + + if (isset($default_values['optionflags'])){ + $default_values['adaptive'] = $default_values['optionflags'] & QUESTION_ADAPTIVE; + unset($default_values['optionflags']); + } + } + + function validation($data){ + $errors = array(); + // Check open and close times are consistent. + if ($data['timeopen'] != 0 && $data['timeclose'] != 0 && $data['timeclose'] < $data['timeopen']) { + $errors['timeclose'] = get_string('closebeforeopen', 'quiz'); + } + + // Check the boundary value is a number or a percentage, and in range. + $i = 0; + while (!empty($data['feedbackboundaries'][$i] )) { + $boundary = trim($data['feedbackboundaries'][$i]); + if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') { + $boundary = trim(substr($boundary, 0, -1)); + if (is_numeric($boundary)) { + $boundary = $boundary * $data['grade'] / 100.0; + } else { + $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorboundaryformat', 'quiz', $i + 1); + } + } + if (is_numeric($boundary) && $boundary <= 0 || $boundary >= $data['grade'] ) { + $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorboundaryoutofrange', 'quiz', $i + 1); + } + if (is_numeric($boundary) && $i > 0 && $boundary >= $data['feedbackboundaries'][$i - 1]) { + $errors["feedbackboundaries[$i]"] = get_string('feedbackerrororder', 'quiz', $i + 1); + } + $data['feedbackboundaries'][$i] = $boundary; + $i += 1; + } + $numboundaries = $i; + + // Check there is nothing in the remaining unused fields. + for ($i = $numboundaries; $i < count($data['feedbackboundaries'] ); $i += 1) { + if (!empty($data['feedbackboundaries'][$i] ) && trim($data['feedbackboundaries'][$i] ) != '') { + $errors["feedbackboundaries[$i]"] = get_string('feedbackerrorjunkinboundary', 'quiz', $i + 1); + } + } + for ($i = $numboundaries + 1; $i < count($data['feedbacktext'] ); $i += 1) { + if (!empty($data['feedbacktext'][$i] ) && trim($data['feedbacktext'][$i] ) != '') { + $errors["feedbacktext[$i]"] = get_string('feedbackerrorjunkinfeedback', 'quiz', $i + 1); + } + } + return $errors; + } + +} +?> \ No newline at end of file diff --git a/mod/survey/details.php b/mod/survey/details.php index 379e5c1b82..4e4630d755 100644 --- a/mod/survey/details.php +++ b/mod/survey/details.php @@ -31,7 +31,9 @@ $mform->addElement('hidden', 'mode', $lastform->mode); $mform->addElement('hidden', 'visible', $lastform->visible); $mform->addElement('hidden', 'groupmode', $lastform->groupmode); - $mform->addElement('submit', 'submitbutton', get_string("savechanges")); +//------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(false); } } diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 7c0dc5b191..0ead3c3b16 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -319,7 +319,10 @@ form.mform fieldset legend { font-weight: bold; margin-left: 0.5em; } - +form.mform fieldset .advancedbutton{ + width:100%; + text-align:right; +} form.mform div.fitem { clear: both; width: 100%; -- 2.39.5