category sharing for big sites

category sharing for big sites

by Nicolas Drosson -
Number of replies: 48
Hi,

here is a hack for sharing of question categories not only with everyone or noone, but also with only the courses of the same course category and its subcategories. If someone wants to test it. It's now a newer version with a bugfix.

Thx in advance Nico
Average of ratings: -
In reply to Nicolas Drosson

Re: category sharing for big sites

by Gustav W Delius -
Nico,

this is very useful.

Can you provide some screenshots of the interface? People are more likely to test new code when they know in advance what to expect.

The code that Nico has attached will work with Moodle 1.6, not Moodle 1.5.
In reply to Gustav W Delius

Re: category sharing for big sites

by Nicolas Drosson -
Oh thx Gustav, I forgot to mention it!!!

In the next days I will post some screenshots.

Regards Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Nicolas Drosson -
I think it is better to test it in live on my test instance:
http://www.drosson.at/moodle-test/

To get teacher rights, please send me an E-Mail at: nicolas.drosson(ät)students.jku.at with username and password. It will be done until the next day.

cu Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Alexander Kuo -
Hi! Nico,
     It is really terrific! We have looked forward to this function for a long time. Now, it does emerge! Thanks!
     By the way, can it run in Moodle 1.5? We are really eager for this function! Or, any suggestion?
In reply to Alexander Kuo

Re: category sharing for big sites

by Nicolas Drosson -
Hi Alex,

The sharing would work with moodle 1.5, but it needs some small modifications because the questions in 1.6 are not in the quiz module anymore. Also before you go in production with this, you should test it (I may have forgotten some test cases). I will post a version that works with 1.5 in the next days.

Hope you'll have fun with it.

Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Nicolas,
Could you please make a version of your module for making quiz questions shareable at teacher level as in this discussion?
Thanks
Joseph
In reply to Joseph Rézeau

Re: category sharing for big sites

by Nicolas Drosson -
Salut Joseph,

Thx for the purpose, I will look at it, but I'm now working on something else, so it could last some time.

Nico
In reply to Joseph Rézeau

Re: category sharing for big sites (publish to self)

by Nicolas Drosson -
Hi Joseph and Anthony,

I hope it is what you wished. Now it is possible to publish a category in all courses where you are a teacher. It means:

You publish it for you in course1 and you are also teacher in course3 so you can use your question category also in course3, but the other teachers of course3 cannot see the category. All the teachers of course1 that are teachers in other courses can also use the question category in their courses.

It was now a fast hack. I think it will need some improvements.

I checked whether the import and export should work and it seems to work for moodle153. The Backup of courses is still a to-do for this hack.

Regards. Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Nicolas Drosson -
Hi Alex,

here is the version to share in moodle 153. I hope I found all the bugs.

Regards Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Alexander Kuo -
Hi! Nico,
      I download it and just give it a try. It really works! But there is one thing that I can't make sure. In your attached file,  a sub-directory, "question",  with three files,  exists under the directory "categories". Do I need to upload this directory onto my Moodle site? If necessary, where should I put it? Now, without uploading this directory, this fuction of category sharing seems to work fine.
      Thanks again for your great help!

Regards Alex
In reply to Alexander Kuo

Re: category sharing for big sites

by Nicolas Drosson -
Oh excuse me. The folder question is part of the moodle1.6 version and I forgot to delete it. It shouldn't influence the function of the patch.

You should test it very well before you go in production with it. I did not have a lot of time to test it on 1.5.3. Please tell me if you find bugs. I will try to fix them as fast as possible. It is not a big change so if you want to find the changes, just look for "ndr". I marked all my changes with it.

Regards Nico

PS: Here is the version without all those unneeded files.
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I really appreciate the modification and additional functionality. In part this helps to solve a concern I had about allowing some students to be teachers in clubs. When questions were published it meant that those students would have access to all published questions which was less than desirable. I have done some brief testing on a test server and will be moving to production. I am planning to move to version 1.6 when it is available and relatively stable (I like living on the edge). I would like to encourage you to share a categories1.0-moodle16 version once 1.6 is officially released. One thing that I found confusing in the help file is the use of the word categories. I think it may be worth considering whether both question categories and course categories should both be called categories. If so, then we should be very explicit in the help files which category we are referring to so as to avoid any possible confusion. Peace.
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Hi Anthony,

thx for the feedback. I will probably need some help from english natives. I speak other languages much better than english. There is only one thing I did not consider: the backup of tests. It is possible, that this doesn't work well. I can remember I looked at it some weeks ago, as I began, but I had some difficulties (It was in moodle 1.6 Alpha).

You also have to be carefull when you share a question category, because a shared question category which parent is not shared will not be visible in other courses. Another example, if a category c1-1 is shared for all and its parent c1 is only shared for the own course category, c1-1 will be automatically shared only in the course category of c1.

If you have any suggestions on how I could improve the patch, please let me know.

Regards Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

One small comment, since I was taking your patches to \mod\quiz\editlib.phpfrom version 1.8.2.11 and using them to modify a later version of the quiz module (1.19). You did a good job of commenting the changes that you made to the code which made it easy to pull the code into a different version of the same file which I am using on my production server. The first time I tried it, I missed adding in the global $CFG; line in the quiz_print_category_form function. I am not sure if this was dropped from an earlier version or something you added. In newer versions of the file it is not there so you may want to add your // BO added ndr and //EO added ndr lines around that otherwise the sql statement will not execute. I would be happy to revise the help file text in English to help make it less ambiguous. Thanks for the warning on parent categories - I will keep that in mind and if I think of any improvements or suggestions I will certainly let you know. For now, I am very pleased with how this works.

In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
You're right, I forgot to add the comment around global $CFG. I add it and post it again. Here it is. Thx for the purpose to improve the help text. It is really cool. I will also post the translations in french, german and spanish if Gustav decides to integrate it in the original quiz module.
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Attached is an attempt at clarifying the language in the categories help file. Use it (in part or in whole) in so far as it may be helpful. Feel free to modify it to your liking. I was also wondering, would if you had considered creating a fourth option of "publish to self" where the question category would be available only to one's own courses? It does not seem like this would be too difficult to implement.
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
thx for the correction, I will use it in my next version.

The option "publish to self" (Joseph also needs it) is maybe not so difficult to develop, but I think it is not good to have only the 4 options. It would mean, if I share my category only with the course category, I can't share it with my other courses (if I'm a teacher). I think, it would be better having 2 fields of options: share with all courses of the current category or all courses at all or don't share / share with all my courses or don't share (another option to this could be: share with all my courses and those of the other teachers in the current course. It's just an idea), but I think, if I'm doing it this way, I should discuss with designers so they tell me the best way to make it easy to use and "self explaining".
In reply to Nicolas Drosson

Re: category sharing for big sites

by Joseph Chopp -

I've worked around the bi-catagory problem by NAMING each question with a prefix of RQ!, RQ2 and FT (reviewquiz1, reviewquiz2 and final test).  So now I can quickly see a listing of questions for each test displayed all in one place.

However, anonther question has popped up: How do I delete a question from one catagory without deleting it from the other catagory.  Right now both listings are gone unless it is shown as an "old question" in both.  AND...this deletion of the question from both lists is not what it says is going to happen when I delete a question from one catagory. 

Thankx.  Joe

In reply to Joseph Chopp

Re: category sharing for big sites

by Nicolas Drosson -
Hi Joseph,

I don't really understand what you mean. What is bi-category? I think you could mean copy of questions, but then you have 2 different questions... Maybe you can try to explain better what you mean or give examples.

Regards Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Joseph Chopp -
Only 2 catagories seem to be permitted.  A question listed in both catagories "A" and "B" can not then be deleted for "A" without being deleted from "B"...then they both show that question as an "old" question instead of (as the program indicates) just affecting one catagory list.  When I restore the question to either list, it restores on both lists.
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico - Do you have a beta or even alpha version for 1.6? I am trying to get my code ready to migrate and I would like this functionality when I do. I would be happy to help with any debugging. Have you heard anything from Gustav as to if there are plans to incorporate your modifications into the standard code (I certainly hope so). I created a feature request as bug #5437. They seemed interested for 1.7 but if I can get it working before then all the better. Merci.
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Hi Anthony,

De rien. Here is the latest version for moodle1.6. I would say it is still an alpha version. This one still doesn't implement the sharing at teacher level. I don't have talked about it with Gustav. At the moment, I don't have enough time, but I think I will.

A bientot Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
C'est magnifique! I will give it a try - I am not as concerned with the teacher level sharing as this will take care of my concern with students who are helping to co-moderate a club will not have access to academic evaluations. I will work on installing today and begin testing. Paix.
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I merged the files you sent with the latest from CVS. Some functions were moved from /question/editlib.php back to /lib/questionlib.php so I included the /lib/questionlib.php in the attached zip file. I also uploaded the zip file to the feature request (bug #5437) in case they want to try to squeeze it into 1.6. I did some light testing of the revised code and it seems to be working great. 
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico - You may want to take a look at the feedback from Bug #5437 about checking the published status.
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Hi Anthony,

Thx for your help. I will look a bit more in detail where the question engine looks for published categories and modify the patch.

Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Let me know if there is anything I can do to be of assistance.
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico - I have upgraded to the latest CVS of Moodle 1.6. When I go to the questions link in the admin block and try to select one of the categories the heading changes to the name of the category but below it displays "No questions have been added yet" - Of course I know that there are questions there because they show up on the quizzes but I cannot view the questions. I tested things on test.moodle.com and it works fine which leads me to believe that it has something to do with the patch. Have you experienced this or do you have any ideas? Peace - Anthony
In reply to Anthony Borrow

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I found the problem - it was in the /question/editlib.php file. When I diff'd and merged the files apparently the line

define('DEFAULT_QUESTIONS_PER_PAGE', 20);

which is in CVS was cut from my file. Once I added it back in things worked like a charm.
Peace - Anthony
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico - I have been working with a merged version of the code with 1.6.1 and have noticed that when I go to a course and attempt to use questions in a published in course category (publishedincat) I am unable to get a list of questions. In fact from the /mod/quiz/edit.php?courseid=32&cat=11 it just takes me back to the local course's default category. Any ideas as to what might be happening? If I switch it to a published question then it seems to work. Have you had a chance to work on the code for 1.6.1 any further? I will continue to try to track down the source of the error but it is late and I've had enough for today. Peace.
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Hi Anthony,

I think it happens because the quiz module and questions have been modified a lot in the time after I published the category sharing. This week, I have no time to check what's wrong because I'm finishing my offline quiz module. I will probably look at it next week.

Regards Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico - thanks for all you do to contribute to Moodle. Next week would be fine and I will continue to poke around and see what I can find. Peace.
In reply to Anthony Borrow

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico,

After some hunting, I stumbled across the \question\showbank.php file. I simply added an OR publish='2' and it now works - in other words - I replaced line 154 with:

if (empty($SESSION->questioncat) or !count_records_select("question_categories", "id = '{$SESSION->questioncat}' AND (course = '{$course->id}' OR publish='1' OR publish='2')")) {

I figured that was OK since it had already selected the eligible categories that there was no need to check again that it was within the course category but this may be a theoretical since the code here is not explicitly checking for that possibility.

You may also want to look at the code for direct reference to publish being 1 in throughout. I did a grep for publish and have more details in the feature request (Bug #5437).  When you get a chance to get back to the publish question category code I wanted you to have a place to start smile

You may well find other places and  have a more elegant solution that will handle other possible publish values. It could be that a simple check for publish<>0 or publish>0 will work in some cases but the $sql= code (~line 180) that you created in \question\editlib may be needed in others. For the time being the change to showbank.php seems to patch it for me.

I am going to post this also in the feature request (Bug #5437) so that there is a documented list of places to check the code along with a recommendation that the $publish variable be changed to $qcatpublish (i.e. QuestionCategoryPublish) to make it easier to search for.

Peace - Anthony
In reply to Anthony Borrow

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I'm uploading an update of the code that I am currently using for my production site to enable question categories published within a course category as categories_1.05ab.zip which should be merged with changes for Moodle the 16Stable tag (1.6.1 - 2006050510) from CVS as of July 26, 2006 that includes the showbank.php patch discussed above.
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Cool thx... So I have a bit more time to finish my offline quiz and all other features I'm adapting for my university. Thx again. Nico
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Hi Anthony,

Did  you run into any problem with this patch until now? I will hand in my diploma thesis next week and would need a feedback.

Thx in advance. Nico
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico -  I continue to use the patch on my production server and have not had any problems with it. I hope that this functionality gets introduced into Moodle core as it gives a significant level of control over how and to whom questions are being shared. Even with roles in 1.7, I think it will help to keep the number of categories seen by a teacher making a quiz to a minimum. As I said, it allowed for my teachers to share questions without the questions falling into the hands of the students who were co-moderators of clubs. Please let me know if there is any other feedback I can provide that might be helpful to you. Thanks for all of your work on this patch. Paix - Anthony
In reply to Anthony Borrow

Re: category sharing for big sites

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 am glad the recent posts have bright this thread to my attention. I was not previously aware of it. This looks like a valable patch, and I will try to get it into core for Moodle 1.8.
In reply to Tim Hunt

Re: category sharing for big sites

by Nicolas Drosson -
Hi Tim,

For Moodle 1.53 I also created an option to share the categories only in the courses where the teachers are also teacher. It is easier to explain with an example:

Nico and Tim are teachers in the course toto.
Nico and Mark are teachers in course tata.
Tim and Tom are teacher in course titi.

In the course toto, Nico creates a category and shares it in all its courses. This sharing has the effect, that Tim also sees the category in all its courses. I don't really remember, but I think this has a problem: Mark and Tom wouldn't see this category if I remember well.

Should I look if I can adapt this sharing option to the patch?

Regards Nico
In reply to Tim Hunt

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Tim - Thanks for your work to stay on top of what is happening with the quiz and question code. I was happy to see the tracker update and the intent to incorporate this in to 1.8 That is excellent news. It really does provide a greater amount of control over the categories. Perhaps an option could be written that would share the category with a specific role. In any case, one step at a time. 
In reply to Anthony Borrow

Re: category sharing for big sites

by Nicolas Drosson -
Hi Anthony,

It would be a good idea, but until now, I haven't looked at the role system of 1.7. I'll have to do it in the future. Maybe I can make a new version for 1.7 in the next months.
In reply to Nicolas Drosson

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nico - I hope you do have time to contribute to this functionality. I was thinking that utilizing roles would give greater flexibility. For example, an administrator could define equal but distinct roles like Math Teacher, Science Teacher, etc. and then regardless of the course category that the course is in the teacher could have access to the questions of other math or science teachers. In our institution, I could even have a Sophomore Theology Teacher role and they would only see what other Sophomore Theology Teachers are doing. Let me know if you need any help with testing. Good luck as you finish up your studies/dissertation.
In reply to Tim Hunt

Re: category sharing for big sites

by Pierre Pichet -

Hi Tim,

I am working on this feature and I have ported the code to the last 1.8 release.
You can see it in action on (although I think you have more important things to do!!!)
http://132.208.141.198/moodle_head/

I will put the new version on cvs (moodleuqamchi on sourceforge) today and my comments on MDL-5437.

Pierre

In reply to Pierre Pichet

Re: category sharing for big sites

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Pierre, This is great news! Thanks for your work on it and let me know (through the tracker) if you need any help testing or with anything at all. I am excited to see this incorporated into Moodle core. Peace.
In reply to Pierre Pichet

Re: category sharing for big sites

by Pierre Pichet -

However this simple fix just do one thing :

It allows the teacher to control if the questions will be seen by other courses in the same category or by all the other courses irrespective of the category level.

The course category level is being set by the administrators.

Given the philosphy of the new 1.7 roles, implementing your feature will be more complex and the code should allow

  • for the administrator the control of the courses category and number of levels
  • and (or) for the teacher the possibility to share the questions at either some category level or even to specific courses.

The transfer of question copies between courses can be controlled actually by the teacher

  • by publishing a category at a specific time known to the other teacher.
    In this case, the question
  • using the import export facility. However the import-export is not actually working for many questiontypes.

Your interest seems to (as an administrator)

  • allow the teachers to limit the extent of diffusion of there questions.
  • limit the number of unsollicited categories displayed for all the teachers.

As a teacher, I am more interested in giving access to my questions to specific courses without having to ask the administrator.

So, if we say that the actual transfer mechanism available (publishing at specific time or using the import-export functions) is satisfactory for individual teacher to teacher transfer, we should work your proposition so that it can handle the course category level of publishing with a select option and not the different eye images.

Your comments.

Pierre

 

 

 

In reply to Pierre Pichet

Re: category sharing for big sites

by sofia torrão -
hi pierre,

i'm really interested in this feature and would like to see it in your site... is it possible for you to arrange a moodle test teacher acccount?

thank you

sofia
In reply to Nicolas Drosson

Re: category sharing for big sites

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Nicolas,
All the best for your thesis.smile Will it be avaible online?
Joseph
In reply to Joseph Rézeau

Re: category sharing for big sites

by Nicolas Drosson -
Hi Joseph,

Sure I will publish it. I mean, I will publish the new module and the necessary patches. The written work is in german so I don't think it would be interesting for you. I may begin to translate it in french, but I don't think I will do it in english. I'm not sure if the difference is clear in english between diploma thesis and the word thesis alone. What I mean is with diploma thesis is the big work at the of my study to become Master of Economics, E-Business and E-Learning. It's not a thesis for a PhD. I don't know if this exists in english...

Before the publication I just need some more time because I still have 3 Bugs. 2 of them are common with the quiz module: The 2 Bugs I commented yesterday, one in comment.php the other in Backup/Restore. I want to correct them before I publish everything.

Regards

Nico