Sha256: 629a57ccb3282392c95b8069864ce3b948ff1fda3b23076fd3ef79ddb7c29c1b

Contents?: true

Size: 814 Bytes

Versions: 12

Compression:

Stored size: 814 Bytes

Contents

# frozen_string_literal: true

require_relative 'resume_array_formatter'

##
# Format data to Moodle CSV
class MoodleCSVFormatter < ResumeArrayFormatter
  ##
  # initialize instance
  # @param report (Report)
  def initialize(report)
    super(report)
    @data = {}
  end

  ##
  # Process internal data and generates data with format
  def process
    build_data
    process_cases
    deinit
  end

  private

  def process_cases
    # MoodleID, Grade, Feedback
    w "MoodleID, TeutonGrade, TeutonFeedback\n"
    @data[:cases].each do |line|
      moodle_id = line[:moodle_id]
      moodle_id = line[:moodle_id].split(',') if moodle_id.class == String
      moodle_id.each do |id|
        w "#{id.strip},#{line[:grade]}," \
          "#{line[:moodle_feedback]}\n" unless line[:skip]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
teuton-2.3.6 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.3.5 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.3.4 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.3.3 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.3.2 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.3.1 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.2.2 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.1.11 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.1.10 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.1.9 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.1.8 lib/teuton/report/formatter/moodle_csv_formatter.rb
teuton-2.1.8dev1 lib/teuton/report/formatter/moodle_csv_formatter.rb