Is it possible to have a question type specific save and continue editing button?

Is it possible to have a question type specific save and continue editing button?

by Marcus Green -
Number of replies: 12
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Is it possible to have an additional button with the functionality of the current "Save changes and continue editing button" that appears at the end of a question editing form. I was hoping to be able use such a button to pick up the id's of a freshly saved multi-part question and use that information later in the editing form.

So I was hoping to be able to do something like

$mform->createElement('submit', 'updatebutton','Some Text');

Without clashing with the one at the footer of the form.

Average of ratings: -
In reply to Marcus Green

Re: Is it possible to have a question type specific save and continue editing button?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Search for registerNoSubmitButton in the question/type folder to see how this is done. There are examples in the multianswer question type, and the three calculated question types.

There are other examples in the OU question types like ddimageortext and varnum*
In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Would such a button be able to do the database write/question save functionality of the current button at the foot of the editor form?

In reply to Marcus Green

Re: Is it possible to have a question type specific save and continue editing button?

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 should not do that. What if the user then clicks Cancel?

In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

They would have the question text without the other bits. I can very easily live with that possibility.

In reply to Marcus Green

Re: Is it possible to have a question type specific save and continue editing button?

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 you don't have to live with that.

I did not mention it before, because the form as a whole is rather complex, but STACK handles this case fairly well. That is used in combination with registerNoSubmitButton:

https://github.com/maths/moodle-qtype_stack/blob/6775f865bb5459da8ee299427fb1a53e78a36632/edit_stack_form.php#L121

In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I decided about an hour after my last post that you were right (grrrrr). I have been reading the Stack code for a while and while it is complex it is useful for inspiration.

In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

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

@Marcus, I also use $mform->registerNoSubmitButton() in my Regexp question type. It works fine (once you've understood the concept).

Joseph

In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I would like to be able to save changes without exiting while I am editing a Formulas question. The reason is as follows:

As opposed to Calculated questions, variables of Formulas questions do not seem to be global across different Formulas questions in the same quiz (please could you confirm this?). Hence, quizzes in which there is a Formulas question may very well have only one question with several subquestions. That could make Formulas questions sometimes long to set up, with much checking and debugging required.

Unfortunately, when returning and editing a Formulas question, after saving it for checking, each time one has to wait for the page to be loaded again, click "Expand all", "Display more..." a few times and resize a few Variable windows. This would not be a problem if it had to be done only a few times. However, with long Formulas questions, this needs to be done quite often. It then becomes a bit frustrating to realize that after a day's work, much time has been spent in waiting, reopening and resizing windows in the question editing page.

A "Save changes and continue editing" button would allow editing and updating a question (without exiting) in one (Microsoft) window and checking the outcome in another (Microsoft) window, i.e. working a bit more efficiently.

Please could you tell me:

  1. If I pass on the information contained in this forum to my site administrator, will he have enough information to add a "Save change and continue editing" button to the "Editing a Formulas Question" page?

  2. Would it not be a good idea to have both "Save changes and exit" and "Save changes (and continue editing)"** buttons at the bottom of the editing page of all question types?

** There does not seem to be automatic saving, is this so?

Thanks in advance for your help.

In reply to Dominique Bauer

Re: Is it possible to have a question type specific save and continue editing button?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Which version of Moodle are you using? All question types have this in Moodle 2.7 and 2.8 (MDL-33653).

You can try it at http://demo.moodle.net/ or http://qa.moodle.net/.

In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Tim,

Thank you for your prompt reply. We have Moodle 2.6.

Version 2.7 or 2.8 should be installed sometimes soon. I can wait.

Please could you tell me if, with versions 2.7 and 2.8, the "Save changes and continue editing" button will appear automatically on the "Editing a Formulas question" page or will it have to be installed separately?

In reply to Dominique Bauer

Re: Is it possible to have a question type specific save and continue editing button?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It appears on each question type automatically.

Screen grab showing the save changes and continue editing button

And, once you have save the question the first time, a link appears next to the button to let you easily open the preview window for that question.

Screen grab showing the new button with the preview link


Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Is it possible to have a question type specific save and continue editing button?

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Tim,

Thank you for the explanations. It look forward using this new feature.