Duplicate Questions and save in other Context

Duplicate Questions and save in other Context

by Pascal Schärli -
Number of replies: 2

hello everyone

If you duplicte a question ($makecopy) you are only able to save the copied question in a category which is in the same context like the original question. same when you are editing a question.

is there an option to make some changes on the code, to safe it in categories which are for example in a lower context (course...)?

the best way will be to choose the new category directly while editing the question. But I might to be happy as well, if i could choose the category after push the save-button.


thanks for your answers.




Attachment duplicate.JPG
Average of ratings: -
In reply to Pascal Schärli

Re: Duplicate Questions and save in other Context

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Almost certainly impossible. I think you will have to duplicate the question, then move the new one.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Duplicate Questions and save in other Context

by Pascal Schärli -
hey tim. thank you very much for the fast answer.
unfortunately, this is a little time-consuming for our teachers.
would it be possible to hide the categorychooser while makecopy and move the question after saving directly to the topcategory of the current coursecontext?

I tried something in mydomain/question/question.php:

if i add the following code on line 242 it moves to the category id i added here:

/// Process the combination of usecurrentcat, categorymoveto and category form
/// fields, so the save_question method only has to consider $fromform->category
if (!empty($fromform->usecurrentcat)) {
// $fromform->category is the right category to save in.

// new code-----------------------------------------------------
if ($makecopy) {
$fromform->category = '259';
}
// end new code -------------------------------------------------

} else {
if (!empty($fromform->categorymoveto)) {
$fromform->category = $fromform->categorymoveto;
} else {
// $fromform->category is the right category to save in.
}
}