diff --git a/grade/grading/form/rubric/js/rubriceditor.js b/grade/grading/form/rubric/js/rubriceditor.js index 6b9137a4e0a..a40533c4d33 100644 --- a/grade/grading/form/rubric/js/rubriceditor.js +++ b/grade/grading/form/rubric/js/rubriceditor.js @@ -143,7 +143,7 @@ M.gradingform_rubriceditor.buttonclick = function(e, confirmed) { elements_str = '#rubric-'+name+' .criterion' } // prepare the id of the next inserted level or criterion - if (action == 'addcriterion' || action == 'addlevel') { + if (action == 'addcriterion' || action == 'addlevel' || action == 'duplicate' ) { var newid = M.gradingform_rubriceditor.calculatenewid('#rubric-'+name+' .criterion') var newlevid = M.gradingform_rubriceditor.calculatenewid('#rubric-'+name+' .level') } @@ -204,6 +204,41 @@ M.gradingform_rubriceditor.buttonclick = function(e, confirmed) { dialog_options['message'] = M.util.get_string('confirmdeletecriterion', 'gradingform_rubric') M.util.show_confirm_dialog(e, dialog_options); } + } else if (chunks.length == 4 && action == 'duplicate') { + // DUPLICATE CRITERION + var levelsdef = [], levelsscores = [0], levidx = 1; + var parentel = Y.one('#'+name+'-criteria'); + if (parentel.one('>tbody')) { parentel = parentel.one('>tbody'); } + + var source = Y.one('#'+name+'-criteria-'+chunks[2]); + if (source.all('.level')) { + var lastcriterion = source.all('.level'); + for (levidx=0;levidx 'criterion'. $criterion['class'], 'id' => '{NAME}-criteria-{CRITERION-id}')); if ($mode == gradingform_rubric_controller::DISPLAY_EDIT_FULL) { $criteriontemplate .= html_writer::start_tag('td', array('class' => 'controls')); - foreach (array('moveup', 'delete', 'movedown') as $key) { + foreach (array('moveup', 'delete', 'movedown', 'duplicate') as $key) { $value = get_string('criterion'.$key, 'gradingform_rubric'); $button = html_writer::empty_tag('input', array('type' => 'submit', 'name' => '{NAME}[criteria][{CRITERION-id}]['.$key.']', 'id' => '{NAME}-criteria-{CRITERION-id}-'.$key, 'value' => $value, 'title' => $value, 'tabindex' => -1)); diff --git a/grade/grading/form/rubric/styles.css b/grade/grading/form/rubric/styles.css index 35b22bf83d0..b889762d332 100644 --- a/grade/grading/form/rubric/styles.css +++ b/grade/grading/form/rubric/styles.css @@ -95,9 +95,11 @@ /* replace buttons with images */ .gradingform_rubric.editor .delete input, +.gradingform_rubric.editor .duplicate input, .gradingform_rubric.editor .moveup input, .gradingform_rubric.editor .movedown input{text-indent: -1000em;cursor:pointer;border:none;} .gradingform_rubric.editor .criterion .controls .delete input {width:12px;height:12px;background: transparent url([[pix:t/delete]]) no-repeat center top; margin: .3em .3em 0 .3em;} +.gradingform_rubric.editor .criterion .controls .duplicate input {width:12px;height:12px;background: transparent url([[pix:t/copy]]) no-repeat center top; margin: .3em .3em 0 .3em;} .gradingform_rubric.editor .levels .level .delete input {width:12px;height:16px;background: transparent url([[pix:t/delete]]) no-repeat center center; } .dir-rtl .gradingform_rubric.editor .levels .level .delete input { margin-right: .45em; margin-left: 0; } .gradingform_rubric.editor .moveup input {width:12px;height:12px;background: transparent url([[pix:t/up]]) no-repeat center top; margin: .3em .3em 0 .3em; }