MDL-47494 ddimageortext: Merge branch 'MOODLE_21_STABLE' into MOODLE_22_STABLE

This commit is contained in:
Tim Hunt
2012-09-28 18:13:28 +01:00
3 changed files with 18 additions and 11 deletions
@@ -217,6 +217,8 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base {
protected function drop_zones_repeated_options() {
$repeatedoptions = array();
$repeatedoptions['xleft']['type'] = PARAM_INT;
$repeatedoptions['ytop']['type'] = PARAM_INT;
$repeatedoptions['choice']['default'] = '0';
return $repeatedoptions;
}
@@ -230,19 +232,23 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base {
$allchoices = array();
for ($i=0; $i < $data['nodropzone']; $i++) {
$ytoppresent = (trim($data['drops'][$i]['ytop']) !== '');
$xleftpresent = (trim($data['drops'][$i]['ytop']) !== '');
$xleftpresent = (trim($data['drops'][$i]['xleft']) !== '');
$ytopisint = (string) clean_param($data['drops'][$i]['ytop'], PARAM_INT) === trim($data['drops'][$i]['ytop']);
$xleftisint = (string) clean_param($data['drops'][$i]['xleft'], PARAM_INT) === trim($data['drops'][$i]['xleft']);
$labelpresent = (trim($data['drops'][$i]['droplabel']) !== '');
$choice = $data['drops'][$i]['choice'];
$imagechoicepresent = ($choice !== '0');
if ($imagechoicepresent) {
if (!$ytoppresent) {
$errors["drops[$i]"] =
get_string('formerror_noytop', 'qtype_ddimageortext');
$errors["drops[$i]"] = get_string('formerror_noytop', 'qtype_ddimageortext');
} else if (!$ytopisint) {
$errors["drops[$i]"] = get_string('formerror_notintytop', 'qtype_ddimageortext');
}
if (!$xleftpresent) {
$errors["drops[$i]"] =
get_string('formerror_noxleft', 'qtype_ddimageortext');
$errors["drops[$i]"] = get_string('formerror_noxleft', 'qtype_ddimageortext');
} else if (!$xleftisint) {
$errors["drops[$i]"] = get_string('formerror_notintxleft', 'qtype_ddimageortext');
}
if ($data['dragitemtype'][$choice - 1] != 'word' &&
@@ -253,17 +259,17 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base {
if (isset($allchoices[$choice]) && !$data['drags'][$choice-1]['infinite']) {
$errors["drops[$i]"] =
get_string('formerror_multipledraginstance', 'qtype_ddimageortext', $choice);
get_string('formerror_multipledraginstance', 'qtype_ddimageortext', $choice);
$errors['drops['.($allchoices[$choice]).']'] =
get_string('formerror_multipledraginstance', 'qtype_ddimageortext', $choice);
get_string('formerror_multipledraginstance', 'qtype_ddimageortext', $choice);
$errors['drags['.($choice-1).']'] =
get_string('formerror_multipledraginstance2', 'qtype_ddimageortext', $choice);
get_string('formerror_multipledraginstance2', 'qtype_ddimageortext', $choice);
}
$allchoices[$choice] = $i;
} else {
if ($ytoppresent || $xleftpresent || $labelpresent) {
$errors["drops[$i]"] =
get_string('formerror_noimageselected', 'qtype_ddimageortext');
get_string('formerror_noimageselected', 'qtype_ddimageortext');
}
}
}
@@ -36,7 +36,6 @@ abstract class qtype_ddtoimage_edit_form_base extends question_edit_form {
const START_NUM_ITEMS = 6;
const ADD_NUM_ITEMS = 3;
/**
*
* Options shared by all file pickers in the form.
@@ -38,9 +38,11 @@ $string['dropzoneheader'] = 'Drop zones';
$string['formerror_disallowedtags'] = 'You have used html tags here that are not allowed in a draggable text drag item type.';
$string['formerror_noallowedtags'] = 'No html tags are allowed in this text which is the alt text for a draggable image';
$string['formerror_noytop'] = 'You must provide a value for the y coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
$string['formerror_noxleft'] = 'You must provide a value for the y coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
$string['formerror_noxleft'] = 'You must provide a value for the x coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
$string['formerror_nofile'] = 'You need to upload or select a file to use here.';
$string['formerror_nofile3'] = 'You need to select an image file here, or delete the associated label and uncheck the infinite checkbox.';
$string['formerror_notintytop'] = 'The y coords must be an integer.';
$string['formerror_notintxleft'] = 'The x coords must be an integer.';
$string['formerror_multipledraginstance'] = 'You have selected this image {$a} more than once as the correct choice for a drop zone but it is not marked as being an infinite drag item.';
$string['formerror_multipledraginstance2'] = 'You have selected this image more than once as the correct choice for a drop zone but it is not marked as being an infinite drag item.';
$string['formerror_noimageselected'] = 'You need to select a drag item to be the correct choice for this drop zone.';