public function validation($data, $files)
 {
     $maxcrossout = $this->get_strategysetting(strategy::MAXZERO);
     $totalpoints = $this->get_strategysetting(strategy::TOTALPOINTS);
     $errors = parent::validation($data, $files);
     if (!array_key_exists('data', $data) or count($data['data']) < 2) {
         return $errors;
     }
     $impossibles = 0;
     $ratings = $data['data'];
     $currentpoints = 0;
     foreach ($ratings as $rating) {
         if ($rating['rating'] == 0) {
             $impossibles++;
         }
         $currentpoints += $rating['rating'];
     }
     if ($impossibles > $maxcrossout) {
         foreach ($ratings as $cid => $rating) {
             if ($rating['rating'] == 0) {
                 $errors['data[' . $cid . '][rating]'] = get_string(strategy::STRATEGYID . '_max_count_zero', ratingallocate_MOD_NAME, $maxcrossout);
             }
         }
     }
     if ($currentpoints != $totalpoints) {
         foreach ($ratings as $cid => $rating) {
             $errors['data[' . $cid . '][rating]'] = get_string(strategy::STRATEGYID . '_incorrect_totalpoints', ratingallocate_MOD_NAME, $totalpoints);
         }
     }
     return $errors;
 }
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $mintickyes = $this->get_strategysetting(strategy::MINTICKYES);
     if (!array_key_exists('data', $data) or count($data['data']) < 2) {
         return $errors;
     }
     $checkedaccept = 0;
     $ratings = $data['data'];
     foreach ($ratings as $rating) {
         if ($rating['rating'] == 1) {
             $checkedaccept++;
         }
     }
     if ($checkedaccept < $mintickyes) {
         foreach ($ratings as $cid => $rating) {
             if ($rating['rating'] == 0) {
                 $errors['data[' . $cid . '][rating]'] = get_string(strategy::STRATEGYID . '_error_mintickyes', ratingallocate_MOD_NAME, $mintickyes);
             }
         }
     }
     return $errors;
 }
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $usedchoices = array();
     // no data exists, so skip
     if (!array_key_exists('choice', $data)) {
         return $errors;
     }
     foreach ($data['choice'] as $choiceid => $choice) {
         if (array_key_exists($choice, $usedchoices)) {
             $errors['choice[' . $choiceid . ']'] = get_string(strategy::STRATEGYID . '_use_only_once', ratingallocate_MOD_NAME);
         }
         $usedchoices[$choice] = true;
     }
     return $errors;
 }
 public function validation($data, $files)
 {
     $maxno = $this->get_max_amount_of_nos();
     $errors = parent::validation($data, $files);
     if (!array_key_exists('data', $data) or count($data['data']) < 2) {
         return $errors;
     }
     $impossibles = 0;
     $ratings = $data['data'];
     foreach ($ratings as $rating) {
         if (key_exists('rating', $rating) && $rating['rating'] == 0) {
             $impossibles++;
         }
     }
     if ($impossibles > $maxno) {
         foreach ($ratings as $cid => $rating) {
             if ($rating['rating'] == 0) {
                 $errors['radioarr_' . $cid] = get_string($this->get_max_nos_string_identyfier(), ratingallocate_MOD_NAME, $maxno);
             }
         }
     }
     return $errors;
 }