Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-35678

Grade CSV Import does not comply with RFC 4180 Standards

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4
    • Component/s: Gradebook
    • Labels:
    • Testing Instructions:
      Hide

      Pre-requisites

      • A course with a couple of assignment modules added.
      • Enrolled students.

      Download the gradebook

      1. Select a course.
      2. Go to [Settings ► Course administration ► Grades ► Export ► Plain text file]
      3. Tick "include feedback in export" and then submit.
      4. You will see a preview of what you are about to download. Click "Download".
      5. Save the file to your machine.

      Alter the downloaded csv file.

      1. Open the csv file in the editor of your choice.
      2. Alter the grades to some or all of the assignments.
      3. Provide feedback to some of the students. Enter in commas and new lines.
      4. Save the file (Make sure to keep it in csv format if you are using excel or Open office).

      Upload the csv file.

      1. Go to [Settings ► Course administration ► Grades ► Import ► CSV file]
      2. Upload your altered csv file.
      3. Make sure that "Separator" is selected and click "Upload grades"
        • Mapping of the csv file
        1. In the "Identify user by" section choose "Email address" for "Map from" and "useremail" for "Map to"
        2. In the "Grade item mappings" section map the assignment grades with the assignment in 'Grade items'.
        3. In the "Grade item mappings" section map the assignment feedback with the assignment in 'Comments'.
      4. Click "Upload grades".
      • You should see a message that says "Grade import success"
      • Click "Continue and observe that the grades and feeback are present
      Show
      Pre-requisites A course with a couple of assignment modules added. Enrolled students. Download the gradebook Select a course. Go to [Settings ► Course administration ► Grades ► Export ► Plain text file] Tick "include feedback in export" and then submit. You will see a preview of what you are about to download. Click "Download". Save the file to your machine. Alter the downloaded csv file. Open the csv file in the editor of your choice. Alter the grades to some or all of the assignments. Provide feedback to some of the students. Enter in commas and new lines. Save the file (Make sure to keep it in csv format if you are using excel or Open office). Upload the csv file. Go to [Settings ► Course administration ► Grades ► Import ► CSV file] Upload your altered csv file. Make sure that "Separator" is selected and click "Upload grades" Mapping of the csv file In the "Identify user by" section choose "Email address" for "Map from" and "useremail" for "Map to" In the "Grade item mappings" section map the assignment grades with the assignment in 'Grade items'. In the "Grade item mappings" section map the assignment feedback with the assignment in 'Comments'. Click "Upload grades". You should see a message that says "Grade import success" Click "Continue and observe that the grades and feeback are present
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-35678-master

      Description

      The grade CSV import functionality still does NOT comply with the RFC 4180 standards, even though there is an almost identical issue that has been closed (MDL-25938).

      MDL-25938 was set to closed(duplicate) based on MDL-34075 which doesn't actually resolve the problem as the gradebook makes no use whatsoever of the csvlib, which is what's been fixed.

      Indications it's still broken (taken from git.moodle.org on 27-09-2012):

      grade/import/csv/index.php
      96     $headers = fgets($fp, GRADE_CSV_LINE_LENGTH);
      97     $header = explode($csv_delimiter, $headers);
      
      132     // --- get header (field names) ---
      133     $header = explode($csv_delimiter, fgets($fp, GRADE_CSV_LINE_LENGTH));
      
      147         $lines = explode($csv_delimiter, fgets($fp, GRADE_CSV_LINE_LENGTH));
      
      175         // --- get header (field names) ---
      176         $header = explode($csv_delimiter, clean_param(fgets($fp,GRADE_CSV_LINE_LENGTH), PARAM_RAW));
      
      223         // read the first line makes sure this doesn't get read again
      224         $header = explode($csv_delimiter, fgets($fp, GRADE_CSV_LINE_LENGTH));
      
      231             $line = explode($csv_delimiter, fgets($fp, GRADE_CSV_LINE_LENGTH));
      

      None of those lines will properly decode a CSV record that
      a) contains a comma as part of it's data
      b) is a multi-line record

      Either use the built in CSV library or replace all of those calls to fgetcsv.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    3/Dec/12