title: creating csv file to upload to moodle
body: <p>Edit: I have tried changing the PHP_EOL to "\n",
  tried creating the file on the server using fputcsv and then download it to the user
  and tried to create my csv file using this approach:</p>
  
  <pre><code>        $callback = function() use ($grades)
      {
          $FH = fopen('php://output', 'w');
          $csv_headers = "Identifier,Email addres,Status,Grade,Scale,Grade can be changed,Last modified (submission),Last modified (grade),Feedback comments";
          fputcsv($FH,explode(',',$csv_headers));
  
          foreach ($grades as $grade) {
              $moodle_stud_id = $grade-&gt;moodle_stud_id;
              $points = $grade-&gt;grade;
              $csv_line = "Participant ".$moodle_stud_id.",,,".$points.",,Yes,,,,";
              fputcsv($FH,explode(',',$csv_line));
          }
          fclose($FH);
      };
  return Response::stream($callback, 200, $headers);
  </code></pre>
  
  <p>all giving back the same result, the file wont be accepted in Moodle unless I open it on my computer and save it, any ideas?</p>
  
  <p>end of edit</p>
  
  <p>I'm using a web application with laravel framework to create a csv file which a user can download, and use that cav file to upload data to another system - to be specific it's a csv file containing students grades to be uploaded into moodle.</p>
  
  <p>If i download the file from my system. and try to upload it to moodle, the moodle doesnt recognize the grades, and says there are no grades to update</p>
  
  <p>But. if i download the file from my system, open it save it and close it, and then trying to upload to moodle - then everything works great</p>
  
  <p>any ideas?
  this is the way I'm creating the csv file:</p>
  
  <pre><code>  $headers = array(
          'Content-Type' =&gt; 'csv',
          'Content-Disposition' =&gt; 'attachment; filename="grades.csv"',
      );
      $output = implode(",", array('Identifier', 'Email address', 'Status','Grade','Scale','Grade can be changed','Last modified (submission)','Last modified (grade)','Feedback comments'));
      $output .= PHP_EOL;
  foreach ($grades as $grade) {
      $output .= implode(",", array("Participant ".$moodle_stud_id,'','',$grade,'','Yes','','','','')); // append each row
      $output .= PHP_EOL;
  }
  return Response::make($output, 200, $headers);
  </code></pre>