Posts made by Joseph Rézeau

Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Hmm... Not for me... I am conducting my tests on a clean new 1.9 install, where I create a couple of courses, a couple of quizzes in each, a couple of categories and a couple of questions in each category.

In import.php, right after

list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup(false, false);

I add this line:

echo("HERE IS IMPORT.PHP courseid = $courseid; cmid = $cmid");

In course ID 2, if I go directly to the questions bank and click on Import, then import.php echoes "HERE IS IMPORT PHP courseid = 2; cmid = 0".

In course ID 2, if I edit quiz ID 6, and, on the editing quiz screen I click on Import, , then import.php echoes "HERE IS IMPORT PHP courseid = 2; cmid = 6".

As far as I can gather, $cmid contains the id of the quiz being currently edited, not the course id. So in import.php, the test $validcats = question_category_options( $cmid, false, true ) can't return a correct list of categories in the actual course. I maintain that it does work however with $validcats = question_category_options( $courseid, false, true );

Can anyone confirm this?

Joseph

Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Howard, if I compare question/import.php and question/export.php in 1.9 latest version, both have this line:

 list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup();

If I try to echo or notify $thispageurl I get a blank page and no error message. What on earth is this $thispageurl meant to be like?

Anyway, in both question/import.php and question/export.php, the value of $cmid is 0. In export.php you do not use $cmid at all when testing the validity of category, so export works fine:

 // check category is valid
 $validcats = question_category_options( $course->id, true, false );
 if (!array_key_exists( $categoryid, $validcats)) {
 print_error( 'invalidcategory','quiz' );
 }
In import.php, however, as mentioned in my previous post, you do use $cmid:
 // check category is valid (against THIS courseid, before we change it)
 $validcats = question_category_options( $cmid, false, true );
 if (!array_key_exists( $params->category, $validcats )) {
 print_error( 'invalidcategory', 'quiz' );
 }

And of course, because $cmid = 0, the category is never valid, hence the error. Although I do not understand the relationship between this error and the "library for constructing URLs" mentioned in your post, I suggest doing the simple replacement mentioned in my post in import.php, i.e. using $courseid instead of $cmid in the category validity test. What do you think?

Joseph

PS.- Better swear at your computer than at real people. He/she?/it won't mind.evil Keep up the good work.cool

Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Another possibility is as follows. In question/import.php line 71 if I replace:

 $validcats = question_category_options( $cmid, false, true );

with

 $validcats = question_category_options( $courseid, false, true );

everything is working fine...

what is $cmid doing in 1.9 instead of $courseid (as in 1.8)?

Joseph

Moodle in English -> General help -> Copying courses -> Re: Copying courses

by Joseph Rézeau -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Robin,
Do you mean to say that on your Moodle site you have set up one course only, e.g. Course01 and you now want to create another similar course, e.g. Course02? You say that new course would be similar but with different participants and content. Well, if both the participants and the content is different, how much "similar" to Course01 would it be?
Which "elements" of Course01 exactly do you want to retain in Course02?
Joseph