MDL-33653 questions, a way to save changes and continue editing

This commit is contained in:
M Kassaei
2014-03-07 12:42:51 +00:00
committed by Tim Hunt
parent 0a489777fc
commit 7756e2bc85
6 changed files with 39 additions and 15 deletions
+2
View File
@@ -230,6 +230,7 @@ $string['novirtualquestiontype'] = 'No virtual question type for question type {
$string['numqas'] = 'No. question attempts';
$string['numquestions'] = 'No. questions';
$string['numquestionsandhidden'] = '{$a->numquestions} (+{$a->numhidden} hidden)';
$string['openpreviewfromform'] = '{$a} Preview';
$string['orphanedquestionscategory'] = 'Questions saved from deleted categories';
$string['orphanedquestionscategoryinfo'] = 'Occasionally, typically due to old software bugs, questions can remain in the database even though the corresponding question category has been deleted. Of course, this should not happen, it has happened in the past on this site. This category has been created automatically, and the orphaned questions moved here so that you can manage them. Note that any images or media files used by these questions have probably been lost.';
$string['page-question-x'] = 'Any question page';
@@ -270,6 +271,7 @@ $string['questionuse'] = 'Use question in this activity';
$string['questionvariant'] = 'Question variant';
$string['reviewresponse'] = 'Review response';
$string['save'] = 'Save';
$string['savechangesandcontinueediting'] = 'Save changes and continue editing';
$string['saveflags'] = 'Save the state of the flags';
$string['selectacategory'] = 'Select a category:';
$string['selectaqtypefordescription'] = 'Select a question type to see its description.';
+8
View File
@@ -263,6 +263,14 @@ if ($mform->is_cancelled()) {
// Purge this question from the cache.
question_bank::notify_question_edited($question->id);
// If we are saving and continuing to edit the question.
if (!empty($fromform->updatebutton)) {
if ($question->id !== 0) {
$url->param('id', $question->id);
}
redirect($url);
}
if ($qtypeobj->finished_edit_wizard($fromform)) {
if ($inpopup) {
echo $OUTPUT->notification(get_string('changessaved'), '');
+18 -14
View File
@@ -121,7 +121,7 @@ abstract class question_edit_form extends question_wizard_form {
* override this method and remove the ones you don't want with $mform->removeElement().
*/
protected function definition() {
global $COURSE, $CFG, $DB;
global $COURSE, $CFG, $DB, $OUTPUT;
$qtype = $this->qtype();
$langfile = "qtype_$qtype";
@@ -236,21 +236,25 @@ abstract class question_edit_form extends question_wizard_form {
$mform->setType('makecopy', PARAM_INT);
$buttonarray = array();
if (!empty($this->question->id)) {
// Editing question.
if ($this->question->formoptions->canedit) {
$buttonarray[] = $mform->createElement('submit', 'submitbutton',
get_string('savechanges'));
}
$buttonarray[] = $mform->createElement('cancel');
} else {
// Adding new question.
$buttonarray[] = $mform->createElement('submit', 'submitbutton',
get_string('savechanges'));
$buttonarray[] = $mform->createElement('cancel');
$buttonarray[] = $mform->createElement('submit', 'updatebutton',
get_string('savechangesandcontinueediting', 'question'));
if (!empty($this->question->id) && $this->question->formoptions->canedit) {
// Build the icon.
$url = question_preview_url($this->question->id);
$image = $OUTPUT->pix_icon('t/preview', '');
$action = new popup_action('click', $url, 'questionpreview',
question_preview_popup_params());
$previewlink = $OUTPUT->action_link($url, get_string('openpreviewfromform', 'question', $image), $action);
$buttonarray[] = $mform->createElement('static', 'previewlink', '', $previewlink);
}
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');
$mform->closeHeaderBefore('buttonar');
$this->add_action_buttons(true, get_string('savechanges'));
if ((!empty($this->question->id)) && (!($this->question->formoptions->canedit ||
$this->question->formoptions->cansaveasnew))) {
+5
View File
@@ -158,3 +158,8 @@ body.path-question-type .fitem_fgroup .accesshide {font: inherit;left: 0;positio
.dir-rtl #qtypechoicecontainer #chooseqtype .instruction,
.dir-rtl #qtypechoicecontainer #chooseqtype .qtypesummary {right: 60%;left: 0%; border-left:0;border-right: 1px solid grey;}
#qtypechoicecontainer #chooseqtype .qtypeoption {padding-right: 0.3em;}
body.path-question-type .mform fieldset.hidden {
padding: 0;
margin: 0.7em 0 0;
}
@@ -460,3 +460,8 @@ a#hidebankcmd {
.que label {
display: inline;
}
body.path-question-type .mform fieldset.hidden {
padding: 0;
margin: 0.7em 0 0;
}
File diff suppressed because one or more lines are too long