a weird apostrophe in excel files exported from gradebook

Re: a weird apostrophe in excel files exported from gradebook

by Stephen Edwards -
Number of replies: 0

This is a bug in the course/grades.php file. Around line 192 or so, when writing out the grade date to an excel file, it has this code:

    foreach ($studentgrades as $grade) {
        $myxls->write_string($i,$j++,strip_tags($grade));
    }

This sends all scores out as text fields rather than numeric fields, which is why the extra single-quote is being used. You can repair this like this:

    foreach ( $studentgrades as $grade ) {
        if ( is_numeric( $grade ) ) {
            $myxls->write_number( $i, $j++, $grade );
        }
        else {
            $myxls->write_string( $i, $j++, strip_tags( $grade ) );
        }
    }

I believe a fix like this has already been added to gradebook_cdc (or is present in the patch I posted to this forum), but it is easy to fix the stock gradebook this way too.