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

Non object property access warning when changing question category name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0.6, 4.1.1
    • 3.11.10, 4.0.4, 4.0.5, 4.1
    • Questions, Quiz
    • MOODLE_311_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MDL-76026_401
    • Hide

      Steps for testing Questions > category names renaming:

      1. Login to a course
      2. Navigate to Question bank. Create a True/False question in a category (e.g., Category 1)
      3. Go to question categories and edit that category
      4. Rename the category to 'Category new'
      4. Save changes

      Expected result: The new category name should be saved without any errors.

      Verify that quiz with Random questions is working as expected.

      Steps for testing Quiz > Add a random question:

      1. Login to a course
      2. Turn editing mode on and create a quiz.
      3. Click on 'Add question' > add a random question
      4. Choose the above category 'Category new'
      5. Now navigate to Question>Categories and rename the category to 'Category new 1'
      6. Save changes

      Expected result: The new category name should be saved without any errors. Also, the quiz random question should now be displaying the catagory name as 'Category new 1'

      Show
      Steps for testing Questions > category names renaming: 1. Login to a course 2. Navigate to Question bank. Create a True/False question in a category (e.g., Category 1) 3. Go to question categories and edit that category 4. Rename the category to 'Category new' 4. Save changes Expected result: The new category name should be saved without any errors. Verify that quiz with Random questions is working as expected. Steps for testing Quiz > Add a random question: 1. Login to a course 2. Turn editing mode on and create a quiz. 3. Click on 'Add question' > add a random question 4. Choose the above category 'Category new' 5. Now navigate to Question>Categories and rename the category to 'Category new 1' 6. Save changes Expected result: The new category name should be saved without any errors. Also, the quiz random question should now be displaying the catagory name as 'Category new 1'

      1. Create a course "Course 1"
      2. Go to question bank and add a true/false question
      3. Go to question categories
      4. Edit the "Default for Course 1" category which contains the question
      5. Change the name to something new like "Default for Course 1 NEW"
      6. Save
      7. Notice the following:

      Notice:  Trying to get property 'id' of non-object in /home/xxx/moodledata/imaster/moodle/question/bank/managecategories/classes/question_category_object.php on line 487
      Notice:  Trying to get property 'id' of non-object in /home/xxx/moodledata/imaster/moodle/question/bank/managecategories/classes/question_category_object.php on line 490 

       

      This appears to be a regression caused by MDL-74427, which added a new method 

      get_real_question_ids_in_category() and updated existing code to use this method. The method returns array values (just ints) but we're accessing each result like it's an object:
      https://github.com/moodle/moodle/blob/0fcea11234a9d5016e7c55fa8e51621ac218a878/question/bank/managecategories/classes/question_category_object.php#L487-L490

      Another thing to perhaps note, is that we don't seem to get an entry in the question table for random questions added to a quiz in 4.0 and above (I'm not sure myself whether this is expected, so reporting here). The only way I was able to see a question record with qtype = 'random' was to:

      • Create a 311 site
      • Create a course
      • Create a question in the question bank
      • Create a quiz and add a random question
      • Upgrade the site to 400 (and the qtype='random' still exists)

      I'll leave it up to those with more knowledge of the question bank to comment on whether this is expected or not (and therefore whether the code dealing with renaming these random questions is still relevant).

            Anupama Sarjoshi Anupama Sarjoshi
            jaked Jake Dallimore
            Mahmoud Kassaei Mahmoud Kassaei
            Tim Hunt Tim Hunt
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 17 minutes
                1h 17m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.