Problems with Item Analysis downloading into Excel

Problems with Item Analysis downloading into Excel

by Steven Geggie -
Number of replies: 21
When I try to export item analysis into Excel, I get the following error in Excel...

"Damage to the file was so extensive that repairs were not possible.  Excel attempted to recover your formuloas and values, but some data may have been lost or corrupted."

Can anyone help?

Attachment moodle_error.JPG
Average of ratings: -
In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1) Which version of Moodle?

2) If you save the xls file to your hard disc, then open it in a text editor, you will probably see a PHP error message. If you tell us the error message, we are more likely to be able to help.
In reply to Tim Hunt

Re: Problems with Item Analysis downloading into Excel

by Steven Geggie -
I did not see any PHP messages when I opened in a text editor...

Attached is the excel file.
In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Jean-Michel Védrine -
I just checked on my production website upgraded 2 weeks ago to Moodle 1.6.2 + stable and surprisingly the download to Excel isn't woorking both in the Overview and Item Analysis reports triste (but it is working in the detailed responses report sourire )
- as Steven said, I don't see any error in the file's content with notepad, must be something else ...
- can other Moodle users of 1.6.2+ and 1.7 versions test to see if the download is working on their websites (no need to test for olders Moodle versions)
- Tim, has any change been made to this feature recently ? All reports were originally using very similar code for the download version (Enrique Castro is the original author of the Item analysis download to Excel code, but I have somewhat modified it in the past, and used it as a source of inspiration when I wrote the download to Excel code for the other reports)
- I will study the problem as soon as I can but I don't think I will be able to look at it before next week-end
In reply to Jean-Michel Védrine

Re: Problems with Item Analysis downloading into Excel

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I don't believe that the Excel export part got changed.

Some of the database code was touched in 1.7dev to make it work on MSSQL and Oracle, but that does not affect Moodle 1.6.

We are, of course, using an Excel export library, and I don't know if they updated the version of that. I didn't see it happen.

Or Microsoft might have issued an Office update, but I doubt that would change the file format.

I'm baffled.

It is not the end of the world, since Excel happily opens CSV or tab delimited files, which you can also export.

But if anyone has a chance to investigate this furter, I would be most grateful.
In reply to Tim Hunt

Re: Problems with Item Analysis downloading into Excel

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

There is obviously something wrong with the Excel export in latest updated Moodle 1.6.2+ (just updated today, Oct. 4th).

I am getting exactly the same error message as mentioned by Steven (in French):

Journal de réparation de fichiers Microsoft Office Excel
Des erreurs ont été détectées dans le fichier 'C:\DOCUME~1\Joseph\LOCALS~1\Temp\AM1SE_Freedman_Oral_Comprehension.xls'
Liste des réparations :
Le fichier était trop endommagé pour pouvoir être réparé. Excel a essayé de récupérer vos formules et valeurs, mais certaines données ont peut-être été perdues ou endommagées.

In fact, I am also getting the same error when trying to import as an Excel file a Grades table!

On the other hand, as Tims says, the text format still works and can be imported into Excel.

Joseph

In reply to Joseph Rézeau

Re: Problems with Item Analysis downloading into Excel

by Ger Tielemans -

..or is it again the headerinformation that does not support IE?

The studentlist-pdf from University of Florence has a fpdf.lib version that discriminates between IE and not IE browsers and sends different headers, works for me. (type florence in the forums to find it..)

In reply to Ger Tielemans

Re: Problems with Item Analysis downloading into Excel

by Steven Geggie -
I use Firefox and get the same result.
In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Ger Tielemans -

I understand that is has soemthing to do with the PHP version..

We now have php 4.4.4 and iconv 2.3.5 and.. Excel works now fine for grades, but not for quiz reports.

In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Ger Tielemans -

I understand that is has soemthing to do with the PHP version..

We now have php 4.4.4 and iconv 2.3.5 and.. Excel works now fine for grades, but not for quiz reports.

In reply to Tim Hunt

Re: Problems with Item Analysis downloading into Excel

by Jean-Michel Védrine -
Well,
Since I upgraded my production website 2 weeks ago for Moodle 1.63 + to Moodle 1.7+, I am having problem in all Excel daownloads (not only the quiz module but also the gradebook). I made a lot of tests and I am nearly convinced that
  • the problem isn't in the quiz module (or the gradebook)'s code but in the Excel library
  • people using only US characters may not see the problem as all Excel downloads containing only ascii 0-127 characters were always OK in my tests (If anybody noted the problem in a test containing only ascii 0-127 characters, please contact me)
  • maybe it has something to do with characters translation to UTF-16LE and the libraries iconv and mbstring used for that translation (but I am not 100% sure of that ...)
  • In my particular case as my hosting compagny (totalchoice) has only mbstring installed and not iconv this may be part of the problem
For all Moodle users having the same problem, until a proper fix is available, I suggest to download the data as text and import it into excel.
This works well for gradebook or the overview report but is less than ideal for item analysis and detailed responses
In reply to Jean-Michel Védrine

Re: Problems with Item Analysis downloading into Excel

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ah, that sounds like a very likely explanation.

What excel library are we using? Is there a more up-to-date version of it that the one we are curretnly using, which copes with UTF-8 better?

Now we know what is going on, this should be fixable.
In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Judith Rutschman -

i get a similar error message.

Judith Rutschman

In reply to Judith Rutschman

Re: Problems with Item Analysis downloading into Excel

by Dr S Bhatia -
If you save it into text, then it exports in a tab delimited format which can be imported into excel on your local machine smile
In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Elaine Short -

I get the same error message but only when I try and download ALL participants (144 student results in my most recent download) to an Excel file. If I split the participants into class groups and download each separately there is no problem. It looks as though approximately the first 100-120 are OK but the others have missing names and/or result total. Is there a problem with file size perhaps ?

In reply to Elaine Short

Re: Problems with Item Analysis downloading into Excel

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If the problem in this thread: http://moodle.org/mod/forum/discuss.php?d=51350 related to the problem you are seeing?
In reply to Tim Hunt

Re: Problems with Item Analysis downloading into Excel

by Chris Gibson -
I've got the same problem. Well... I guess it is: opening the Excel file in OpenOffice has a lot of '*** ERROR IN SST ***' in the cells.

Attempting a bit of a debug, I tried re-ordering the SQL query to see if it was always the same entries that got corrupted : it wasn't. Nor was it the entries on lines always on X,Y or Z.

To save my users having to download the text file, rename it to a .csv file and opening it again in Excel I did the following nasty hack:

Change:
elseif ($download=='CSV') {
$filename .= ".txt"

To:
elseif ($download=='CSV') {
$filename .= ".csv"


In reply to Steven Geggie

Re: Problems with Item Analysis downloading into Excel

by Jean-Michel Védrine -
Hello,
Can all Moodle users having some problems with Excel downloads post here :
  1. the version of PHP their server is using
  2. if PHP was compiled with iconv enabled (if I remember well, iconv is installed by default for PHP versions > 5.0)
  3. if PHP was compiled with mbstring option enabled
To answer to questions 2 and 3 look at to the phpinfo() output, or if you hosting provided has disabled phpinfo, ask him about iconv and mbstring, or use a small script like :
<?php
if (!function_exists('iconv')) {
echo 'iconv is not installed';
}
if (!function_exists('mb_strlen')) {
echo 'mbstring is not installed';
}
?>
In reply to Jean-Michel Védrine

Re: Problems with Item Analysis downloading into Excel

by Jean-Michel Védrine -
I forgot to answer my own questions :
my PHP version is 4.4.4
iconv is not installed
mbstring is installed
I have problems with Excel downloads both in quiz reports and in gradebook but not always, some downloads are OK. The only pattern I was able to find is that all downloads without any french accented characters are OK but I don't have quiz with a lot of attempts in that case.
In reply to Jean-Michel Védrine

Re: Problems with Item Analysis downloading into Excel

by Chris Gibson -
PHP 5.1.6
iconv installed
mbstring installed
(Moodle 1.6.1)

By the way, you don't need Jean-Michels script of you have access to the moodle admin area: there's an 'Environment' link at the bottom that tells you this information.
In reply to Chris Gibson

Re: Problems with Item Analysis downloading into Excel

by James Steinbach -

Our regular system:
php 4.3.11
iconv OK
mbstring OK
Moodle 1.6.1

Also a trial system:
php 4.3.11
iconv OK
mbstring OK
Moodle 1.7

Item analysis exports straight to Excel (2002) fine on both.  Hope this helps.  smile

In reply to Jean-Michel Védrine

Re: Problems with Item Analysis downloading into Excel

by Jean-Michel Védrine -
I had some success with the fix given in the tracker for MDL-5472:
in the lib/excellib.class.php file, comment the 2 lines

// $this->pear_excel_workbook->setVersion(8);

and

// $str = $textlib->convert($str, current_charset(), 'utf-16le');

all downloads appear to be OK now.
The only drawback of this method is that all special chars are left utf-8 encoded and are not recognized as such by Excel some for instance é become é, ... but as I already have a macro to convert such characters, it will works for me until we find a better way.