Moodle

Error when import questions from file located in computer

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.3
  • Fix Version/s: 1.9.5
  • Component/s: Questions
  • Labels:
    None
  • Database:
    Microsoft SQL
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

When i try import questions from a file locatted in my local computer, sometimes (9 in 10), give me this error: an error has ocurred in import process: is not possible to read import file, or file is empty.
Before i can see a window alert, saying that elements is null and refering to URL ... questions/import.php.
Sometimes the process works, and he works fine if first i upload the file into the server, and then i use it.

Activity

Hide
Tim Hunt added a comment -

(It is much easier if you save screenshots as .gif or .png files and attach the directly to the bug, instead of hiding them in a .zip file.)

Which import format are you using?

Is your import file using the UTF-8 character set. That is a requirement.

Show
Tim Hunt added a comment - (It is much easier if you save screenshots as .gif or .png files and attach the directly to the bug, instead of hiding them in a .zip file.) Which import format are you using? Is your import file using the UTF-8 character set. That is a requirement.
Hide
Pedro Almeida added a comment -

Hi Tim,

Thanks for your help.
In fact, i've carefully used UTF-8 character set in the imported file. I guess that it is not the problem, like i said before: if i first upload the file to the server, and then i use it, the process works fine.
I'm trying with the GIFT format, but the same ocurs with AIKEN...

Next time i will send the images properly, sorry.

PA

Show
Pedro Almeida added a comment - Hi Tim, Thanks for your help. In fact, i've carefully used UTF-8 character set in the imported file. I guess that it is not the problem, like i said before: if i first upload the file to the server, and then i use it, the process works fine. I'm trying with the GIFT format, but the same ocurs with AIKEN... Next time i will send the images properly, sorry. PA
Hide
Tim Hunt added a comment -

Can you attach one of your files here, so I can try importing it myself?

Show
Tim Hunt added a comment - Can you attach one of your files here, so I can try importing it myself?
Hide
Pedro Almeida added a comment -

Thanks Tim,

I'm upgrading the file...

Show
Pedro Almeida added a comment - Thanks Tim, I'm upgrading the file...
Hide
Pedro Almeida added a comment -

There is the file...

Show
Pedro Almeida added a comment - There is the file...
Hide
Tim Hunt added a comment - - edited

Naturally, it works when I try it.

Would you be able to try out a possible solution? Can you add the line of code

$this->_form->updateAttributes(array('accept-charset'=>'utf-8'));

to lib/formslib.php, just before the line

$this->set_upload_manager(new upload_manager());

(that is line 115 of formslib.php in my version.)

Then try some more uploads and see if it works.

Show
Tim Hunt added a comment - - edited Naturally, it works when I try it. Would you be able to try out a possible solution? Can you add the line of code $this->_form->updateAttributes(array('accept-charset'=>'utf-8')); to lib/formslib.php, just before the line $this->set_upload_manager(new upload_manager()); (that is line 115 of formslib.php in my version.) Then try some more uploads and see if it works.
Hide
Pedro Almeida added a comment -

Tim,

Still doesn´t working correctly.
I put the code as you said, first time have worked, then stoped working with the same error...
It seems to me that for some reason, moodle considers that this file is empty...

Show
Pedro Almeida added a comment - Tim, Still doesn´t working correctly. I put the code as you said, first time have worked, then stoped working with the same error... It seems to me that for some reason, moodle considers that this file is empty...
Hide
Tim Hunt added a comment -

Drat! I thought I had worked it out. Which web browser are you using, and which language is your operating system set to? Do you happen to know which charset it uses by default?

Show
Tim Hunt added a comment - Drat! I thought I had worked it out. Which web browser are you using, and which language is your operating system set to? Do you happen to know which charset it uses by default?
Hide
Pedro Almeida added a comment -

Tim,

I am using Internet Explorer 7, with OS XP, in english.
Moodle is using portuguese (PT).
I don´t know wich charset is used by default, i guess is Ascii.
This Moodle, has been upgrated from 1.8.?, and in at that version, all text files to upload are in UTF-8, without any problems.

Show
Pedro Almeida added a comment - Tim, I am using Internet Explorer 7, with OS XP, in english. Moodle is using portuguese (PT). I don´t know wich charset is used by default, i guess is Ascii. This Moodle, has been upgrated from 1.8.?, and in at that version, all text files to upload are in UTF-8, without any problems.
Hide
Tim Hunt added a comment -

Windows defaults to windows-1252 which is close to iso-8859-1but with a few extra characters.

The import works for me when I try it on Windows / IE7.I tried it twice.

Since you are using Microsoft SQL, can I guess that you are also using IIS instead of Apache. That might make a difference, but I don't currently have a way to test that combination.

I don't really know what to suggest now. I am stuck.

Show
Tim Hunt added a comment - Windows defaults to windows-1252 which is close to iso-8859-1but with a few extra characters. The import works for me when I try it on Windows / IE7.I tried it twice. Since you are using Microsoft SQL, can I guess that you are also using IIS instead of Apache. That might make a difference, but I don't currently have a way to test that combination. I don't really know what to suggest now. I am stuck.
Hide
Tim Hunt added a comment -

Have commited the same accept-charset="uft-8" fix to the 1.9 stable branch, so resolving now.

Show
Tim Hunt added a comment - Have commited the same accept-charset="uft-8" fix to the 1.9 stable branch, so resolving now.
Hide
Andrew Davis added a comment -

Given how unpredictable this bug appears to be and that the original reporter has never come back saying this bug is definitely fixed I'm not entirely sure we've got it. Pedro, let us know if you are still encountering this issue.

Show
Andrew Davis added a comment - Given how unpredictable this bug appears to be and that the original reporter has never come back saying this bug is definitely fixed I'm not entirely sure we've got it. Pedro, let us know if you are still encountering this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: