### Eclipse Workspace Patch 1.0 #P moodle_1.9 Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.970.2.77 diff -u -r1.970.2.77 weblib.php --- lib/weblib.php 1 Apr 2008 19:47:47 -0000 1.970.2.77 +++ lib/weblib.php 17 Apr 2008 15:27:46 -0000 @@ -4174,14 +4174,22 @@ * @param string $tooltip a tooltip to add to the button as a title attribute. * @param boolean $disabled if true, the button will be disabled. * @param string $jsconfirmmessage if not empty then display a confirm dialogue with this string as the question. + * @param boolean $preventdoublesubmit if true, then when the form is submitted, + * the button is disabled to prevent repeat submissions. Default false. * @return string / nothing depending on the $return paramter. */ -function print_single_button($link, $options, $label='OK', $method='get', $target='_self', $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='') { +function print_single_button($link, $options, $label='OK', $method='get', $target='_self', + $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $preventdoublesubmit = false) { $output = ''; $link = str_replace('"', '"', $link); //basic XSS protection + if ($preventdoublesubmit) { + $onsubmit = ' onsubmit="var inputs=this.getElementsByTagName(\'input\');inputs[inputs.length-1].disabled=true;"'; + } else { + $onsubmit = ''; + } $output .= '
"; if ($return) { Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.41.2.3 diff -u -r1.41.2.3 format.php --- question/format/xml/format.php 12 Feb 2008 11:55:33 -0000 1.41.2.3 +++ question/format/xml/format.php 17 Apr 2008 15:27:46 -0000 @@ -302,6 +302,8 @@ $qo = $this->import_headers( $question ); // header parts particular to shortanswer $qo->qtype = DESCRIPTION; + $qo->defaultgrade = 0; + $qo->length = 0; return $qo; } Index: question/format/gift/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/gift/format.php,v retrieving revision 1.24.2.4 diff -u -r1.24.2.4 format.php --- question/format/gift/format.php 29 Nov 2007 04:31:14 -0000 1.24.2.4 +++ question/format/gift/format.php 17 Apr 2008 15:27:46 -0000 @@ -277,6 +277,8 @@ switch ($question->qtype) { case DESCRIPTION: + $question->defaultgrade = 0; + $question->length = 0; return $question; break; case ESSAY: #P moodle_sourceforge Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.1055 diff -u -r1.1055 weblib.php --- lib/weblib.php 8 Apr 2008 16:10:49 -0000 1.1055 +++ lib/weblib.php 17 Apr 2008 15:27:48 -0000 @@ -4199,15 +4199,22 @@ * @param string $tooltip a tooltip to add to the button as a title attribute. * @param boolean $disabled if true, the button will be disabled. * @param string $jsconfirmmessage if not empty then display a confirm dialogue with this string as the question. + * @param boolean $preventdoublesubmit if true, then when the form is submitted, + * the button is disabled to prevent repeat submissions. Default false. * @return string / nothing depending on the $return paramter. */ function print_single_button($link, $options, $label='OK', $method='get', $notusedanymore='', - $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='') { + $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $preventdoublesubmit = false) { $output = ''; $link = str_replace('"', '"', $link); //basic XSS protection + if ($preventdoublesubmit) { + $onsubmit = ' onsubmit="var inputs=this.getElementsByTagName(\'input\');inputs[inputs.length-1].disabled=true;"'; + } else { + $onsubmit = ''; + } $output .= '"; if ($return) { Index: question/format/gift/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/gift/format.php,v retrieving revision 1.27 diff -u -r1.27 format.php --- question/format/gift/format.php 29 Nov 2007 04:31:57 -0000 1.27 +++ question/format/gift/format.php 17 Apr 2008 15:27:48 -0000 @@ -277,6 +277,8 @@ switch ($question->qtype) { case DESCRIPTION: + $question->defaultgrade = 0; + $question->length = 0; return $question; break; case ESSAY: Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.44 diff -u -r1.44 format.php --- question/format/xml/format.php 4 Apr 2008 02:54:52 -0000 1.44 +++ question/format/xml/format.php 17 Apr 2008 15:27:48 -0000 @@ -302,6 +302,8 @@ $qo = $this->import_headers( $question ); // header parts particular to shortanswer $qo->qtype = DESCRIPTION; + $qo->defaultgrade = 0; + $qo->length = 0; return $qo; } #P moodle_1.6 Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.5.4.2 diff -u -r1.5.4.2 format.php --- question/format/xml/format.php 11 May 2007 15:30:49 -0000 1.5.4.2 +++ question/format/xml/format.php 17 Apr 2008 15:27:49 -0000 @@ -299,6 +299,8 @@ $qo = $this->import_headers( $question ); // header parts particular to shortanswer $qo->qtype = DESCRIPTION; + $qo->defaultgrade = 0; + $qo->length = 0; return $qo; } #P moodle_1.7 Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.16.2.10 diff -u -r1.16.2.10 format.php --- question/format/xml/format.php 24 Sep 2007 14:16:58 -0000 1.16.2.10 +++ question/format/xml/format.php 17 Apr 2008 15:27:50 -0000 @@ -350,6 +350,8 @@ $qo = $this->import_headers( $question ); // header parts particular to shortanswer $qo->qtype = DESCRIPTION; + $qo->defaultgrade = 0; + $qo->length = 0; return $qo; } #P moodle_1.8 Index: question/format/gift/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/gift/format.php,v retrieving revision 1.15.2.11 diff -u -r1.15.2.11 format.php --- question/format/gift/format.php 29 Nov 2007 04:30:28 -0000 1.15.2.11 +++ question/format/gift/format.php 17 Apr 2008 15:27:51 -0000 @@ -274,6 +274,8 @@ switch ($question->qtype) { case DESCRIPTION: + $question->defaultgrade = 0; + $question->length = 0; return $question; break; case ESSAY: Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.21.2.16 diff -u -r1.21.2.16 format.php --- question/format/xml/format.php 15 Jan 2008 14:58:10 -0000 1.21.2.16 +++ question/format/xml/format.php 17 Apr 2008 15:27:51 -0000 @@ -299,6 +299,8 @@ $qo = $this->import_headers( $question ); // header parts particular to shortanswer $qo->qtype = DESCRIPTION; + $qo->defaultgrade = 0; + $qo->length = 0; return $qo; }