public function validation($data, $files) { $errors = parent::validation($data, $files); $bgimagesize = $this->get_image_size_in_draft_area($data['bgimage']); if ($bgimagesize === null) { $errors["bgimage"] = get_string('formerror_nobgimage', 'qtype_ddmarker'); } $allchoices = array(); for ($i = 0; $i < $data['nodropzone']; $i++) { $choice = $data['drops'][$i]['choice']; $choicepresent = $choice !== '0'; if ($choicepresent) { //test coords here if ($bgimagesize !== null) { $shape = $data['drops'][$i]['shape']; $coordsstring = $data['drops'][$i]['coords']; $shapeobj = qtype_ddmarker_shape::create($shape, $coordsstring); $interpretererror = $shapeobj->get_coords_interpreter_error(); if ($interpretererror !== false) { $errors["drops[{$i}]"] = $interpretererror; } else { if (!$shapeobj->inside_width_height($bgimagesize)) { $errorcode = 'shapeoutsideboundsofbgimage'; $errors["drops[{$i}]"] = get_string('formerror_' . $errorcode, 'qtype_ddmarker'); } } } } else { if (trim($data['drops'][$i]['coords']) !== '') { $errorcode = 'noitemselected'; $errors["drops[{$i}]"] = get_string('formerror_' . $errorcode, 'qtype_ddmarker'); } } } for ($dragindex = 0; $dragindex < $data['noitems']; $dragindex++) { $label = $data['drags'][$dragindex]['label']; if ($label != strip_tags($label, QTYPE_DDMARKER_ALLOWED_TAGS_IN_MARKER)) { $errors["drags[{$dragindex}]"] = get_string('formerror_onlysometagsallowed', 'qtype_ddmarker', QTYPE_DDMARKER_ALLOWED_TAGS_IN_MARKER); } } return $errors; }
/** * Setup a drop zone object. * * @param int $no Which number drop zone this is * @param int $shape Shape of the drop zone * @param array $coords Coordinates of the zone */ public function __construct($no, $shape, $coords) { $this->no = $no; $this->shape = qtype_ddmarker_shape::create($shape, $coords); $this->coords = $coords; }