diff --git a/grade/grading/form/guide/edit_form.php b/grade/grading/form/guide/edit_form.php
index 937f7344b5e..5437beeff27 100644
--- a/grade/grading/form/guide/edit_form.php
+++ b/grade/grading/form/guide/edit_form.php
@@ -51,9 +51,11 @@ class gradingform_guide_editguide extends moodleform {
$form->setType('returnurl', PARAM_LOCALURL);
// Name.
- $form->addElement('text', 'name', get_string('name', 'gradingform_guide'), array('size'=>52));
+ $form->addElement('text', 'name', get_string('name', 'gradingform_guide'),
+ array('size' => 52, 'maxlength' => 255));
$form->addRule('name', get_string('required'), 'required');
$form->setType('name', PARAM_TEXT);
+ $form->addRule('name', null, 'maxlength', 255, 'client');
// Description.
$options = gradingform_guide_controller::description_form_field_options($this->_customdata['context']);
diff --git a/grade/grading/form/guide/guideeditor.php b/grade/grading/form/guide/guideeditor.php
index da430ec9027..902834c5166 100644
--- a/grade/grading/form/guide/guideeditor.php
+++ b/grade/grading/form/guide/guideeditor.php
@@ -197,6 +197,10 @@ class moodlequickform_guideeditor extends HTML_QuickForm_input {
$errors['err_noshortname'] = 1;
$criterion['error_description'] = true;
}
+ if (strlen(trim($criterion['shortname'])) > 255) {
+ $errors['err_shortnametoolong'] = 1;
+ $criterion['error_description'] = true;
+ }
if (!strlen(trim($criterion['maxscore']))) {
$errors['err_nomaxscore'] = 1;
$criterion['error_description'] = true;
diff --git a/grade/grading/form/guide/lang/en/gradingform_guide.php b/grade/grading/form/guide/lang/en/gradingform_guide.php
index 6bbfb40a79e..a36eabc7df4 100644
--- a/grade/grading/form/guide/lang/en/gradingform_guide.php
+++ b/grade/grading/form/guide/lang/en/gradingform_guide.php
@@ -54,6 +54,7 @@ $string['err_nodescription'] = 'Student description can not be empty';
$string['err_nodescriptionmarkers'] = 'Marker description can not be empty';
$string['err_nomaxscore'] = 'Criterion max score can not be empty';
$string['err_noshortname'] = 'Criterion name can not be empty';
+$string['err_shortnametoolong'] = 'Criterion name must be less than 256 characters';
$string['err_scoreinvalid'] = 'The score given to {$a->criterianame} is not valid, the max score is: {$a->maxscore}';
$string['gradingof'] = '{$a} grading';
$string['guidemappingexplained'] = 'WARNING: Your marking guide has a maximum grade of {$a->maxscore} points but the maximum grade set in your activity is {$a->modulegrade} The maximum score set in your marking guide will be scaled to the maximum grade in the module.