Moodle
  1. Moodle
  2. MDL-27896

Incorrect context set in course/edit.php prevent emoticons to observe filters status properly

    Details

    • Testing Instructions:
      Hide
                            1. Test editor filters ############
                              1. Log in as Admin
                              2. Turn emoticons on (Site administration -> Plugins -> filters -> Manage filters -> Display emoticons as images)
                              3. Turn editing on
                              4. Select a course
                              5. Click settings -> Edit settings
                              6. Click on emoticon icon and add an emoticon in course summary
                              7. Save course
                              8. Turn emoticons off for the course (Settings -> Filters -> Display emoticons as images )
                              9. Click settings -> Edit settings
                              10. Emoticon icon should not be visible, but text version of emoticon should be shown.
                              11. Select another course and click settings -> edit settings
                              12. You should be able to see emoticons button in course summary editor.
                              13. Try perform similar test for cohort

      test category:
      1. Create a category
      2. turn off emoticon filter
      3. Add a subcategory and emoticon button should not be visible
      4. Add course and emoticons should not be visible
      5. Turn emoticon "on" on category
      6. repeat 3 and 4, and emoticon button should be visible.

                            1. Test files ############
                              1. edit category and insert image
                              2. Save category and edit again, image should be visible
                              3. Try create multiple categories and sub-categories and repeat step 1,2.
                              4. Try test the same in cohort, course, assignment, feedback, lesson, wiki, workshop and user
      Show
      Test editor filters ############ 1. Log in as Admin 2. Turn emoticons on (Site administration -> Plugins -> filters -> Manage filters -> Display emoticons as images) 3. Turn editing on 4. Select a course 5. Click settings -> Edit settings 6. Click on emoticon icon and add an emoticon in course summary 7. Save course 8. Turn emoticons off for the course (Settings -> Filters -> Display emoticons as images ) 9. Click settings -> Edit settings 10. Emoticon icon should not be visible, but text version of emoticon should be shown. 11. Select another course and click settings -> edit settings 12. You should be able to see emoticons button in course summary editor. 13. Try perform similar test for cohort test category: 1. Create a category 2. turn off emoticon filter 3. Add a subcategory and emoticon button should not be visible 4. Add course and emoticons should not be visible 5. Turn emoticon "on" on category 6. repeat 3 and 4, and emoticon button should be visible. Test files ############ 1. edit category and insert image 2. Save category and edit again, image should be visible 3. Try create multiple categories and sub-categories and repeat step 1,2. 4. Try test the same in cohort, course, assignment, feedback, lesson, wiki, workshop and user
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull Master Branch:
      wip-mdl-27896
    • Rank:
      17547

      Description

      While integrating MDL-27500 and playing with new code was detected that the course->summary editor was not observing the filters status for the course context, causing the emoticons button (tinymce plugin) to be shown / hidden incorrectly.

      After a nice trace session with David, it seems that we need to:

      1) Add the missing 'context' element to the editoroptions array in course/edit.php

      And also we have agreed it would be great to have some central check in order to find anomalous situations like that, so we have decided to:

      2) Modify file_prepare_editor() (not used in all forms but in a hight %, and it's the only central point where both $options and $context are available) to:

      2a) missing both OK
      2b) $context !== $options['context'] then EXCEPTION
      2c) missing one of them DEBUGGING_DEVELOPER

      1. chat.txt
        13 kB
        David Mudrak

        Issue Links

          Activity

          Eloy Lafuente (stronk7) created issue -
          Eloy Lafuente (stronk7) made changes -
          Field Original Value New Value
          Fix Version/s 2.1 [ 10370 ]
          Priority Minor [ 4 ] Major [ 3 ]
          Labels triaged
          Affects Version/s 2.0 [ 10122 ]
          Eloy Lafuente (stronk7) made changes -
          Link This issue has been marked as being related by MDL-27500 [ MDL-27500 ]
          Martin Dougiamas made changes -
          Fix Version/s 2.1.1 [ 10750 ]
          Fix Version/s 2.1 [ 10370 ]
          Rajesh Taneja made changes -
          Assignee moodle.com [ moodle.com ] Rajesh Taneja [ rajeshtaneja ]
          Rajesh Taneja made changes -
          Status Open [ 1 ] Development in progress [ 3 ]
          Rajesh Taneja made changes -
          Fix Version/s STABLE Sprint 11 [ 10751 ]
          David Mudrak made changes -
          Attachment chat.txt [ 24308 ]
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Pull Master Diff URL https://github.com/rajeshtaneja/moodle/compare/master...wip-mdl-27896
          Pull Master Branch wip-mdl-27896
          Pull 2.0 Diff URL https://github.com/rajeshtaneja/moodle/compare/MOODLE_20_STABLE...wip-mdl-27896-MOODLE_20_STABLE
          Pull 2.0 Branch wip-mdl-27896-MOODLE_20_STABLE
          Pull from Repository git://github.com/rajeshtaneja/moodle.git
          Pull 2.1 Branch wip-mdl-27896-MOODLE_21_STABLE
          Pull 2.1 Diff URL https://github.com/rajeshtaneja/moodle/compare/MOODLE_21_STABLE...wip-mdl-27896-MOODLE_21_STABLE
          Peer reviewer rwijaya
          Rajesh Taneja made changes -
          Testing Instructions 1. Enable emoticons filter (Site administration -> Plugins -> Manage filters -> Activate "Display emoticons as images)
          2. select course
          3. edit course (Settings -> Edit settings)
          4. Check course summary should show emoticons button in tinymce
          5. Now disable emoticons filter
          6. Check course summary and now emoticons buttons should not be visible.
          Rossiani Wijaya made changes -
          Original Estimate 0 minutes [ 0 ]
          Remaining Estimate 0 minutes [ 0 ]
          Status Waiting for peer review [ 10012 ] Development in progress [ 3 ]
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Open [ 1 ]
          Rajesh Taneja made changes -
          Status Open [ 1 ] Waiting for integration review [ 10010 ]
          Sam Hemelryk made changes -
          Currently in integration Yes
          Petr Škoda made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator skodak
          Petr Škoda made changes -
          Status Integration review in progress [ 10004 ] Reopened [ 4 ]
          Petr Škoda made changes -
          Fix Version/s 2.1.1 [ 10750 ]
          Petr Škoda made changes -
          Currently in integration Yes
          Rajesh Taneja made changes -
          Status Reopened [ 4 ] Waiting for integration review [ 10010 ]
          Sam Hemelryk made changes -
          Currently in integration Yes
          Petr Škoda made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Petr Škoda made changes -
          Status Integration review in progress [ 10004 ] Reopened [ 4 ]
          Petr Škoda made changes -
          Currently in integration Yes
          Rajesh Taneja made changes -
          Testing Instructions 1. Enable emoticons filter (Site administration -> Plugins -> Manage filters -> Activate "Display emoticons as images)
          2. select course
          3. edit course (Settings -> Edit settings)
          4. Check course summary should show emoticons button in tinymce
          5. Now disable emoticons filter
          6. Check course summary and now emoticons buttons should not be visible.
          1. Enable emoticons filter (Site administration -> Plugins -> Manage filters -> Activate "Display emoticons as images)
          2. select course
          3. edit course (Settings -> Edit settings)
          4. Check course summary should show emoticons button in tinymce
          5. Now disable emoticons filter for this course.
          6. Check course summary and now emoticons buttons should not be visible.
          Rajesh Taneja made changes -
          Comment [ Hello Petr,

          I tried exploring a bit more and figure out the following:
          # $options['context'] in file_prepare_standard_editor is not required, as this is is just updating the data (which is later passed to form.). Hence, initial change in filelib.php was wrong.
          # editoroptions are actually passed by add_element, {code}$mform->addElement('editor','summary_editor', get_string('coursesummary'), null, $editoroptions);{code}

          Now, the problem is do we need to pass context to editoroptions? This is a bit tricky part as $editoroptions['context'] is used by TinyMCE and filepicker(for image, media and links).
          {code:title=lib/form/editor.php}
          function toHtml() {
          ...
             $fpoptions['image'] = $image_options;
             $fpoptions['media'] = $media_options;
             $fpoptions['link'] = $link_options;
          // print text area - TODO: add on-the-fly switching, size configuration, etc.
             $editor->use_editor($id, $this->_options, $fpoptions);
          ...
          }
          {code}
          Currently, editoroptions['context'] is not set in most of the calls, hence breaks the filter behavior.

          At this point, I feel adding context in course and category is safe and will solve the purpose.
          I am still looking at other modules where context is not passed to editor and will update the branches as I progress.

          Please advice :) ]
          moodle.com made changes -
          Fix Version/s STABLE Sprint 12 [ 10850 ]
          Fix Version/s STABLE Sprint 11 [ 10751 ]
          Dongsheng Cai made changes -
          Assignee Rajesh Taneja [ rajeshtaneja ] Dongsheng Cai [ dongsheng ]
          Dongsheng Cai made changes -
          Assignee Dongsheng Cai [ dongsheng ] Rajesh Taneja [ rajeshtaneja ]
          Dongsheng Cai made changes -
          Peer reviewer rwijaya dongsheng
          Dongsheng Cai made changes -
          Status Reopened [ 4 ] Waiting for integration review [ 10010 ]
          Petr Škoda made changes -
          Currently in integration Yes
          Petr Škoda made changes -
          Integrator skodak
          Sam Hemelryk made changes -
          Status Waiting for integration review [ 10010 ] Reopened [ 4 ]
          Petr Škoda made changes -
          Currently in integration Yes
          Rajesh Taneja made changes -
          Status Reopened [ 4 ] Waiting for integration review [ 10010 ]
          Sam Hemelryk made changes -
          Currently in integration Yes
          Eloy Lafuente (stronk7) made changes -
          Status Waiting for integration review [ 10010 ] Reopened [ 4 ]
          Rajesh Taneja made changes -
          Testing Instructions 1. Enable emoticons filter (Site administration -> Plugins -> Manage filters -> Activate "Display emoticons as images)
          2. select course
          3. edit course (Settings -> Edit settings)
          4. Check course summary should show emoticons button in tinymce
          5. Now disable emoticons filter for this course.
          6. Check course summary and now emoticons buttons should not be visible.
          ############ Test editor filters ############
          1. Log in as Admin
          2. Turn emoticons on (Site administration -> Plugins -> filters -> Manage filters -> Display emoticons as images)
          3. Turn editing on
          4. Select a course
          5. Click settings -> Edit settings
          6. Click on emoticon icon and add an emoticon in course summary
          7. Save course
          8. Turn emoticons off for the course (Settings -> Filters -> Display emoticons as images (off))
          9. Click settings -> Edit settings
          10. Emoticon icon should not be visible, but text version of emoticon should be shown.
          11. Select another course and click settings -> edit settings
          12. You should be able to see emoticons button in course summary editor.
          13. Try perform similar test for cohort

          test category:
          1. Create a category
          2. turn off emoticon filter
          3. Add a subcategory and emoticon button should not be visible
          4. Add course and emoticons should not be visible
          5. Turn emoticon "on" on category
          6. repeat 3 and 4, and emoticon button should be visible.

          ############ Test files ############
          1. edit category and insert image
          2. Save category and edit again, image should be visible
          3. Try create multiple categories and sub-categories and repeat step 1,2.
          4. Try test the same in cohort, course, assignment, feedback, lesson, wiki, workshop and user
          Eloy Lafuente (stronk7) made changes -
          Currently in integration Yes
          Rajesh Taneja made changes -
          Status Reopened [ 4 ] Waiting for integration review [ 10010 ]
          Eloy Lafuente (stronk7) made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator stronk7
          Currently in integration Yes
          Eloy Lafuente (stronk7) made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Michael de Raadt made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Tester salvetore
          Michael de Raadt made changes -
          Link This issue has been marked as being related by MDL-28954 [ MDL-28954 ]
          Michael de Raadt made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          Eloy Lafuente (stronk7) made changes -
          Integration date 17/Aug/11
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Affects Version/s 2.0.4 [ 10652 ]
          Affects Version/s 2.2 [ 10656 ]
          Fix Version/s 2.0.5 [ 10950 ]
          Fix Version/s 2.1.2 [ 10851 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes
          Eloy Lafuente (stronk7) made changes -
          Fix Version/s STABLE Sprint 12 [ 10850 ]

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: