Issue Details (XML | Word | Printable)

Key: MDL-17293
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Olli Savolainen
Reporter: Tim Hunt
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-17284

Problem in edit_single_category in question/category_class.php

Created: 19/Nov/08 03:38 PM   Updated: 23/Nov/08 01:32 AM
Return to search
Component/s: Questions
Affects Version/s: 2.0
Fix Version/s: 2.0

Participants: Olli Savolainen and Tim Hunt
Security Level: None
Resolved date: 23/Nov/08
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
The two lines

            $this->catform_rand->set_data($category);
            $this->catform_rand->display();

Should not be present. To see why, go to Question Bank management -> Categories tab -> Click on the edit icon next to a category.

You end up on a page with two forms, when only the top one should be present.


By the way, the purpose of the code

        if (1 == $DB->count_records_sql("SELECT count(*)
                                           FROM {question_categories} c1,
                                                {question_categories} c2
                                          WHERE c2.id = ?
                                            AND c1.contextid = c2.contextid", array($currentcat))){
            $mform->hardFreeze('parent');
        }

Well, the SQL is counting the number of other categories belonging to the same context as this one. If there is only one, then it is trying to stop you changing the parent (so you can't remove the default category from any context.) However, that should not apply when you are creating a new context. (That applies to the standard create category form too.) Can you either fix this, or create a new issues assigned to me.


        //TODO: Tim: is this questionable? to add a hidden field right from a get parameter?
        $mform->addElement('hidden', 'addonpage', optional_param("addonpage_form", 0, PARAM_SEQUENCE), 'id="rform_qpage"');

Yes, that is questionable. You should do the optional_param call on the page that loads the form, and pass the data in via the call to set_data. Hmm that is tricky, because the call to set_data is in the initialize method. It might be better to call set_data in display_randomquestion_user_interface(), and pass $addonpage as an argument to that.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Olli Savolainen committed 1 file to 'Moodle CVS' - 23/Nov/08 12:52 AM
quiz editing: MDL-17293 removed two lines of code that did nothing good but some bad, showing an extra form where it should have not been.
MODIFY question/category_class.php   Rev. 1.46    (+1 -3 lines)
Olli Savolainen committed 3 files to 'Moodle CVS' - 23/Nov/08 01:32 AM
quiz editing: MDL-17293 changed how the page number to add on is passed to the form for creating a random question
MODIFY question/category_class.php   Rev. 1.47    (+3 -3 lines)
MODIFY mod/quiz/addrandom.php   Rev. 1.2    (+3 -2 lines)
MODIFY question/category_form_randomquestion.php   Rev. 1.2    (+2 -3 lines)
Olli Savolainen committed 1 file to 'Moodle CVS' - 23/Nov/08 02:30 AM
quiz editing: MDL-17293 Added a default value to avoid error messages

Added a default value to the function that passes a page number to avoid error messages.
MODIFY question/category_class.php   Rev. 1.48    (+2 -2 lines)