Sha256: dc8b93b1c586a3676b32eb12cf486039ce78cda3d013a9f3a833ed88f78e23a8
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: false require "erb" require_relative "../application" # Transform Questions into Gift format class QuestionMoodleFormatter ## # Convert question object into gift formatted string # @param question (Question) # @return String def self.to_s(question) case question.type when :choice fractions = Application.instance.config["questions"]["fractions"] penalties = fractions # penalties = ['', '-50', '-33.33333', '-25', '-20'] # puts "[DEBUG] fractions : #{fractions}" # puts "[DEBUG] penalties : #{penalties}" penalty = penalties[question.bads.size] template = File.read(File.join(File.dirname(__FILE__), "moodle", "multichoice.erb")) when :boolean template = File.read(File.join(File.dirname(__FILE__), "moodle", "truefalse.erb")) when :ddmatch template = File.read(File.join(File.dirname(__FILE__), "moodle", "ddmatch.erb")) when :match template = File.read(File.join(File.dirname(__FILE__), "moodle", "matching.erb")) when :ordering template = File.read(File.join(File.dirname(__FILE__), "moodle", "ordering.erb")) when :short template = File.read(File.join(File.dirname(__FILE__), "moodle", "shortanswer.erb")) else warn "[ERROR] QuestionMoodleFormatter: Unknown type (#{question.type})" exit 1 end renderer = ERB.new(template) renderer.result(binding) end end
Version data entries
3 entries across 3 versions & 1 rubygems