diff --git a/local/epfl/check-scipers b/local/epfl/check-scipers index 2118c9c..034d5c5 100755 --- a/local/epfl/check-scipers +++ b/local/epfl/check-scipers @@ -1,163 +1,163 @@ #!/usr/bin/env php $iline) { $iline = explode($options['iseparator'], $iline); // Format input_student $input_student = array(); foreach (array_keys($oformat) as $key) { switch ($key) { case 'id': $input_student[$key] = $i+1; break; default: if (array_key_exists($key, $iformat)) { $input_student[$key] = $iline[$iformat[$key]]; } else { $input_student[$key] = null; } } } # Add empty email if needed if (array_key_exists('email', $input_student) and is_null($input_student['email'])) $input_student['email'] = 'n/a'; # Add version number if needed if (array_key_exists('version', $input_student) and is_null($input_student['version'])) { $input_student['version'] = $options['oversions'][($input_student['id']-1) % $nb_of_versions]; } # fetch LDAP data $LDAP->find_by_sciper($input_student['sciper'], 'student', 1); $output_student = $LDAP->get_entries(); - if (count($output_student) == 1) { + if (is_array($output_student) && count($output_student) == 1) { $output_student = $output_student[0]; } else { $output_student = array( 'found' => 0 ); } # add some info if ((bool)$output_student['found']) { $output_student['status'] = 'OK'; } else { $output_student['status'] = 'NOT FOUND'; } # Merge info $merged_student = array_merge($input_student, $output_student); # Print line $oline = array(); foreach (array_keys($oformat) as $key) $oline[] = $merged_student[$key]; echo implode($options['oseparator'], $oline)."\n"; } # Add extra students $nb_of_extra_exams = $options['oextras']; $first_extra_id = $i+2; $current_extra = 1; for ($extra_id = $first_extra_id; $extra_id < $first_extra_id+$nb_of_extra_exams; $extra_id++) { $oline = array(); foreach (array_keys($oformat) as $key) { switch ($key) { case 'id': $oline[] = $extra_id; break; case 'sciper': $oline[] = 999000 + $current_extra; break; case 'name': $oline[] = 'Spare-'.$current_extra; break; case 'section': $oline[] = 'XXX'; break; case 'version': $oline[] = $options['oversions'][($extra_id-1) % $nb_of_versions]; break; default: $oline[] = 'n/a'; break; } } $current_extra++; echo implode($options['oseparator'], $oline)."\n"; } exit; ?>