Skip to content

Commit

Permalink
making progress
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesx2013 committed May 6, 2015
1 parent cbbd5d4 commit 0de1da3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions bin/ruql
Expand Up @@ -93,8 +93,8 @@ def main
['-l', '--log', Getopt::REQUIRED],
['-y', '--yaml', Getopt::REQUIRED]
)

Quiz.instance_eval opts, "#{IO.read(filename)}"
Quiz.set_yaml_file opts.delete("y") || opts.delete("yaml")
Quiz.instance_eval "#{IO.read(filename)}"
Quiz.quizzes.each { |quiz| puts quiz.render_with(renderer, opts) }
end

Expand Down
13 changes: 8 additions & 5 deletions lib/ruql/peer_review/peer_review.rb
@@ -1,22 +1,25 @@
require 'securerandom'
class PeerReview

attr_accessor :question_title, :prompts, :criterions, :name,
:url_name, :allow_file_upload, :allow_latex,
:submission_start, :submission_due,
:question_feedback_prompt, :question_feedback_default_text

def initialize(options={})
attr_accessor :yaml

def initialize(options={}, yaml={})
@prompts = []
@criterions = []

# Not sure what to do with url_name...hopefully I'll find out soon
@url_name = SecureRandom.hex
@yaml = yaml

@allow_file_upload = options[:allow_file_upload] || false
@allow_latex = options[:allow_latex] || false

start_date = options[:submission_start] || Time.now.to_s
end_date = options[:submission_end] || Time.now.to_s
start_date = @yaml[:submission_start] || Time.now.to_s
end_date = @yaml[:submission_end] || Time.now.to_s

@submission_start = Date.parse(start_date)
@submission_due = Date.parse(end_date)
Expand All @@ -34,6 +37,6 @@ def criterion(*args, &block)
end

def single_question(*args, &block)

instance_eval(&block)
end
end
22 changes: 15 additions & 7 deletions lib/ruql/quiz.rb
@@ -1,6 +1,8 @@

class Quiz
@@quizzes = []
@@yaml_file;
@quiz_yaml = {}
def self.quizzes ; @@quizzes ; end
@@default_options =
{
Expand Down Expand Up @@ -28,16 +30,16 @@ def self.quizzes ; @@quizzes ; end
attr_reader :logger
attr_accessor :title

def initialize(title, options={})
def initialize(title, yaml, options={})
@output = ''
@questions = options[:questions] || []
@title = title
@options = @@default_options.merge(options)
binding.pry
@seed = srand
@logger = Logger.new(STDERR)
@logger.level = Logger.const_get (options.delete('l') ||
options.delete('log') || 'warn').upcase
options.delete('log') || 'warn').upcase
@quiz_yaml = yaml
end

def self.get_renderer(renderer)
Expand All @@ -51,6 +53,11 @@ def render_with(renderer,options={})
@output = @renderer.output
end

def self.set_yaml_file(file)
raise "Can't read file" if file.nil? || !File.readable?(file)
@@yaml_file = YAML::load_file(file)
end

def points ; questions.map(&:points).inject { |sum,points| sum + points } ; end

def num_questions ; questions.length ; end
Expand Down Expand Up @@ -88,8 +95,10 @@ def truefalse(*args)
end

def peer_review(*args, &block)
binding.pry
q = PeerReview.new(*args)
y = @quiz_yaml.shift
raise "Cannot continue - You must have a yaml block for each peer evaluation question" if y.nil?
yaml = y[1][0]
q = PeerReview.new(*args, yaml)
q.instance_eval(&block)
@questions << q
end
Expand All @@ -106,8 +115,7 @@ def fill_in(*args, &block)
end

def self.quiz(*args, &block)
binding.pry
quiz = Quiz.new(*args)
quiz = Quiz.new(*args, @@yaml_file.shift)
quiz.instance_eval(&block)
@@quizzes << quiz
end
Expand Down
7 changes: 0 additions & 7 deletions lib/ruql/renderers/edxml_renderer.rb
Expand Up @@ -7,13 +7,6 @@ class EdXmlRenderer
attr_accessor :file, :yaml_file
def initialize(quiz,options={})
@only_question = options.delete('n') || options.delete('name')

file_name = options.delete('y') || options.delete('yaml')
if file_name
raise "Can't open file #{file_name}" unless File.readable?(file_name)
@yaml_file = YAML::load_file(File.join(__dir__, file_name))
end

@output = ''
@b = Builder::XmlMarkup.new(:target => @output, :indent => 2)
@quiz = quiz
Expand Down

0 comments on commit 0de1da3

Please sign in to comment.