form_set_error('upload','You must select a valid file to upload.');
}
//there is a bug in Drupal file validator, refer http://api.drupal.org/api/function/file_validate_extensions it Bypass validation for uid = 1 so using custom validation functions which is same as drupal file_validate_extensions but it does not Bypass for uid = 1
return'<p>'.t('Invalid number of lines or no lines were found in @filename.',array('@filename'=>$file->filename)).'</p>';
}
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
foreach($lineas$l){
// yet to add validation code
}
++$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;
}
/*
* @function
* This function checks whether the file has enough number of fields
* This function checks whether the csv import file is in proper format or not.
$error_msg.=!empty($error_msg)?'<p>'.t('Import Failed. These lines were found to have an invalid number of fields in @filename.',array('@filename'=>$file->filename)).'</p>':'';
return$error_msg;
$error_msg.=!empty($error_msg)?'<p>'.t('CVS Import Failed. These lines were found to have an invalid number of fields in @filename.',array('@filename'=>$file->filename)).'</p>':'';