You are here

function questions_import_validate_aiken in Quiz 6.6

Same name and namespace in other branches
  1. 6.3 includes/questions_import/questions_import.admin.inc \questions_import_validate_aiken()

@function This function checks whether the aiken import file is in proper format or not.

File

includes/questions_import/questions_import.admin.inc, line 243
Administration file for Questions Import module

Code

function questions_import_validate_aiken($file, $separator) {

  /*
  $error_msg = '';
  $row = 0;
  $lines = file($file->filepath);

  if (empty($lines) || (count($lines) < 4)) {
  return '<p>' . t('Invalid number of lines or no lines were found in @filename.', array('@filename' => $file->filename)) . '</p>';
  }

  if ($question_type = 'multichoice') {
  while (!empty($lines)) { // while not empty of file content
  while ($current_line = trim(array_shift($lines))) {
  if (empty($current_line)) {
  break;
  }
  $line[] = $current_line;
  }
  // it should have read a questions, choices and its correct answer

  if (count($line) < 4) {
  $error_msg .= '<p>' . t('Error around line : @line_number', array('@line_number' => $row)) . '</p>';
  }

  $answer = trim(array_pop($line));
  if (stristr($answer, 'ANSWER') === FALSE) {
  $error_msg .= '<p>' . t('Error around line : @line_number', array('@line_number' => $row)) . '</p>';
  }

  // now $line is left only with choices which looks like A) Moodle B) ATutor C) Claroline D) Blackboard etc
  ++$row;
  }
  }

  $error_msg .= !empty($error_msg) ? '<p>' . t('Aiken Import Failed. These lines were found to have an invalid number of fields in @filename.', array('@filename' => $file->filename)) . '</p>' : '';
  return $error_msg;
  */
}