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

Change the tag API to include the contextid and component when tagging an item.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.7
    • Component/s: Questions, Tags
    • Labels:
    • Testing Instructions:
      Hide
      Test 1
      1. Run "vendor/bin/phpunit tag/tests/taglib_test.php", "vendor/bin/phpunit lib/tests/questionlib_test.php" and "vendor/bin/phpunit course/tests/courselib_test.php" and ensure all passes.
      Test 2
      1. Install a new Moodle site and check that the 'tag_instance' table contains the columns 'component', 'contextid' and 'timecreated' with the following properties.

      'component' - Character field with a length of '100' null allowed.
      'contextid' - Integer field with a length of '10' null allowed.
      'timecreated' - Integer field with a length if '10' null NOT allowed.

      Test 3 (This test must be tested on ALL supported DBs)
      1. Create a Moodle site from the latest stable master branch.
      2. Visit <yoursite>/admin/settings.php?section=optionalsubsystems and ensure 'Enable tags functionality' is checked.
      3. Visit <yoursite>/admin/settings.php?section=blocksettingtags and ensure 'Show course tags' is checked.
      4. Tag a course, wiki page, blog, external blog, user (their interests) and question.
      5. Create a backup of the course you tagged.
      6. Upgrade the Moodle site to the latest integration master and check that the 'tag_instance' table contains the columns 'component', 'contextid' and 'timecreated' with the properties listed above.
      7. Check that the 'component' and 'context' have been populated correctly for the items you tagged.
      8. Restore the course backup and ensure it works and the tags still exist.
      Test 4
      1. Check that you can tag a course, wiki page, blog, external blog, user (their interests) and question on the latest integration master.
      2. Backup and restore a tagged course that contains a tagged wiki and a quiz using a tagged course question and check that it works and the tags remain.
      Test 5
      1. Create a course.
      2. Under 'Course administration' click on 'Question bank' then 'Questions'.
      3. Create a question in the default category for the course and add some tags.
      4. Check the 'tag_instance' table and ensure the correct contextid has been assigned (the contextid will be the context of the question category - you can see this in the question_categories table) for these tags.
      5. Select the question, from the drop down select default for the course but under the category heading, and then click 'Move to >>'.
      6. Check the 'tag_instance' table and ensure the correct contextid has been assigned for these tags.
      7. Click on 'Categories' under the 'Question bank' and move the category containing the question to another section using the arrows.
      8. Check the 'tag_instance' table and ensure the correct contextid has been assigned for these tags.
      9. Edit the question itself and move it to another category.
      10. Delete the question and ensure the 'tag_instance' records have been removed.
      Test 6
      1. Add tags to a wiki post.
      2. Delete the wiki activity.
      3. Check the tag_instances for the activity have been removed.
      Test 7
      1. Add some tags to wiki posts belonging to multiple wiki activities.
      2. Uninstall the wiki module.
      3. Check that all tag_instances for 'mod_wiki' have been removed.
      Show
      Test 1 Run "vendor/bin/phpunit tag/tests/taglib_test.php", "vendor/bin/phpunit lib/tests/questionlib_test.php" and "vendor/bin/phpunit course/tests/courselib_test.php" and ensure all passes. Test 2 Install a new Moodle site and check that the 'tag_instance' table contains the columns 'component', 'contextid' and 'timecreated' with the following properties. 'component' - Character field with a length of '100' null allowed. 'contextid' - Integer field with a length of '10' null allowed. 'timecreated' - Integer field with a length if '10' null NOT allowed. Test 3 (This test must be tested on ALL supported DBs) Create a Moodle site from the latest stable master branch. Visit <yoursite>/admin/settings.php?section=optionalsubsystems and ensure 'Enable tags functionality' is checked. Visit <yoursite>/admin/settings.php?section=blocksettingtags and ensure 'Show course tags' is checked. Tag a course, wiki page, blog, external blog, user (their interests) and question. Create a backup of the course you tagged. Upgrade the Moodle site to the latest integration master and check that the 'tag_instance' table contains the columns 'component', 'contextid' and 'timecreated' with the properties listed above. Check that the 'component' and 'context' have been populated correctly for the items you tagged. Restore the course backup and ensure it works and the tags still exist. Test 4 Check that you can tag a course, wiki page, blog, external blog, user (their interests) and question on the latest integration master. Backup and restore a tagged course that contains a tagged wiki and a quiz using a tagged course question and check that it works and the tags remain. Test 5 Create a course. Under 'Course administration' click on 'Question bank' then 'Questions'. Create a question in the default category for the course and add some tags. Check the 'tag_instance' table and ensure the correct contextid has been assigned (the contextid will be the context of the question category - you can see this in the question_categories table) for these tags. Select the question, from the drop down select default for the course but under the category heading, and then click 'Move to >>'. Check the 'tag_instance' table and ensure the correct contextid has been assigned for these tags. Click on 'Categories' under the 'Question bank' and move the category containing the question to another section using the arrows. Check the 'tag_instance' table and ensure the correct contextid has been assigned for these tags. Edit the question itself and move it to another category. Delete the question and ensure the 'tag_instance' records have been removed. Test 6 Add tags to a wiki post. Delete the wiki activity. Check the tag_instances for the activity have been removed. Test 7 Add some tags to wiki posts belonging to multiple wiki activities. Uninstall the wiki module. Check that all tag_instances for 'mod_wiki' have been removed.
    • Affected Branches:
      MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull Master Branch:
      MDL-44316_master
    • Story Points (Obsolete):
      40
    • Sprint:
      BACKEND Sprint 12

      Description

      We want to update the database table 'tag_instance' so that the contextid and component are stored. This will allow for easy deletion of tags when cleaning up particular areas of Moodle, it will also be consistent with other parts of the Moodle API - eg. the file area.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  2 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

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