diff --git a/admin/roles/classes/capability_table_with_risks.php b/admin/roles/classes/capability_table_with_risks.php index acf7257e68e..96addb533d9 100644 --- a/admin/roles/classes/capability_table_with_risks.php +++ b/admin/roles/classes/capability_table_with_risks.php @@ -35,7 +35,6 @@ abstract class core_role_capability_table_with_risks extends core_role_capabilit protected $allpermissions; // We don't need perms ourselves, but all our subclasses do. protected $strperms; // Language string cache. protected $risksurl; // URL in moodledocs about risks. - protected $riskicons = array(); // Cache to avoid regenerating the HTML for each risk icon. /** @var array The capabilities to highlight as default/inherited. */ protected $parentpermissions; protected $displaypermissions; @@ -183,12 +182,12 @@ abstract class core_role_capability_table_with_risks extends core_role_capabilit */ public function get_risk_icon($type) { global $OUTPUT; - if (!isset($this->riskicons[$type])) { - $iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type)); - $text = '' . get_string($type . 'short', 'admin') . ''; - $action = new popup_action('click', $this->risksurl, 'docspopup'); - $this->riskicons[$type] = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin'))); - } - return $this->riskicons[$type]; + + $iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type)); + $text = '' . get_string($type . 'short', 'admin') . ''; + $action = new popup_action('click', $this->risksurl, 'docspopup'); + $riskicon = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin'))); + + return $riskicon; } } diff --git a/blocks/navigation/renderer.php b/blocks/navigation/renderer.php index 131c559ec4a..86565e83e75 100644 --- a/blocks/navigation/renderer.php +++ b/blocks/navigation/renderer.php @@ -70,7 +70,8 @@ class block_navigation_renderer extends plugin_renderer_base { // Turn our navigation items into list items. $lis = array(); - $number = 0; + // Set the number to be static for unique id's. + static $number = 0; foreach ($items as $item) { $number++; if (!$item->display && !$item->contains_active_node()) { diff --git a/grade/grading/form/rubric/renderer.php b/grade/grading/form/rubric/renderer.php index 6ea8a4b27a5..72b6b6052d6 100644 --- a/grade/grading/form/rubric/renderer.php +++ b/grade/grading/form/rubric/renderer.php @@ -450,6 +450,8 @@ class gradingform_rubric_renderer extends plugin_renderer_base { break; default: if ($mode == gradingform_rubric_controller::DISPLAY_EDIT_FROZEN && $value) { + // Id should be different then the actual input added later. + $attrs['id'] .= '_hidden'; $html .= html_writer::empty_tag('input', $attrs + array('type' => 'hidden', 'value' => $value)); } // Display option as checkbox @@ -461,6 +463,8 @@ class gradingform_rubric_renderer extends plugin_renderer_base { if ($mode == gradingform_rubric_controller::DISPLAY_EDIT_FROZEN || $mode == gradingform_rubric_controller::DISPLAY_PREVIEW) { $attrs['disabled'] = 'disabled'; unset($attrs['name']); + // Id should be different then the actual input added later. + $attrs['id'] .= '_disabled'; } $html .= html_writer::empty_tag('input', $attrs); $html .= html_writer::tag('label', get_string($option, 'gradingform_rubric'), array('for' => $attrs['id'])); diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index d0b13f51281..53d74200473 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -1603,8 +1603,9 @@ class grade_report_grader extends grade_report { } $name = shorten_text($element['object']->get_name()); - $courseheader = html_writer::tag('span', $name, array('id' => 'courseheader')); - $courseheader .= html_writer::label($showing, 'courseheader', false, array('class' => 'accesshide')); + $courseheaderid = 'courseheader_' . clean_param($name, PARAM_ALPHANUMEXT); + $courseheader = html_writer::tag('span', $name, array('id' => $courseheaderid)); + $courseheader .= html_writer::label($showing, $courseheaderid, false, array('class' => 'accesshide')); $courseheader .= $icon; return $courseheader; diff --git a/lib/form/advcheckbox.php b/lib/form/advcheckbox.php index 0d1c3cca054..97118d6410f 100644 --- a/lib/form/advcheckbox.php +++ b/lib/form/advcheckbox.php @@ -130,5 +130,4 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox{ } return $output; } - } diff --git a/lib/form/text.php b/lib/form/text.php index a1af03b747e..8b8c5580319 100644 --- a/lib/form/text.php +++ b/lib/form/text.php @@ -124,5 +124,4 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{ function getHelpButton(){ return $this->_helpbutton; } - } diff --git a/lib/form/url.php b/lib/form/url.php index 4a22571136c..eb54220556c 100644 --- a/lib/form/url.php +++ b/lib/form/url.php @@ -119,7 +119,7 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{ if (count($options->repositories) > 0) { $straddlink = get_string('choosealink', 'repository'); $str .= << + EOD; diff --git a/lib/formslib.php b/lib/formslib.php index a616133d5d0..e0639a24315 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -2651,7 +2651,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ 'actionbuttons'=>"\n\t\t".'
{element}
', - 'fieldset'=>"\n\t\t".'
{help}
{error}
{element}
', + 'fieldset'=>"\n\t\t".'
{help}
{error}
{element}
', 'static'=>"\n\t\t".'
{label}{req}{advancedimg} {help}
{error}
{element}
', @@ -2766,6 +2766,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ $html =str_replace('{id}', 'fgroup_' . $group->getAttribute('id'), $html); $html =str_replace('{name}', $group->getName(), $html); $html =str_replace('{type}', 'fgroup', $html); + $html =str_replace('{class}', $group->getAttribute('class'), $html); $emptylabel = ''; if ($group->getLabel() == '') { $emptylabel = 'femptylabel'; diff --git a/lib/pear/HTML/QuickForm/element.php b/lib/pear/HTML/QuickForm/element.php index dc615f52e07..89597aa8a06 100644 --- a/lib/pear/HTML/QuickForm/element.php +++ b/lib/pear/HTML/QuickForm/element.php @@ -254,11 +254,18 @@ class HTML_QuickForm_element extends HTML_Common return ''; } else { $id = $this->getAttribute('id'); + if (isset($id)) { + // Id of persistant input is different then the actual input. + $id = array('id' => $id . '_persistant'); + } else { + $id = array(); + } + return '_getAttrString(array( 'type' => 'hidden', 'name' => $this->getName(), 'value' => $this->getValue() - ) + (isset($id)? array('id' => $id): array())) . ' />'; + ) + $id) . ' />'; } } @@ -486,4 +493,4 @@ class HTML_QuickForm_element extends HTML_Common // }}} } // end class HTML_QuickForm_element -?> \ No newline at end of file +?> diff --git a/lib/pear/README_MOODLE.txt b/lib/pear/README_MOODLE.txt index 02eb5b7e1ce..0737feb05a0 100644 --- a/lib/pear/README_MOODLE.txt +++ b/lib/pear/README_MOODLE.txt @@ -30,6 +30,7 @@ MDL-46467 - $mform->hardfreeze causes labels to loose their for HTML attribute MDL-52081 - made all constructors PHP7 compatible MDL-52826 - Remove onsubmit events pointing to the global validation functions and script tag moved after the HTML +MDL-50484 - _getPersistantData() returns id with _persistant prefixed to element id. Pear diff --git a/lib/tests/formslib_test.php b/lib/tests/formslib_test.php index cfe314caba1..fb44b9138cf 100644 --- a/lib/tests/formslib_test.php +++ b/lib/tests/formslib_test.php @@ -577,6 +577,35 @@ class core_formslib_testcase extends advanced_testcase { $this->assertTag(array('id' => 'id_grade_3_modgrade_point'), $html); $this->assertTag(array('id' => 'id_grade_3_modgrade_scale'), $html); } + + /** + * Test persistant freeze elements have different id's. + */ + public function test_persistantrreeze_element() { + $this->resetAfterTest(true); + + $form = new formslib_persistantrreeze_element(); + ob_start(); + $form->display(); + $html = ob_get_clean(); + + // Test advcheckbox id's. + $this->assertTag(array('id' => 'id_advcheckboxpersistant'), $html); + $this->assertTag(array('id' => 'id_advcheckboxpersistant_persistant'), $html); + $this->assertTag(array('id' => 'id_advcheckboxnotpersistant'), $html); + $this->assertNotTag(array('id' => 'id_advcheckboxnotpersistant_persistant'), $html); + $this->assertTag(array('id' => 'id_advcheckboxfrozen'), $html); + $this->assertTag(array('id' => 'id_advcheckboxfrozen_persistant'), $html); + + // Check text element id's. + $this->assertTag(array('id' => 'id_textpersistant'), $html); + $this->assertTag(array('id' => 'id_textpersistant_persistant'), $html); + $this->assertTag(array('id' => 'id_textnotpersistant'), $html); + $this->assertNotTag(array('id' => 'id_textnotpersistant_persistant'), $html); + $this->assertTag(array('id' => 'id_textfrozen'), $html); + $this->assertNotTag(array('id' => 'id_textfrozen_persistant'), $html); + + } } @@ -861,3 +890,42 @@ class formslib_multiple_modgrade_form extends moodleform { $mform->addElement('modgrade', 'grade[3]', 'Grade 3'); } } + +/** + * Used to test frozen elements get unique id attributes. + */ +class formslib_persistantrreeze_element extends moodleform { + public function definition() { + $mform = $this->_form; + + // Create advanced checkbox. + // Persistant. + $advcheckboxpersistant = $mform->addElement('advcheckbox', 'advcheckboxpersistant', 'advcheckbox'); + $mform->setType('advcheckboxpersistant', PARAM_BOOL); + $advcheckboxpersistant->setChecked(true); + $advcheckboxpersistant->freeze(); + $advcheckboxpersistant->setPersistantFreeze(true); + // Frozen. + $advcheckboxfrozen = $mform->addElement('advcheckbox', 'advcheckboxfrozen', 'advcheckbox'); + $mform->setType('advcheckboxfrozen', PARAM_BOOL); + $advcheckboxfrozen->setChecked(true); + $advcheckboxfrozen->freeze(); + // Neither persistant nor Frozen. + $mform->addElement('advcheckbox', 'advcheckboxnotpersistant', 'advcheckbox'); + $mform->setType('advcheckboxnotpersistant', PARAM_BOOL); + + // Create text fields. + // Persistant. + $elpersistant = $mform->addElement('text', 'textpersistant', 'test', 'test'); + $mform->setType('textpersistant', PARAM_TEXT); + $elpersistant->freeze(); + $elpersistant->setPersistantFreeze(true); + // Frozen. + $elfrozen = $mform->addElement('text', 'textfrozen', 'test', 'test'); + $mform->setType('textfrozen', PARAM_TEXT); + $elfrozen->freeze(); + // Neither persistant nor Frozen. + $mform->addElement('text', 'textnotpersistant', 'test', 'test'); + $mform->setType('textnotpersistant', PARAM_TEXT); + } +} \ No newline at end of file diff --git a/mod/lesson/pagetypes/truefalse.php b/mod/lesson/pagetypes/truefalse.php index 5a8623d8c50..8ce8f094f60 100644 --- a/mod/lesson/pagetypes/truefalse.php +++ b/mod/lesson/pagetypes/truefalse.php @@ -409,24 +409,28 @@ class lesson_display_answer_form_truefalse extends moodleform { $mform->setType('pageid', PARAM_INT); $i = 0; + $radiobuttons = array(); foreach ($answers as $answer) { - $mform->addElement('html', '
'); $ansid = 'answerid'; if ($hasattempt) { $ansid = 'answer_id'; } - $mform->addElement('radio', $ansid, null, format_text($answer->answer, $answer->answerformat, $options), $answer->id, $disabled); + $radiobuttons[] = $mform->createElement('radio', $ansid, null, + format_text($answer->answer, $answer->answerformat, $options), $answer->id, $disabled); + $mform->setType($ansid, PARAM_INT); if ($hasattempt && $answer->id == $USER->modattempts[$lessonid]->answerid) { $mform->setDefault($ansid, $attempt->answerid); $mform->addElement('hidden', 'answerid', $answer->id); $mform->setType('answerid', PARAM_INT); } - $mform->addElement('html', '
'); $i++; } + $radiogroup = $mform->addGroup($radiobuttons, $ansid, '', array(''), false); + $radiogroup->setAttributes(array('class' => 'answeroptiongroup')); + if ($hasattempt) { $this->add_action_buttons(null, get_string("nextpage", "lesson")); } else { diff --git a/mod/lesson/styles.css b/mod/lesson/styles.css index c972a91c98c..382ce90c501 100644 --- a/mod/lesson/styles.css +++ b/mod/lesson/styles.css @@ -26,14 +26,18 @@ .path-mod-lesson .resourcecontent {text-align: center;} -.path-mod-lesson .answeroption .fcheckbox > span, -.path-mod-lesson .answeroption .fradio > span { +.path-mod-lesson .answeroption .fcheckbox > span { position: relative; float: left; } +.path-mod-lesson .answeroptiongroup .fgroup > span { + position: relative; + width: 100%; +} + .path-mod-lesson .answeroption .fcheckbox input, -.path-mod-lesson .answeroption .fradio input { +.path-mod-lesson .answeroptiongroup input { position: absolute; top: 2px; margin-top: 0px; @@ -41,28 +45,28 @@ } .path-mod-lesson .answeroption .fcheckbox label, -.path-mod-lesson .answeroption .fradio label { +.path-mod-lesson .mform .fitem.answeroptiongroup fieldset.fgroup label { padding-left: 20px; float: left; } -.path-mod-lesson .answeroption .felement label p:last-child { +.path-mod-lesson .answeroption .felement label p:last-child, +.path-mod-lesson .answeroptiongroup .felement label p:last-child { margin-bottom: 0px; } -.path-mod-lesson.dir-rtl .answeroption .fcheckbox > span, -.path-mod-lesson.dir-rtl .answeroption .fradio > span { +.path-mod-lesson.dir-rtl .answeroption .fcheckbox > span { float: right; } .path-mod-lesson.dir-rtl .answeroption .fcheckbox input, -.path-mod-lesson.dir-rtl .answeroption .fradio input { +.path-mod-lesson.dir-rtl .answeroptiongroup .fgroup input { left: inherit; right: 0; } .path-mod-lesson.dir-rtl .answeroption .fcheckbox label, -.path-mod-lesson.dir-rtl .answeroption .fradio label { +.path-mod-lesson.dir-rtl .mform .fitem.answeroptiongroup fieldset.fgroup label { padding-left: 0; padding-right: 20px; float: right; diff --git a/user/addnote.php b/user/addnote.php index 4072718bb2f..d4f764be86e 100644 --- a/user/addnote.php +++ b/user/addnote.php @@ -103,9 +103,9 @@ foreach ($users as $k => $v) { if (!$user = $DB->get_record('user', array('id' => $v))) { continue; } - $checkbox = html_writer::label(get_string('selectnotestate', 'notes'), 'menustates', false, array('class' => 'accesshide')); + $checkbox = html_writer::label(get_string('selectnotestate', 'notes'), 'menustates_'.$v, false, array('class' => 'accesshide')); $checkbox .= html_writer::select($statenames, 'states[' . $k . ']', - empty($states[$k]) ? NOTES_STATE_PUBLIC : $states[$k], false, array('id' => 'menustates')); + empty($states[$k]) ? NOTES_STATE_PUBLIC : $states[$k], false, array('id' => 'menustates_'.$v)); $table->data[] = array( ''. fullname($user, true), '',