Plan for the conversion of the question bank into an activity module

Plan for the conversion of the question bank into an activity module

by Jamie Pratt -
Number of replies: 106
As part of the project I'm working on 'Question Creation as A Student Activity' I'm interested in working on the conversion of the question bank into an activity module. See my plan for this in Moodle docs.

This will not be a complete rewrite of the question bank unfortunately as Petr suggests here http://moodle.org/mod/forum/discuss.php?d=51143#p235845 I propose to just repurpose the existing code with a new outer shell to work as an activity module and to allow for multiple question bank modules within one course.

As outlined in other posts to the forums making the question bank into an activity module seems to make a lot of sense - to have questions handled like other content within a course. So then the question modules can benefit from the activity module framework and won't have to rely on special case code for backup and restore, permissions, etc.

I expect the work converting the question bank won't take more than 4 weeks. I'd like to start as soon as possible. I'll also be available for bug squishing duties particularly related to the changes I've made.

Jamie


Average of ratings: -
In reply to Jamie Pratt

Re: Plan for the conversion of the question bank into an activity module

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Errr..... am I missing something? Did we not (in 1.6) expend a great deal of effort to *remove* the questionbank from the mod directory? Why are we now talking about putting it back? Is the questionbank "activity" not just a quiz?

I'm confused - even more than usual!!
In reply to Howard Miller

Re: Plan for the conversion of the question bank into an activity module

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The problem with being stuck out on a limb in a separate top level folder is that everything has be done as a special case. Backup and restore, roles and capabilities (well, at the moment, you can't really use roles to control access to the question bank, since it is not a context), etc.

1.6 took questions out of the quiz module. We are not undoing that.

The main issues with this plan are:

1. Lots of people want more flexibility for controlled sharing of question banks. Not currently possible. This change, plus the existing roles and capabilities, gives us a lot of that.

2. It introduces the concept of module instances depending on other modules instances (including ones from other courses because of published categories). That is, particular quizzes will depend on particular question banks. This is a new level of complication, but also, opens up lots of rich possibilities for the future.

3. MDL-6047: it is almost impossible to solve this the way Moodle is now. After Jamie's change, it gets easier.

4. It will be a pain having to support old backup format, as well as the new simpler one.

5. Moving all these files again will break CVS history again, so it will get even harder than it already is to understand how the code got like it is today.

Actually, to help with 5, I am hoping that this change will not require any changes to the question type or import/export format plugin APIs, or indeed, to anything in the question/type or question/format folders at all. Then, we could see if Martin could move those folders in the repository, like he did with the contrib reorganisation. Jamie, when you are developing, could you do something devious with symbolic rather than moving the files, until near then end of your work when it is time to merge?


Anyway, this is a big scary change. No argument there. And I really want second (and third and fourth ...) opinions from Martin D, Petr, Eloy, and so on.

But long term I think this change need to be made, and it would be better that it is done before Moodle 2.0. It is great that Jamie is volunteering to do it; and that he wants to do it right at the start of the Moodle 1.9 development cycle, so we have plenty of time to work the bugs out.
In reply to Jamie Pratt

Re: Plan for the conversion of the question bank into an activity module

by Gustav W Delius -
Hi Jamie, you say that "making the question bank into an activity module seems to make a lot of sense - to have questions handled like other content within a course". I disagree with the statement that activity modules are a way for teachers to handle course content. The activity modules are for providing activities to students. Activity modules are not meant to be a front-end for teachers to manage content. Content that is not specific to a single activity is handled outside of activity modules. Examples are provided by the file area and the grading scales.
In reply to Gustav W Delius

Re: Plan for the conversion of the question bank into an activity module

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
But lables, resources, scorms etc. are all modules. And glosary entries, images in an image gallery (database module preset) are stored in module instances too, although they may be teacher or student generated content.

It would be useful to be able to share content (e.g. a particular web page) between courses without always having to copy stuff. Metacourses let you do quite a lot, but they have their limits.

Also, I think it would improve Moodle if images were stored in an image gallery, instead of course files, and there was a slick interface for managing these images as images, not just as files, and including them in text edited by the HTML editor, etc.

The big win is that a module instance is a context, in the sense of the Moodle roles system. So you can have quite a lot of flexibility when controlling who can do what with stuff in a module. And lots of people want to be able to manage their question banks more flexibly. (Without bugs like the one I mentioned above.)
In reply to Tim Hunt

Re: Plan for the conversion of the question bank into an activity module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
All files will be in the repository, accessed via the repository API, so those content problems you mention will go away ..
In reply to Martin Dougiamas

Re: Plan for the conversion of the question bank into an activity module

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Right, so tell us more. This is the key issue we are trying to solve, and at the moment I think making the question bank a module is the best way to solve it. But I am quite happy to be given a better way.

How exactly will the repository work? I does the key thing we want - give administrators more control over who can do what with stuff - only for us, stuff is quiz questions not files.

Now to use this extra flexibility for files, users are going to have to get their heads round a few new concepts, and a few new bits of iterface.

It would be best if we used the same concepts and the same sort of interface for managing sharing questions in the question bank.

So, I'll finish where I started, tell us more ...


(I suppose that, as well as content in respositories and questions in question banks, for Moodle 1.9 there will also be outcomes. That's another thing that people will invest a lot of time creating, and will then want to share between courses in a fairly flexible way. So that is another reason for finding the right solution to this problem now.)
In reply to Jamie Pratt

Re: Plan for the conversion of the question bank into an activity module

by Rick Barnes -
From a teaching point of view, I currently use one of the word or open office templates for pupils to create questions (and format them) on a topic before collecting them in an assignment, merging them together and then publishing a revision quiz based on aa selection of the best questions.
This means a reasonable amount of work for me but not as much as If I tried to create the questions myself.
I haven't tried this with the new V09 xml export template which allows you to include images.
I would love this process to be all in moodle pupils seem to take to new processes without much prompting when it is web based, but using new skills in word or open office needs a little more introduction.

It sounds like the process could be;
Teacher sets task, no of questions, topic etc
Pupils create and submit their questions to the question bank.
Teacher selects the questions they want to use (may be even choose to give credit to the authors, with the question or in a summary at the end of the quiz, questions submited by.....).
Pupils have the completed quiz made available to them.

By viewing and answering the questions they would/could learn a lot about the quality of the questions that they submitted. They could even have a way to give feedback about the questions to the authors.

Rick.

In reply to Rick Barnes

Re: Plan for the conversion of the question bank into an activity module

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Rick,

I am very interested in the possibility for students to author their own questions and quizzes in Moodle. I am especially thinking of my language teaching students at an advanced level, who need to practise their authoring skills. Up to now I've used Hot Potatoes for that, but I would be interested in using Moodle's own quiz as well.

As I have already explained at length here, I am not interested in using quizzes for testing, but for learning purposes. In that perspective, I am a little disconcerted by your approach which seems to consider a quiz as a hapazard collection of questions.mixed For me, a quiz is certainly not a random collection of questions, but a well-constructed set of questions, of varied types, usually graded (starting with easier questions and finishing with harder ones), etc. This is why I would never ever use the "random questions" facility in Moodle quiz building. I have no use either for a "question bank" or for publishing questions. In my practise, any particular question can only belong to one quiz. I consider it equally important to teach my (language teaching) students how to build a quiz as to teach them how to create individual questions.

Of course, I do appreciate that there are completely different teaching/learning situations, where a large question bank of hundreds or thousands of questions from which a certain number can be randomly selected to build a testing quiz is needed. But this is not my situation.

Joseph

In reply to Joseph Rézeau

Re: Plan for the conversion of the question bank into an activity module

by Rick Barnes -
We don't really have the time to go into details of quiz creation with the pupil, but we find that explaining the different types of questions and their uses and then asking pupils to create questions helps them to process the information that they have learnt.

The quizzes created in this way are not used as teacher assessment tools, but for the pupils to identify weak areas as part of their revision. The large number of questions can be used with the random function so that the revison quizzes can be used more than once by pupils without them just trying to learn the answers to the questions, but hopefully learning about the topic so they can atempt to answer any question. My younger pupils think that they are doing well when they can get 100% but still can't answer a new question on a topic (have they learned anything apart from the answers to the questions)

I agree about using quizzes for assessment, planing a series of questions that cover the whole bredth of a topic and generally that become more difficult as the quiz progresses would be my choice. In this way I hope when I have time to be able to create quizzes that can replace our more traditional, paper based mock exams and that will then be able to significantly reduce the marking required. Because of the layout of computer rooms I would love to be able to break quizzes into sections, and rendomise the questions in a section so that the exam dificulty can still increase as you progress but so that pupils sitting next to each other would br unlikely to start on the same question. (If I tried this now I would have to randomise the whole quiz, ruining my planning, or plan a series of quizzes of increasing dificulty and then collate the results)

We haven't yet made any use of the lesson module but now we have upgraded to 1.7 and can colapse the lesson to speed up editing we will have to look into lessons, then maybe we can use quizzes more for assessment than learning, and use the questions in the lessons to prompt pupils to learn. I need to learn much more about how lessons work to find the best way forward here.

Rick.
In reply to Rick Barnes

Re: let student create qustions

by Ger Tielemans -

Why not make a student-quiz-template for the glossary?

Combine this with a NEW quizplayer for such glossary-format-quiz, activated witha button in the instance of that local glossary?  

And create a xml-transport-script to move the final glossary set to the real question-repository? 

In reply to Jamie Pratt

Re: Plan for the conversion of the question bank into an activity module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Is it not possible to ADD this as an alternative, rather than thinking of it as a conversion?

I agree with Gustav that putting something like this in as a activity ONLY does not fit with the Moodle interface.

I'm very very strongly against questions using/abusing the mod structure this way, not to mention making modules dependent on other modules. It's very much against the whole design philosophy. I don't mind that it's a special case right now. I'm sure there are other ways to fix that and give it a contexts and backups that make good sense.

However, I totally would love to let students in to work on them, and for that purpose it does make sense to have a question-editing activity that operates on the central questions database, for those who want that.
In reply to Martin Dougiamas

Re: Plan for the conversion of the question bank into an activity module

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Again, I was under the impression that one of the main reasons for pulling the question banks out of modules so that new modules could easily use them.

Would it not be easier to write a new module that permitted students to build tests?

Having said that, something we get asked for every so often is for students to be able to build *any* content themselves in a controlled way so this may be a more general thing. Imagine, if you will, a Moodle course on how to build Moodle courses.

In reply to Howard Miller

Re: Plan for the conversion of the question bank into an activity module

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
No, that was the reason for taking the questions out of the quiz module. It does not say where it is best for them to go.

There is already a module that lets people build quizzes (and with Roles, people can be students) it's called the quiz module!
In reply to Tim Hunt

Re: Plan for the conversion of the question bank into an activity module

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ok..... I'm confused or being stupid or both.

So if using roles students can build quizzes, what does Jamie want to do that is different to that - words of one syllable please??
In reply to Howard Miller

Re: Plan for the conversion of the question bank into an activity module

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
He wants students to be able to create questions too.

And when students create questions, he wants the stored somewhere separate, so that the do not get mixes up with teacher-created questions.
In reply to Tim Hunt

Re: Plan for the conversion of the question bank into an activity module

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
And it takes a complete re-jig of the question code to do that?

I'm probably sounding horribly negative about Jamie's plans - I'm not trying to be, I just don't geddit at the moment.
In reply to Howard Miller

Re: Plan for the conversion of the question bank into an activity module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
No it doesn't take a complete conversion.

But it will require some extending of the questions to understand the new contexts, and some GUI features to make it clear who created what questions and who they are for (the whole site, a course, a specific activity etc)

Tim explained things well just earlier today.
In reply to Tim Hunt

Re: Plan for the conversion of the question bank into an activity module

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Here are some thoughts, questions, suggestions, etc. that came to mind as I read this thread. I like the idea of allowing students to work at building question banks and feel that it fits well Moodle's constructivist pedagogy.

One step toward getting student questions might be to add a creatorid field to the mdl_question table that would store the mdl_user id of the user who wrote the question. Another issue that comes up is how would we want to handle student written questions.
  1. Should students be able to see the questions written by other students? (I would think so).
  2. Should students be able to edit or delete the questions written by other students? (Possibly) If so, then perhaps we would need another field in mdl_question for modifierid and probably a last modified timestamp.
  3. Would the goal be to allow some type of rating system similar to the forums that a well written question could get a higher rating from either the teacher or other students than a poorly written one?
  4. Would an option for some type of approval system similar to the database module be helpful whereby a teacher would have to approve the question before other students could see the question or use it some other setting (for example, creating a quiz)?
I agree that it is best to keep questions where they are (and not move them back to mod). Every module should be able to make use of questions. I am excited about the repository api development. Keep up the great work, I like where this is going!
In reply to Anthony Borrow

Re: Plan for the conversion of the question bank into an activity module

by Rick Barnes -
The proces could get a little complicated, would you build it all into the quiz creation module or use discussions to rate questions and provide peer feedback, (of course you could run the process in a workshop as it has the same sort of stages) I prefer each pupil to be be able to move forward independently rather than the workshops that I used in 1.5 that had set time frames.

I would go for the more complicated to set up integrated approach, as asking pupils to create questions, look at questions, go toa forum to discuss and rate, then go back to improve questions before publishing a quiz as an individual or group would be quite complicated.

1/2. Yes, but maybe not until they have submitted their questions and started on the rating/review process (this could involve creating a quiz that students can answer, rate questions or give feedback or both). After this if they go back and change questions it will be in response to feedback not just copying quesions so that they dont't have to write their own.
2. An option for individuals to revise their questions and An option for the group to select from all of the questions to create a final quiz, rateher than deleting questions (maybe the option to post this new quiz for other groups, after teacher aproval, again this may also require other groups to have submitted their questions for review before the new quiz is available to them to prevent copying)
In reply to Anthony Borrow

Re: Plan for the conversion of the question bank into an activity module

by Julian Ridden -
Some good points:
1. Should be an option when creating the activity. Think of the glossary options. (Can student create entries, must they need to be approved). This way teachers can customise to their specific needs.

2. Not sure on students deleting other students efforts. mixed I have enough issues with wikis as it is.

3. undecided. Not sure on the relevance of ratings when designing questions. Students would be designing questions as part of an activity would they not? The success of the question therefore comes from the quality of the response smile

4. See my remarks in 1 wink
In reply to Anthony Borrow

Re: Plan for the conversion of the question bank into an activity module

by Peter Ruthven-Stuart -
Picture of Plugin developers
Anthony,

Thank you for your thoughts, questions and suggestions. The details of my ideas re student Question making (The SelfStudy Project), which in part initiated this conversion of the question bank, are described here and here. Essentially, I envisage three phases of the development:
  • Phase 1: allow students to make questions, allow teachers to grade and import these questions into quizzes
  • Phase 2: allow students to create their own quizzes sing their own, peer created and teacher created questions
  • Phase 3: allow both teachers and students to generate on-the-fly quizzes
Up until now, this discussion has been about phase 1, and I can see that due to the complexity of converting the question bank to an activity module, it will be a while before work begins on phases 2 and 3. That said, from what I understand of this discussion, it seems that the changes now being considered will make it easier to realize phases 2 and 3.

So, to answer your questions:

1. Should students be able to see the questions written by other students? (I would think so).

Yes, For Phase 1, it would be good if students could be allowed to share their own questions with their peers. Also, for Phase 2 it would be essential for students to be able to use, and therefore see, other students' questions when they make their own quizzes.

2. Should students be able to edit or delete the questions written by other students? (Possibly) If so, then perhaps we would need another field in mdl_question for modifierid and probably a last modified timestamp.

Students should be able to edit questions written by other students, and when saving the edited question, the default should be 'saving as a new question'. Deletion of questions should only be possible if there is a feature in the question making activity that allows students to work in groups - e.g. a group of 4 students work collaboratively on question creation and they all get the same grade for their efforts - as in the new Project Module.

3. Would the goal be to allow some type of rating system similar to the forums that a well written question could get a higher rating from either the teacher or other students than a poorly written one?

Yes. My hope is that question creation can be graded in two ways:
  • automatically: i.e. if a student is required to make 5 multi-choice questions and they make 5 (regardless of quality) then this fact should be automatically recorded to the gradebook.
  • manually: teachers can assign grades for quality - again this score is recorded to the gradebook. Also, it should be possible for teachers to write feedback and require students to re-write questions. Ideally, I'd also like to see the possibility for peer evaluation of questions.
4. Would an option for some type of approval system similar to the database module be helpful whereby a teacher would have to approve the question before other students could see the question or use it some other setting (for example, creating a quiz)?

Hopefully, the grading system described above would make an approval system possible. For example, the teacher could indicate that only those questions that get more than a certain score ('an approval threshold') would be automatically available to other students to be edited and or used in quizzes. Furthermore, this approval system will assist in Phase 3: only those questions that had broken the 'approval threshold' could be used in on the fly quizzes.

Thanks again for your questions.
In reply to Howard Miller

Re: Plan for the conversion of the question bank into an activity module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yeah, ideally all questions everywhere would be in this database, even Choice, say, or Survey.

That's why I think it belongs in the core and not in module.
In reply to Martin Dougiamas

Re: Plan for the conversion of the question bank into an activity module

by Julian Ridden -
Totaly agreed.

Sharing these questions between similar modules (feedback, choice, etc) will also remove some current overlaps.
In reply to Martin Dougiamas

Re: Plan for the conversion of the question bank into an activity module

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Martin,

do you know something about the plans to use the question bank in lessons?
In reply to Ralf Hilgenstock

Re: Plan for the conversion of the question bank into an activity module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I remember we talked about it and everyone liked the idea but I don't know where it's at, sorry. You'd need to ask that in the forum for the Lesson module.
In reply to Martin Dougiamas

Re: Plan for the conversion of the question bank into an activity module

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Martin, I made the post here because the developements should be coordinated. Ralf
In reply to Ralf Hilgenstock

Re: Plan for the conversion of the question bank into an activity module

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
No, actually, the two bits of development are quite independant.

This thread is about making the facilities for managing questions within the existing question bank more flexible. That hardly affects the questions themselves.

Converting the lesson to use the global question bank is a separate piece of work with two parts: 1. change the lesson module, and 2. fix the places where the libraries implicitly assumes that the questions are only used in quizzes.

2. will happen the first time another module starts using the question bank. There are not many quiz dependancies left. There are a few known ones that are marked with TODO comments in the code, but no one has had the time or incentive to fix them. The first time anyone writes another question-using module for real, we will probably find a few more, and have to fix them all. Anyway, the lesson may not be first module in this situation, since Jamie and a colleague plan to write such a module.

1. will happen when Mark Nielsen (lesson maintianer), or someone else, has time to work on it. However, I think he is involved in other Moodle-related projects at the moment.
In reply to Tim Hunt

Re: Plan for the conversion of the question bank into an activity module

by Mark Nielsen -
1. will happen when Mark Nielsen (lesson maintianer), or someone else, has time to work on it. However, I think he is involved in other Moodle-related projects at the moment.

My free time is at a minimum right now due to other projects.

If anyone is interested, I have attempted to document to lesson to question bank conversion here: http://docs.moodle.org/en/Development:Adding_question_types_to_lesson

At the moment, the page has the target version set to Moodle 2.0, but there are NO plans to ensure that this is met.

This switch needs to happen because the lesson question code is very outdated and has arrested the development of the module. I'm willing to work with someone to help move this along. Anyone interested? I know Tim is willing to help with the question bank specific updates.

If no one steps up, then I'll just casually code it and it will be done when it's done wink

Cheers,
Mark
In reply to Martin Dougiamas

Re: Plan for the conversion of the question bank into an activity module

by Jamie Pratt -
The 'student question creation activity module' will certainly be a seperate module. I imagine it interfacing to the question bank in a similar way to the quiz module.
In reply to Jamie Pratt

Re: Plan for the conversion of the question bank into an activity module

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
....and it is so different from the existing quiz module that it needs to be a whole new module? Will they not have loads of code in common?
In reply to Howard Miller

Re: Plan for the conversion of the question bank into an activity module

by Jamie Pratt -
Yes. I think this should be a new module. This module is for the graded creation of questions (not quizzes). I just posted an updated version of the specification of this module here. Actually I was thinking it might be an assignment type plug in but I've not looked into the benefits / limitations of that yet.

Peter plans to commission a Student Created Quiz Module as well at some point. Peter outlines his plan here.
In reply to Jamie Pratt

want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
My incentive for volunteering to work on this project are simply to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course that might be used for quizzes or that a teacher doesn't want accessible.

We could achieve this by having the ability to have several question banks in one course and thus having the flexibility to control permissions for each question bank. But there are many other ways this could be achieved. In discussion and in my research, the concensus seemed to be that the future for the question bank would be to turn it into an activity module. See posts here and here for example. This made some sense to me. But I'm flexible. I'd be willing to help with work on the question bank in order to improve it's flexibility, and so I can meet the goals of my project.

I look forward to an interesting discussion on people's views of how the Moodle architecture should evolve and us arriving at some agreement on the future of the question bank in order that we can move forward with development.

Jamie


In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Could this not be achieved relatively simply by enhancing the "permissions" on question categories? There are probably other things that this would fix anyway (e.g., you can share my questions but you cannot copy them, only share in particular categories/courses).
In reply to Howard Miller

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
We could achieve enhancement of permissions in a number of ways. I went with this way because it seemed to fit in with others' vision for the question bank and might help to solve other problems in the question bank.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I was just discussing this with Martin on Skype, during which we came up with an alternative option. Since I only just thought of this, we are not sure whether it actually solves all the problems, but let me describe it and you can all see what you think.



Just to recap, the problem we really want to solve are:

1. More flexible sharing options, so you can share questions between all the courses in a category, in addition to sharing with all the courses in a site and no sharing which you can do now.

2. Ability to have separate areas to store different types of question in a course, so they don't get mixed up with teacher-created questions. For example, student created questions, or questions specially made for the end of course exam, that only a few people are allowed to see.

3. A solution to bugs like MDL-6047 that are almost impossible to solve with the way that question sharing works now.

4. At the moment, there is one question bank per courses. To to check for access, you check capabilities at the course level, so the capability is associated with the course, not the question bank.



And the idea is this: At the moment, in the database, we have a link

mdl_question_categories -> mdl_course

and we change this to

mdl_question_categories -> mdl_context

(at least for module, course, coursecategory and site level contexts). Then, when you are editing a particular activity (e.g. quiz), you see all the questions from that context, and all parent contexts for which you have the moodle/question:usequestions capability (that is a new capability).

Module and course level questions can refer to resources in the course files area or the site files area. category and site level questions can only refer to the site files area.

By default, questions would be created in the course-level question bank (like now). It would be in cases like the ones mentioned in 2. that you would use module-level question bank.

To allow the sharing in 1., there would be a nice interface for moving questions from level to level.

If you moved a question that referred to course files up to category or site level, you would get a page that lists those resources, and offers you the chance to copy them to site files, or cancel. That deals with 3.

For 4. Capabilities would still be associated with a course or a module, not the question bank itself, but it is no longer hard-coded that that is course level.

Question banks would be backed up exactly when the corresponding thing is backed up. So when you backup a course, you get the course, category and site banks. And the banks for the activity modules you chose include in the backup that have their own banks.

On restore, we would keep the existing code that only restores what is necessary, and does not create duplicates, by using globally unique ids on categories and questions.



Now, does that actually work? what have we overlooked?

In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Pierre Pichet -

I agree that using roles to limit access to questions category do preserve the actual structure of Moodle and give the wanted property. Students can create their questions and at the upper level the teacher ( assistant-teacher etc) can access them to evaluate.

There are technical problems of how to do it correctly for example in Moodle installation with a large number of students.

We should have a closer look of the actual convention on using the question->parent parameter as a way to "delete" old questions.

And adding a "copy question to category" function will facilitate sharing them although it could also facilitate plagiarism...unless we can trace back the author(s) ( anoher parameter?). 

How about the import and export functions? The roles should give access to the student level under the control of the course teacher...

Pierre

Tim , thanks to have put a post in quiz forum on this discussion.

In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Tim - This sounds wonderful to me. I am a little confused about how a question written for quiz could be used in a lesson. I understand that the idea would be to bump it up a context level from quiz to course; however, I think this is the trickiest part of what you have described. Would you change the context or duplicate the questions and have one set in quiz and another linked to the course context. I suspect you mean to change the context. My next concern then would be moving down a context. I have some questions that I wrote at the course context level and then want to move them to the quiz context level; however, I have already used some of those questions in a lesson. How would that scenario be handled? Again, do we duplicate the questions (not desirable IMO), disallow the move and indicate that other modules are using the questions? I think the flexibility and power of what you have proposed is exciting but it may take a while to get users to understand this whole business of context levels (I am still trying to understand it myself). Peace.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I like this idea very much! You seem to have a special talent for analysing these kind of problems Tim! Some of my first thoughts below.

So the current shared questions would become questions which are available to people who have the 'usequestions' capability at site level. We can get rid of the shared field in the question_categories table. The current non-shared questions would be available to people who have the 'usequestions' capability at the course level. And we can set up categories that users have special permissions to when accessed from a particuar module in a course.

I'm not really clear on what the 'usequestions' permission would cover and when the current 'managequestions' would apply. What do you think about adding more permissions such as :
  • read all questions
  • create own question permission
  • edit own question permission
  • delete own question permission.
  • edit others question permission
  • delete others question permission.
And also adding a createdby and possibly lastmodifiedby field pointing to a userid to the question table? And 'created' and 'lastmodified' with a time stamp?



In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
More of my thoughts trying to understand fully this idea.

For the interface for moving questions between levels then we might just have some top level items in the Category drop down box in the question creation form. What do you think? There would be a :

  • site option (represented by the short name of the site) and a category hierarchy under that of categories that are available at the site level (old shared questions).
  • And several 'coursecategory' top level options (represented by the course category name??) and question category hierarchies under them. Since course categories are also hierachical questions will be shared at several levels. Eg. there might be shared questions at the Humanities level and then further shared questions in the course sub categories English or French accessible by courses in those categories. And more levels at which to share questions depending on the Course Category structure you've set up.
  • Then there would be a hierarchy of categories under the course that the module is included in.
What options for saving questions appear on the question creation drop down would depend on your permissions for usequestions at the different context levels.






In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
And in a similar way we could unify the interface for moving categories of questions about. The different contexts would be top level options on the 'Edit Categories' page, in the drop down boxes to select a 'Parent' category.

This might be a bit much to try to do right now but I wonder if there is a nice bit of javascript code out there that we could use to make this into a drag and drop interface with expanding folders and that we could also use for moving questions about. Anyone got any pointers to something that looks like it might do this and fallback nicely to an alternative interface for those without js.


In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
Just some ideas.

The YUI tree widget looks great. But I wonder if we can get it to fallback to some non js alternative. I guess it would be possible for a js guru to get drag and drop working for this widget and to communicate moved categories to Moodle with ajax. And I guess we could fall back to the present category editing interface if the user has selected that they don't want to use ajax and js features in their user profile.

Edit : Ah but moving a question category will also involve asking the users if they want to move associated files as Tim outlined above. This would be tricky to do nicely in this kind of ajax interface.


In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You have done a good job of identifying the details that need to be considered. smile

We definitely want to track who last edited each question.

Yes, we get rid of the shared field in the question_categories table.

Certainly we need to think about what capabilities are needed, starting from the ones already defined in lib/db/access.php. Also, thing about how to incorporate groups, and that we can now tell whether you were the person who created the question. So we should also look at how capabilities work in the database module for ideas.

We also need to think about the things different modules might want to do with questions. usequestions was for controlling whether people could add questions to a quiz (or other activity) at the questionbank end. At the moment this is just policed at the quiz end via mod/quiz:managequestions. We now need to check both that the person is allowed to do whatever it is a the module end, but also that they are allowed to access questions from this question bank.

I think we can do a lot of this without necessarily changing the interface much. There is plenty of scope for improving the interface, but that could be a separate step. And you can do drag and drop without doing Ajax. Just, when they drop, trigger a form submission instead of doing something hidden behind the scenes. The you either redirect to a warning-are-you-sure page, or back to the same page, as necessary. We have the YUI library to work with.

I would still like to see considered opinions on this from key people before we plunge in. Do you have the time to make a page like http://docs.moodle.org/en/Development:Plan_to_Convert_question_bank_to_activity_module, but for the new plan, detailing what would need to be done to implement it?


In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I can write up a new development plan in the next few days.
In reply to Jamie Pratt

Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
Well. I'm working on my plan for how to develope this and thought I'd post some thoughts along the way.

I was thinking about how to do add to the current question UI to add information about how questions in categories will be shared.

I found on the internet the following link about how to add images into select controls. Our JIRA bug tracker does this and I found a nice page about how this is done here

Thought that something like this might be a good way to add an indication of how each category will be shared. But now writing about it I'm not sure that this is such a good idea, what images would we use, we could use an image for :
  • module level --the module icon?? icon.gif
  • course level --not sure what we would use for this
  • course category level -- the course.gif
And then we would include the name of the category or course as well that the questions are shared in.

The course category icon seems to be the same as the course icon.

Maybe it would work. We would also need a way to have this be accessible as well.



In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That is really cool. I can't beleive that I have been using JIRA all this time, and I had not noticed that it is doing something quite clever in HTML. But that is the hallmark of a good UI. It is so easy to use you don't even think about how it works.

But I am not sure that icons will solve this problem. Perhaps the clearest way is to have two linked dropdowns. The first that lets you choose which question bank:

Choose questions from the [Site: My moodle/Category: My courses/Course: CF101/Quiz: My test] question bank.

Show show questions from category [Existing category dropdown]

I don't think either of those menus would benefit from icons. Perhaps the first one would.

In the first one, we should only show the ones the user is allowed access too.

Perhaps it would be confusing to teachers if they had different permissions on different question banks, if the number of tabs at the top of the screen kept changing. Perhaps it would be clearer to change the code so that always shows the same tabs, but when you can't do something like import, export or edit categories, it dsables the tab and adds a tool tip to it saing something like 'you don't have permission to export questions from this question bank.'

There are other dropdowns in Moodle where it would be really good to use icons. For example, the create new question dropdown, and the add activity dropdown when editing courses.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
Yes. I had not noticed that the JIRA tracker was doing something special. I searched on google for 'images in select html' and it came up with that page.

Your reply relates to another design decision I was thinking about. We should decide if we want the category permissions :

  • to work as the 'shared category' thing works now. Ie in one course you can choose categories from any part of your category hierarchy to share. Now we are talking about sharing them at the Course Category and Module Level as well as the present options of the Course Level and the Site Level. If a category's parent category is not available to use in the current context then the category will appear as if it is at the top level of the hierarchy.
  • to work as you suggest in your post. To have effectively completely seperate hierarchies of categories for each shared area. Simpler but less flexible. The UI could work as you suggest or could be done with one select box with top level options for each context in which questions are shared.
The icons would be useful for the first situation to indicate in which context a category is shared in the drop down box.

Then when that item is select we could also have a text message about the sharing context of this category, so although users using a screen reader would miss the extra info in the select box they would however still have the info about the sharing context of categories available.

I attach a screen shot showing possible changes to the question bank UI for the first case above. Note that I also suggest getting rid of the edit categories button since the category editing page can be reached through the tabs above so the button is redundant and we may need the extra screen space for long Course Category / Question Category names.

Attachment qb.gif
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I definitely prefer the second option.

Allowing sharing of categories was a mistake. I think it is quite a complicated model for users to understand, while at the same time, not giving the level flexibility that users want. Also, it makes the code more complicated, and leads to difficult bugs, like the images in shared questions one. And what if you add a random question from a shared category where some, but not all of the child categories is not shared? I think that this might incorrectly let other courses use non-shared questions.

I think that a site-level, as well as a course-level question bank is much easier to understand. And is going to be much easier to implement without bugs.

Certainly, in the UI, we need an interface for moving categories into the site-wide question bank, as well as individual questions. Actually, the manage-categories page, where things are lest cramped than the manage questions page, is a good place to make it clear to users what their mental model for understanding the question bank should be.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
Upon reflection I think you're right that the first option is more complex from a usability viewpoint and I hadn't thought of the possible complications in the code. And I can't think of any real advantages to the more complex first option so I'll go with the second option as you suggest.

This I think will also make the UI easier. We will do everything in the existing select box that is used for categories. We can have on the question bank page optgroups for all available contexts - these will be effectively toplevel unselectable options. Then we would have the category hierarchies for each context displayed below each context optiongroup. Something like below :



Default dfgdfg fgdfgd fdgdfg Default dfgdfg fgdfgd fdgdfg Default dfgdfg fgdfgd fdgdfg

edit : not displayed because moodle won't let me use the select and optgroup html tags in my post.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
The optgroups stuff could be done with html something like this :

<select id="catmenu_jump" name="jump">
<optgroup label="Site">
<option value="edit.php?courseid=2&cat=1">Default</option>
<option value="edit.php?courseid=2&cat=2" selected="selected"> dfgdfg</option>
<option value="edit.php?courseid=2&cat=3"> fgdfgd</option>
<option value="edit.php?courseid=2&cat=4"> fdgdfg</option>
</optgroup>
<optgroup label="Course Category 1">

<option value="edit.php?courseid=2&cat=4"> fdgdfg</option>
</optgroup><optgroup label="Course Category 2">
<option value="edit.php?courseid=2&cat=1">Default</option>
<option value="edit.php?courseid=2&cat=2" selected="selected"> dfgdfg</option>
<option value="edit.php?courseid=2&cat=3"> fgdfgd</option>
<option value="edit.php?courseid=2&cat=4"> fdgdfg</option>
</optgroup>
<optgroup label="CF101">
<option value="edit.php?courseid=2&cat=1">Default</option>
<option value="edit.php?courseid=2&cat=4"> fdgdfg</option>
</optgroup>

<optgroup label="Module name 1">
<option value="edit.php?courseid=2&cat=3"> fgdfgd</option>
<option value="edit.php?courseid=2&cat=4"> fdgdfg</option>
</optgroup>
</select>

And would look as the attached gif.
Attachment optgroup.gif
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
This would have the advantage of allowing a view of all available categories at once instead of using the two select box system which would only show you one context's category hierarchy at once.

The category hierarchy in the attached image is not being indented for some reason but I'm sure this can be fixed.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes, but I would put the more specific ones - the module and course ones at the top. That is, reverse the order of the optgroups.

Also, have you thought about what happens on a site where they develop a huge global question bank? The drop-down would get very unwieldy.

The dropdown is OK for now - it is a bit better that we have already. However, longer term we should look at the cool widgets available in YUI (as long as they are accessible).

I assume it will only show people the categories they have access to. Perhaps we should add the number of questions in brackets after the category name?
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
Yes, but I would put the more specific ones - the module and course ones at the top. That is, reverse the order of the optgroups.

Yes. You are right that would be better.


Also, have you thought about what happens on a site where they develop a huge global question bank? The drop-down would get very unwieldy.

The dropdown is OK for now - it is a bit better that we have already. However, longer term we should look at the cool widgets available in YUI (as long as they are accessible).

The drop down will work for upto around a hundred options I guess. That is a hundred categories available from any one context. It would be nice to use YUI widgets as you say but for now I think it is enough to support these.


I assume it will only show people the categories they have access to.

Yes, the categories they have access to from their current context for the question bank.

Perhaps we should add the number of questions in brackets after the category name?

Nice idea again. Thanks.

In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
This was the part I missed earlier this morning - I had read the code but the image was blocked by our firewall. Now that I see it looks good and makes sense.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
From my perspective, one of the points of being able to share questions is to share them with other folks in my department. In addition to the site-level and course-level, would there also be room in this scheme for a course-category level?
In reply to Anthony Borrow

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you read all the above thread, you will see that is already in the plan.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Thanks Tim - I had read it, I just wanted to make sure it wasn't getting dropped and that it was still part of the plan. Peace.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Pham Giai Khoi -
Hi Jamie,
Your post is helpful for me. Thanks for sharing.
I am working for Ngan hang
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
This is how I imagined the category editor might look for the first category sharing case.
Attachment categoryeditor.gif
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think the interface I would like to see is:

Questions specific to this activity

None.

{Add new category}

Questions for this course (S101)

  • Default (0) the default category for questions [edit] [delete] [up] [down]
    • General knowledge (5) [edit] [delete] [up] [down]
  • Science (42) [edit] [delete] [up] [down]
    • Physics (7) [edit] [delete] [up] [down]
    • Chemistry (11) elementary level chemistry questions [edit] [delete] [up] [down]
{Add new category}

Questions for Science courses

[Another list]

Questions from the global question bank

  • Study skills (100)
    • Using library databases (10)
    • etc.
That is, I think lists might be better than tables for this. Use standard moodle editing icons where I have shown alt text. Only show editing controls on question banks where they person can edit. Category names are links to the questions screen for that category.

As well as the up-down arrows (which also need to cope with parent-child relationships), allow categories to be moved by drag and drop. Categories can also be moved from the create/edit category screen (which I think should be separate, not at the top of this page), where there is a dropdown, like now.

At the moment, a lot of the question bank pages rather evilly use the session to track which category to display, whether to include subcategories, etc. as you switch tabs. This makes it impossible to work in two browser windows at once. It would be much better to keep these options in the URL. I don't know if you can fix that while you are working on the code.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
Yes that looks great. I like the look of these nested lists. This looks like a good plan for revision of the categories editing page. I had been thinking along the same lines as you to have the seperate headings but I was thinking of justing using the existing tables underneath. I think nested lists look a lot better though and with some clever css they might even be turned into a tree of folders or something??

What do you think - we could also have a link / button appear after the Category Name, description, action links called 'Add Child Category' to send the user to the add a category page with a param indicating the parent category.

Not sure I'll have the time to do the drag and drop stuff. That might not be necessary in a first implementation. Categories could be moved as well from the edit category page by selecting a new parent from a drop down list.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
An 'Add Child Category' link is either going to be useful, or unnecessary clutter. You probalby won't know until you try it. I am happy to leave details like that in your capable hands.

Flashy stuff like YUI would be cool, but certainly not needed at this time. I have no problem at all if you want to focus on the making the basics really solid and accessible. If they are, making the interface flashier can easily be done later.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
What do people feel should happen in the list above for example for the Physics category if the up link next to it is pressed? First it should become a top level category like this :

  • Default (0) the default category for questions [edit] [delete] [down]
    • General knowledge (5) [edit] [delete] [up] [down]
  • Physics (7) [edit] [delete] [up] [down]
  • Science (42) [edit] [delete] [up] [down]
    • Chemistry (11) elementary level chemistry questions [edit] [delete] [up]
Then if it is pressed again it should become a child of Default like this :

  • Default (0) the default category for questions [edit] [delete] [down]
    • General knowledge (5) [edit] [delete] [up] [down]
    • Physics (7) [edit] [delete] [up] [down]
  • Science (42) [edit] [delete] [up] [down]
    • Chemistry (11) elementary level chemistry questions [edit] [delete] [up]
Then :
  • Default (0) the default category for questions [edit] [delete] [down]
    • Physics (7) [edit] [delete] [up] [down]
    • General knowledge (5) [edit] [delete] [up] [down]
  • Science (42) [edit] [delete] [up] [down]
    • Chemistry (11) elementary level chemistry questions [edit] [delete] [up]
Then :

  • Physics (7) [edit] [delete] [down]
  • Default (0) the default category for questions [edit] [delete] [up] [down]
    • General knowledge (5) [edit] [delete] [up] [down]
  • Science (42) [edit] [delete] [up] [down]
    • Chemistry (11) elementary level chemistry questions [edit] [delete] [up]
And similarly for pressing the down button.

The alternative is that the Physics category should become a top level category and then move before the default category in two clicks.

Notice that the first / last activities in the list above do not have an up / down button. Since I don't think it makes so much sense to be able to move them into the context above / below. This can be done on the edit category page.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
There is a nice example of drag and drop lists using YUI here.

And something even closer to what we're looking for here. More info here. According to this here they are updating their licenses to the LGPL, but right now they've a license in comments in their code that looks to me like it might conflict with the GPL.

I'm not sure if I have time to work on this my js is not too hot.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Jamie - Thanks for taking the work begun by Nico to share question categories and developing it further. I am very interested in seeing this developed and I think with roles we now have better flexibility within Moodle to do a better job. Peace.
In reply to Anthony Borrow

Re: Plan to improve flexibility of question category sharing and permissions

by Jamie Pratt -
Thanks for your encouragement Anthony!
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Comments on the wiki page:


Its looking really good


I agree with you that there is such a thing as 'too many comments in the code'.


http://docs.moodle.org/en/Development:Plan_to_Improve_Flexibility_of_Question_Category_Sharing_and_Permissions#Make_DB_changes

Following the coding guidelines, the renamed column should be contextid.

With the database upgrade from the existing structure: We are agreed that connected fragments of published categories from the course category tree are moved to the site question bank as whole chunks. But what happens to the remains of the tree that is left behind? And to make matters worse, you can have random questions that select from a cateogry, or any of its children, and they pretty much preclude radical surgery on the trees. Yuck!


In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Jamie Pratt -


And to make matters worse, you can have random questions that select from a cateogry, or any of its children, and they pretty much preclude radical surgery on the trees. Yuck!



Oh dear.

Came up with several ideas to fix this :

?Rare? Problem with Random Question Types

Random questions draw questions randomly from a category and optionally any sub categories. There may be a problem with random questions which draw from sub categories. If during the upgrade and separation of the category hierarchies into the different contexts, the category that the random question is in ends up in a different context to any of it's sub categories then the question pool from which the random question draws questions from will have changed. I expect this will be a fairly rare case?? I suggest either :

  • that we simply warn the user during the upgrade that there is a problem with one or more of their questions. In the warning we tell them which questions may have this problem and which quizzes they are used in and we suggest they fix the problem after upgrade and point them to a moodle docs page to explain the problem. The warning would be something like "During this upgrade we have seperated completely hierarchies of question categories shared at the course and site level. This has affected the pools of questions that random question(s) blah blah, foofoo and oooo in quiz(zes) foo, fi and fo. You can manually edit questions after this upgrade to fix any problems."
  • we add a list of moved category parents' ids to the questiontext field for random questions after the boolean for whether this question searches in sub categories which is in there now. Then we use questions in the hierarchies below these parent categories for the pool of questions for the random question to draw on.
  • we make copies of the questions in the sub categories after warning the user.
But none of these solutions is completely satisfactory.

The rest of the issues you bring up are addressed in the wiki in these changes.
In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Another option might be:
  1. If a category is published, and contains random questions which include questions from subcategories, then set all the non-published subcategories be published before doing anything else in the upgrade. Create a log of such changed categories.
  2. If a category is not published, and contains random questions which include questions from subcategories, the copy the published child categories and all their questions to the site level, instead of moving them, leaving a copy in the course.
Actually, 2. is tricky, because different question types store data in different database tables (and the site you are upgrading may use custom question types we don't know anything about). The only reliable way I know to clone a question is to edit it using the interface, then click 'Save as new question', which is hard to automate, and will be too slow for an upgrade that may have to copy lots of questions.

So don't do what I suggest in 2. Instead, for any of the published child categories from 2. We query the database to see if any questions from that category is used by a quiz from another course. If it isn't used, we set that category to be not published. And log that change. That reduces the scope of the problem. It still leaves a small, as yet unsolved problem.

Before you start the upgrade, we should delete any random questions that are not used in any quiz (using delete_question()). That should be a safe thing to do, and can only simplify the upgrade. That can only simplify things.

I think logging should go into a file in the course files area (instead of, or in addition to displaying them on screen during the update) so there is a permanent record of the changes.

Yuck, yuck, yuck! This is horrible.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Immediately after hitting send, I had a better idea.

(I know, I could edit my previous post, but I want people to realise how messy this is.)

There is one fact that makes this whole thing simpler: which categories you have access to only matters when you are building a quiz. Once the quiz is built, the quiz has a reference to the question id, and it does not matter which category that question is subsequently moved to, it will go on being used in that quiz unless the quiz is edited. (Apart from random questions, where it does matter which category it is in, and what the child categories of that category are, but not whether the child categories are published or not.)

And, if, before the upgrade starts, we can ensure that, for every category with random questions picking from subcategories (CWRQPFS), all subcategories have the same published status as this one, then the upgrade is no problem, or at least, the procedure you have already described on the wiki works.

So, as the first step of the upgrade process, we work through all the category trees in the site, starting at the top, and every time we find a CWRQPFS, we set all child categories to have the same published status as that one, and log the changes we make so they can be reviewed later.

Because of my comment above, that won't break any quizzes.

But here is the clever bit. We don't just do all this at upgrade time, when it is difficult to pause and explain things to users. We also write an admin report (the 'Is your question bank ready for Moodle 1.9?' report) and check that in to the 1.8 (and 1.7?) stable branches. That report performs the same logic on your site as the upgrade would, and lists all the categories that would cause a problem if you upgraded now. This report can include lots of explanatory text, and have links to go and edit those categories manually, so people can easily tweak things by hand before upgrading if they want to. We can then point people to that report in the release notes.

Admin reports are pretty quick to write, and actually, it is going to be easier to write and debug that report first, that just trying to write and debug an upgrade script.

Does this sound reasonable?
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I appreciate the care and energy that you are putting in to this issue. Most of my quizzes involve random questions and sub-categories. I would be happy to help with testing. Peace.
In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Pierre Pichet -
There is a problem as long as calculated question support the sharing of wild cards at the category level.
If you move a calculated question to another category ( change the category id) that use a shared wild card there will be no problem using it in a quiz as long as you don't edit the question.
The code to move questions to other category should be optimized so that this is not just a simple change to the question table category parameter but a call to a specific Qtype->move_to_category() function or something similar.

Pierre

P.S. We add some discussion about the moving of a question to another category process but I don't remember where ( and a rapid search in the forum was not efficient...)



In reply to Tim Hunt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Jamie Pratt -
In this rare possible worst case scenario :

  • Science (not shared) CWRQPFS
    • Chemistry (shared) CWRQPFS
      • Organic Chemistry (not shared)
      • Inorganic Chemistry (shared)

CWRQPFS = category with random questions picking from subcategories

I guess we will set everything under Science to not shared before upgrade. Ie. the topmost category with a CWRQPFS will determine the shared status of all sub categories regardless of whether there is a CWRQPFS in a sub category. This won't affect existing quizzes.

In reply to Jamie Pratt

Re: Plan to improve flexibility of question category sharing and permissions - Problem with Random Question Types

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes, but additionally, for the shared categories, we can query the database to see how many questions from that category are actually used by quizzes from other courses, and list those quizzes/courses, in the proposed admin report.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators
Very interesting discussion.

In lots of trainings with teacher I see that most of them are confused about the way to use the features of quiz.

If we are adding more features we should have a look on usability also.
In reply to Ralf Hilgenstock

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Peter Ruthven-Stuart -
Picture of Plugin developers
Ralf,

Thanks for your comments re these developments. Note that the plan to allow students to create their own questions will be a separate activity to the Quiz module. However, your point about usability is well made.

As a moodling teacher who shows other teachers how to use the system, it is apparent to me that many people have a hard time interacting with UIs (not just in Moodle). So, once we get to the stage of testing both the teacher and student UI your help and suggestions will be greatly appreciated.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
===Replace old permissions code===

Introduce a new capability 'moodle/question:usequestions'.

Replace old permissions code based on sharing field of question_categories table with new permissions code. Check when creating a quiz that the user has permissions to access the category. We can probably leave this till after the other steps and until then write code that gives everyone access to questions in all contexts. Then at the last stage we write code that restricts access and doesn't display categories for roles without the usequestion capability in that context.

For all roles and all contexts from the course up the usequestion capability will default to being the same as the managequestions capability.

Wrote the above for the wiki but it seems to me that usequestions is not needed. I don't see the difference between moodle/question:manage and moodle/question:usequestions. Now we will be testing for moodle/question:manage at the different context levels to see if the user has the capability to access the category in that context. And if they have permission to access any category they are allowed to use the question bank.

I'll check through the code and document what exactly the different capabilities do now. This will be a first step to proposing some new capabilities.

In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think it is useful to distinguish usequestions and managequestions. Two examples:

1. In a large institution, you might want quite strict controls over who is allowed to add questions to the global question bank. You might want all teachers to create their questions in their own course, and then have a 'question librarian' who checks them, and moves reusable ones to the global question bank and files them in the right category in. However you want lots of teachers to be able to use questions from this question bank.

2. You want an activity where students build quizzes, but only using a predetermined set of questions that the teacher has prepared for the purpose.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I got the difference now between usequestions and question/manage. manage is for creation, editing, deleting, moving etc. usequestions is just for the capability to include a question in a quiz or in another activity.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I did think of a slight problem with our plan, to do with what roles and capabilites can and can't do. The problem is that capabilites only flow downwards.

So, what you can't do is have it automatically allow all teachers in all courses to access the global question bank.

People will only be able to access the global question bank if they have some role at the site level which has the usequestions capability. The teacher role is normally assigned at the course level.

For some people, this will be a feature: Being able to separately control who can get at the global question bank. But for people who are used to how published categories work now, it will be a bug.

We could consider extending the roles system a bit, so when creating a role, you can specify "When someone is assigned this role in a course context, also assign them role YYY in the parent course category and site contexts." This could easily be handled by a function that works just like sync_metacourses.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
Similar problem here it seems : MDL-4469 Non-admin user's ability to submit a site event to calendar
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
That does seem to be a problem. Correct me if I'm wrong :

  • this won't affect existing quizzes.
  • teachers who are assigned as teachers at course level (most teachers) will no longer be able to access any shared questions unless they are specifically allowed to. Not at the course category or the site level
We could consider extending the roles system a bit, so when creating a role, you can specify "When someone is assigned this role in a course context, also assign them role YYY in the parent course category and site contexts." This could easily be handled by a function that works just like sync_metacourses.

So you imagine being able to create a new role perhaps called 'courseteacher' that would be assigned at the site level and then admins would be able to control capabilities to manage site calendar events and to use questions from the question bank. metaroles??


In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes, or if you wanted it to be more transparent, you could create two roles: "Question user" and "Calendar manager" which each just allow the one extra capability. Then on the settings page for the Teacher role, you would be able to set up "Anyone who has the Teacher role on any course also gets assigned the Question user and Calendar manager roles for the whole site."
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I've done more thinking on how roles and permissions will work with the new question sharing functionality.

I propose that access control to context question banks will be effectively controlled by a dual permission system! Although a user may have the usequestions permission at system level and thus have the permission to access question banks all over the site, they will only be able to access question banks in contexts that are parents of the current context.

We will need some seperate capability to control whether the user has permission to access the question UI from the current context. This seperate capability might be question/manage (or maybe this should be given a new name like question/viewui). The seperate capability will only be tested at the course / module level -the current context. Whatever, the main point is that when a user accesses the question UI we are doing tests for permissions in different contexts - at the current context to see if they can access the question UI here and then for the different question banks for the question/usequestion capability to see which parent contexts' question banks the user has access to.

So in order to have question sharing work as before then we can assign a permission at the system level usequestions for all users. But this permission will not let anyone do anything unless they have the viewui permission at the course / module level, they must have both permissions. Thus question sharing will work as at present if we set as default that all users have the usequestion permission at system level (and this will be inherited in all contexts).

Other scenarios of how questions can be shared will be supported with this kind of dual permissions system. usequestions might be disabled at the site level for all users but enabled in site / course category contexts for all users / just some users etc. usequestions will always be allowed for teachers at the course level and this would be inherited usually in module contexts.




In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
A 'dual permissions system' of some sort will of course be necessary anyway otherwise if we assign a capability at some parent context for a user to be able to usequestions in that context then that capability will be inherited in all child contexts and so someone who is a teacher in one course will be able to access questions in other courses.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I though my original proposal already included the fact that when you are in a particular context, you can only access questions from that context and its parents. Anyway, I agree with you there.

I am not yet convinced by the need for a viewui permission.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I am not yet convinced by the need for a viewui permission.

Yeah, whoops. I thought I had found a solution to the problem of permissions for contexts above course level for teachers. It involved testing for a permission at the module / course level depending on where the question bank was accessed from AND a permission in the context of the question categories. But it wouldn't work I'd just got my logic in a twist. smile
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
We could consider extending the roles system a bit, so when creating a role, you can specify "When someone is assigned this role in a course context, also assign them role YYY in the parent course category and site contexts." This could easily be handled by a function that works just like sync_metacourses.

One problem with this would be that the capabilities assigned at the higher level will then be inherited in all child contexts which might not always be helpful and would become very complex when these kind of meta-roles are used for allowing other permissions for students / teachers at context levels above the course level.


In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by John Isner -
Sorry for this delayed post. I just stumbled on this discussion through a link in another forum.

The way publishing works now is a bug! Teachers should never have been allowed to push their categories to the site, and any organization that was serious about QA would have disabled this feature. I hope that the changes to how categories are shared solves this problem. Categories should either be pulled from below, or pushed from below by someone with permission to create questions in the higher context.
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
'when you backup a course, you get the course, category and site banks. And the banks for the activity modules you chose include in the backup that have their own banks.'

There is a potential problem here which I'm thinking about. If a teacher has backup permissions for the course, but doesn't have permission to access the course category and site banks, are they able to backup a course and should questions that they don't have access to be included in the backup. This would give them access to restore the questions somewhere else with some editing of the xml file.

If they are not allowed then what about if there are questions used by someone with different permissions in a quiz who had permission to access the questions.

I guess we back up all the questions whether the user has permissions to access the questions otherwise. And someone who has course backup permissions is trusted to have access to the xml files.



In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I guess this is not really a problem although not ideal if people know about this issue when they choose to share questions at the site / course category level.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think we need to continue with something a bit like the way it works at the moment.

At the moment, when you back up a course (including some or all of the quizzes), it backs up all the categories in this course, and all the published categories from other courses used by one of the quizzes we are backing up. The logic for this is in the function insert_category_ids in mod/quiz/backuplib.php.

Each question and category has a globally-unique-id.

When restoring, if a category or question in the backup file has the same id as one on the server you are restoring to, then that is used instead of restoring the one from the file.

If the category does not already exist, a new category is created attached to the coures we are restoring (even if it was a published category before). Similarly qith questions.


The guiding principal with Moodle backups is that everything you need is included in the backup file.

On the other hand we don't want the backup file to get too big when there is a huge global question bank.

If you have the right to bakup a course, you should have the right to backup everything used by the course.

When you have the right to restore, you can restore into that course, but not necessarily globally.


Therefore, I think backups should include all questions from the course and modules we are backing up. However, from the category and system question banks, it should only inlude the categories that are used by this course.

On restore, match globally unique ids as now to avoid creating duplicate questions. If we do need to restore the question, then if they person has site/category restore and add to question bank capabilites, then add the questions to the global/category question bank. Otherwise, create new categories at the course level, and add the questions to them.


Althoght this sounds quite complicated, I think it is right, and the existing code does approximately this, so you should be able to use it as a starting point.
In reply to Tim Hunt

Re: want to have a way for ...... - ready to start work?

by Jamie Pratt -
Your plan sounds good to me. I added your proposals slightly reworded and with some more detail to my development plan.

Please take a look Tim.

I think we've covered nearly every point in the development plan, although more will come up during the work. I'm wanting to get started with some coding. Can you look over the plan and then I'll message Martin to let him see it and possibly make any comments and I can get started.
In reply to Jamie Pratt

Re: want to have a way for ...... - ready to start work?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'll try to give it a final review today, although I have been following its evolution via recent changes, and it seems pretty good so far. But I should probably read the whole document through again now. As I say, I'll try to do that today. If you have not heard from me by Friday morning your time, nag me.
In reply to Tim Hunt

Re: want to have a way for ...... - ready to start work?

by Jamie Pratt -
Thanks Tim.

Look forward to your comments.

Jamie
In reply to Jamie Pratt

Re: want to have a way for ...... - ready to start work?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Some specific comments about details. But basically this is a great plan. Go for it!

Before Branch Changes to HEAD, ?17_STABLE? AND 18_STABLE

I think you should develop this report on head, but not backport it to the stable branches until you have made enough progress with the rest of the work to be 100% confident it will be released in 1.9. That avoids raising expectations, and starting people worrying about the upgrade until we are 100% sure it will happen in 1.9.

Change in How Categories Are Shared

When changing the tree, it would be nice if you could preserve the existing ordering as defined by the sortorder fields.

Question Bank Page

The category dropdown menus here, and on all other pages, are all produced by the question_category_options function in questionlib.php, so you should just have to edit that function.

(Historical note: In the past, this code was implemented in four different places, and each version had different bugs. Also, it was slow with lots of categories. So I rewrote it as a function with better performance. I'm sure you won't undo my good work here. The question category editing page does not use this function, and is still slow with lots of categories. See http://moodle.org/mod/forum/discuss.php?d=68157.)

Add Permissions to Roles and Permissions System

With the changes in capabilites, do you need to think about a database upgrade script that gives appropriate new-style capabilites to roles based on the old role definition? Note that the upgrade procedure does not have the flexibility to let you do this at the moment. It will update the list of capabilites in the database for you, based on access.php, but it does not let you insert custom logic to control which roles get the new capabilites.

In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I notice in the current backup code that where there is a shared question used by a quiz in the course then all questions from the shared category are backed up and also all questions in parent categories in the other course are backed up.

I'm not sure of the logic behind backing up all questions in parent categories but I think it is safe not to back up parent categories in the new code.

Maybe we should also make the backup select exactly what questions it wants to backup instead of always backing up entire categories.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
I think we probably need to add functionality insert_category_ids to insert question ids as well and only back up questions we need for the quizzes in a course from contexts above the course level. Then we can backup categories that are parents of the categories in which there are questions we need but not the contents of the categories.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Possibly. When I cleaned up this code recently, I was not brave enough to make that sort of change, but I can't see any problems with changing it if you want to tackle it. It will just leave unnecessary information out of the backup file, which is probably a good thing.

Of course, with child categories of categories with random questions, you do still need all questions.

After you make this change. Will they be any way to backup and restore the site-level, or a category-level question bank?
In reply to Tim Hunt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Jamie Pratt -
After you make this change. Will they be any way to backup and restore the site-level, or a category-level question bank?

No. And there won't be any way to do a Moodle back up of unused questions in the system or category-level question bank after I follow our agreed plan for what questions should be backed up.

In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I guess that isn't a problem. We have backup and restore for managing courses, and all the things they depend on, and import and export for managing question banks.
In reply to Jamie Pratt

Re: want to have a way for students to be able to create and edit their own questions but not be able to access questions in the same course

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Jamie - Thanks for initiative to spur on this conversation. I am pleased with the direction that the conversation is heading. Peace.
In reply to Jamie Pratt

Re: Moving question when and how...

by Pierre Pichet -

  1. Actually there is a select category element when you create or edit a question. This allow the user to change the category in the edition process so to MOVE the question to another category.
    Although I undertand that the categories display there should be the ones that are allowed to the user, should we continue to allow this moving in the edition and creation process or just in the normal new interface that you are building?
  2. If I use the calculated question as an example of complex question, in addition to a move_to_category() there should be a select display when moving questions that could confirm the user choice like in the DELETE question process.
    Also calculated questions can share wild card parameters between questions in the same category. If you move all the questions that share the same wild cards, there is no problem. If however you only move some of them, the user should have a warning about this and act accordingly as long as the calculated question can create a new wild card set in the new category or use a similar wild card parameter already present.
    So the additional confirm moving should be handled in part by the questiontypes.

    I could work with you on this moving of complex question.

Pierre