Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-33774

Convert hardcode tests for label to module_supports()

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3, 2.5
    • Fix Version/s: 2.5
    • Component/s: Libraries
    • Testing Instructions:
      Hide

      Hopefully this issue will be integrated together with MDL-37455 and they can be tested together.

      Test 1. Upgrade

      1. BEFORE integrating this issue
      2. Create course with labels in it (or several courses)
      3. Apply commits from this issue
      4. Run upgrade
      5. Make sure that you can view the courses and see all labels

      Test 2.

      1. Create a course in weeks/topics format with at least one label, one folder that is displayed inside the course (see MDL-37455) and one normal module
      2. Add recent activity block
      3. Turn editing on and try different actions on modules - inline edit of the name, hide/show, duplicate, delete. Make sure all works
      4. Make sure recent activity block shows actions on non-inline module only (exception: the delete action on inline folder will be shown)
      5. Login as student, view the first course, do some activities on the course (view, submit assignment, etc.)
      6. Login as admin/teacher, view all available reports on the course, make sure that only activities on non-inline module(s) are shown
      7. Enable filter "activity names"
      8. Create some text in the course where you use all names of existing activities
      9. Make sure that filter auto-link only activities that are not displayed inline
      10. Create a course in social format, add similar 3 activities in the block, turn editing on, make sure editing buttons work
      Show
      Hopefully this issue will be integrated together with MDL-37455 and they can be tested together. Test 1. Upgrade BEFORE integrating this issue Create course with labels in it (or several courses) Apply commits from this issue Run upgrade Make sure that you can view the courses and see all labels Test 2. Create a course in weeks/topics format with at least one label, one folder that is displayed inside the course (see MDL-37455 ) and one normal module Add recent activity block Turn editing on and try different actions on modules - inline edit of the name, hide/show, duplicate, delete. Make sure all works Make sure recent activity block shows actions on non-inline module only (exception: the delete action on inline folder will be shown) Login as student, view the first course, do some activities on the course (view, submit assignment, etc.) Login as admin/teacher, view all available reports on the course, make sure that only activities on non-inline module(s) are shown Enable filter "activity names" Create some text in the course where you use all names of existing activities Make sure that filter auto-link only activities that are not displayed inline Create a course in social format, add similar 3 activities in the block, turn editing on, make sure editing buttons work
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      wip-MDL-33774-master

      Description

      As discovered in MDL-33726, we need to convert hardcoded use of labels:

      grep -r "== [\"']label[\"']" *
       
      course/lib.php:            if ($info[0] == 'label') {     // Labels are ignored in recent activity
      course/lib.php:    if ($mod->modname !== 'label' && $hasmanageactivities && course_ajax_enabled($COURSE)) {
      lib/modinfolib.php:        if ($this->modname === 'label' && $this->content === '') {
      report/log/locallib.php:            if ($mod->mod == "label") {
      report/log/locallib.php:            if ($mod->mod == "label") {

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              skodak Petr Skoda added a comment -

              I am going to drop everything simpletest related in 2.4dev asap.

              Show
              skodak Petr Skoda added a comment - I am going to drop everything simpletest related in 2.4dev asap.
              Hide
              poltawski Dan Poltawski added a comment -

              oops, just removed the simpletest things here as not relevant (not regarding mod label)

              Show
              poltawski Dan Poltawski added a comment - oops, just removed the simpletest things here as not relevant (not regarding mod label)
              Hide
              marina Marina Glancy added a comment -

              oh no, there are even more places where label is hardcoded. Reopening

              Show
              marina Marina Glancy added a comment - oh no, there are even more places where label is hardcoded. Reopening
              Hide
              marina Marina Glancy added a comment -

              Ok, I corrected almost all hardcoded 'label's that I've found.

              I have not used module_supports() rather cm_info::has_view()

              We should have better solution for reports but since the logging/reporting API will be redesigned I thought it is unreasonable to implement new callback for reporting purposes now.

              There is one know place where I did not remove hardcoded label:
              https://github.com/moodle/moodle/blob/master/course/format/renderer.php#L356
              because here no other module should be hidden

              Show
              marina Marina Glancy added a comment - Ok, I corrected almost all hardcoded 'label's that I've found. I have not used module_supports() rather cm_info::has_view() We should have better solution for reports but since the logging/reporting API will be redesigned I thought it is unreasonable to implement new callback for reporting purposes now. There is one know place where I did not remove hardcoded label: https://github.com/moodle/moodle/blob/master/course/format/renderer.php#L356 because here no other module should be hidden
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

              TIA and ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
              Hide
              samhemelryk Sam Hemelryk added a comment -

              Hi Marina,

              This is presently causing a couple of unit tests to fail.
              Somethings not quite right yet sorry.

              Many thanks
              Sam

              Show
              samhemelryk Sam Hemelryk added a comment - Hi Marina, This is presently causing a couple of unit tests to fail. Somethings not quite right yet sorry. Many thanks Sam
              Hide
              cibot CiBoT added a comment -

              Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.

              Show
              cibot CiBoT added a comment - Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.
              Hide
              cibot CiBoT added a comment -

              Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.

              Show
              cibot CiBoT added a comment - Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.
              Hide
              marina Marina Glancy added a comment -

              YES! After spending several days trying to find what broke the phpunit tests I found it! The filter_manager instance was cached. I have no idea why nobody else experienced those conflicts before and I was so lucky. Anyway, added a commit clearing the cached filter_manager instance

              Show
              marina Marina Glancy added a comment - YES! After spending several days trying to find what broke the phpunit tests I found it! The filter_manager instance was cached. I have no idea why nobody else experienced those conflicts before and I was so lucky. Anyway, added a commit clearing the cached filter_manager instance
              Hide
              damyon Damyon Wiese added a comment -

              The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

              Thanks!

              Show
              damyon Damyon Wiese added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. Thanks!
              Hide
              damyon Damyon Wiese added a comment -

              Thanks Marina - I like removing special cases from the code!

              I didn't spot any issues and the unit tests are passing.

              I have integrated this to master only (improvement).

              Show
              damyon Damyon Wiese added a comment - Thanks Marina - I like removing special cases from the code! I didn't spot any issues and the unit tests are passing. I have integrated this to master only (improvement).
              Hide
              dmonllao David Monllaó added a comment -

              It passes, tested in master

              Show
              dmonllao David Monllaó added a comment - It passes, tested in master
              Hide
              damyon Damyon Wiese added a comment -

              Thanks for your hard work - this issue has made it! Moodle is now a little bit better.

              Regards, Damyon

              Show
              damyon Damyon Wiese added a comment - Thanks for your hard work - this issue has made it! Moodle is now a little bit better. Regards, Damyon

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    14/May/13