Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Plan to Improve Flexibility of Question Category Sharing and Permissions: Difference between revisions

From MoodleDocs
Line 61: Line 61:
''Site Level''
''Site Level''


* Physics (shared)
* Physics


If a childs parent is gone then it get's put in the grandparent category, if no grandparent, then grand grand parent etc. We'll search up the category hierarchy till we reach a category that is still in the same context level or we reach the top level and use that as a parent.
If a childs parent is gone then it get's put in the grandparent category, if no grandparent, then grand grand parent etc. We'll search up the category hierarchy till we reach a category that is still in the same context level or we reach the top level and use that as a parent.

Revision as of 14:48, 21 March 2007

Status of this Plan

Working on the plan now and it is still under discussion. Please post comments here : forum discussion starting here with new heading 'Plan to Improve Flexibility of Question Category Sharing and Permissions'

Background

Commenting

I plan along the way before making changes to the question bank code to add plenty of commenting in the approved Moodle style and in line with this info on Quiz_developer_docs#Code_documentation. Will add ??? where I'm not sure of something and generally add as many inline and phpdoc comments to the code as seem useful. I think Moodle guideline suggest that there are never to many comments in code, I'll try to keep the comments succinct. This I hope along the way will be a good way for me to learn about how the code works myself and cement the concepts in my own mind.

Rest of Tasks in Plan Are In The Order I Intend to Tackle Them

Commenting will be something I'll do throughout my work as I delve into the code and add new code. The rest of tasks in my plan below are in roughly the order in which I intend to tackle them.

Before Branch Changes to HEAD

I propose to make these changes before I branch the question bank code to work on a development branch.

Convert the Current edit categories table to a UL

Will convert the current edit categories table to an UL. This will be one step towards the new interface with several headings and lists of categories below each context heading. I won't add the context headings at this stage just change the current table to a UL.

Remove the Question Bank Reliance on SESSION

Will work on removing the use of SESSION to keep track of what category should be displayed and pass category and other params from page to page as url params or as hidden fields for buttons.

After Branching

Make DB changes

Remove 'publish' field from question_categories table 'course' field will become 'contextid' and will be of INT type pointing to the 'context' table.

Calculate equivalent context

Contents of the new context table will depend on the old contents of 'publish' and 'course' if publish is 1 then we make the context the site context. If it is 0 then we make the context the context for the course indicated in the 'course' field.

Change in How Categories Are Shared

Previously you could share a category anywhere in your Course's question bank category hierarchy at the site level. Now we have decided that we'll have seperate hierarchies for categories at each context level. So we need code on db upgrade to check that all parent categories referred to in the question_categories 'parent' field are in the same context. If they are not then this category becomes a new top level category.

So if a question category hierarchy in a course is as below :

  • Default
    • Science
      • Physics (shared)
        • Momentum and Dynamics

The Physics course will get moved to the site context since it is shared and the question category hierarchies will then be as follows :

Course Level

  • Default
    • Science
      • Momentum and Dynamics

Site Level

  • Physics

If a childs parent is gone then it get's put in the grandparent category, if no grandparent, then grand grand parent etc. We'll search up the category hierarchy till we reach a category that is still in the same context level or we reach the top level and use that as a parent.

The problem here is that if there was a random question in category Science or Physics which had the 'Display questions from sub-categories too' turned on, then before or after the upgrade, it will behave differently. I don't know what the best solution to this is.Tim Hunt 07:49, 21 March 2007 (CDT)

Edit Categories Page

Add Headings to Edit Categories Page for Each Context Level

Will add headings to edit categories page and below each heading there will be a list of categories in that context. Edit Categories page will then have the structure as shown here

The contexts available depend on where you are editing the categories from. Thus in one course you only see that course's context, any parent course categories contexts and the site context. When in the site context you only see the site context.

Add Up / Down Action Buttons

These will work as discussed here - I like the first option and not the alternative I discuss.

Question Bank Page

  • New Question Category selection box with contexts as OPTGROUPS. Something like below. Only available categories are shown ie. only the parent contexts of the current context to which the user has usequestions capability.
  • Make sure indentation of category hierarchy works properly.
  • Add count of questions in brackets after each category.
Optgroup.gif

Question Adding / Editing Forms

  • New Question Category selection box with contexts as OPTGROUPS. Same as in Question bank page above.

Add code to cope with detecting and moving associated files

Need code to check for files in the current course / at the site level that need to be moved when a question is moved. Check for linked files in question text and other text course files and site files area using a regular expression. List associated files for user and allow user the choice to move files to the same context as the question.