Преглед на файлове

Mock up assignment class.

master
Ben Kurtovic преди 8 години
родител
ревизия
eab1d5a5ff
променени са 7 файла, в които са добавени 46 реда и са изтрити 19 реда
  1. +1
    -0
      lib/kgrader.rb
  2. +15
    -0
      lib/kgrader/assignment.rb
  3. +1
    -4
      lib/kgrader/cli.rb
  4. +6
    -4
      lib/kgrader/course.rb
  5. +3
    -0
      lib/kgrader/errors.rb
  6. +16
    -8
      lib/kgrader/filesystem.rb
  7. +4
    -3
      lib/kgrader/task.rb

+ 1
- 0
lib/kgrader.rb Целия файл

@@ -1,3 +1,4 @@
require_relative 'kgrader/assignment'
require_relative 'kgrader/cli'
require_relative 'kgrader/course'
require_relative 'kgrader/errors'


+ 15
- 0
lib/kgrader/assignment.rb Целия файл

@@ -0,0 +1,15 @@
module KGrader
class Assignment
attr_reader :name

def initialize(filesystem, course, name)
@fs = filesystem
@course = course
@name = name

@config = @fs.load @fs.assignment(@course.name, @name)
rescue FilesystemError
raise AssignmentError, "unknown assignment: #{name}"
end
end
end

+ 1
- 4
lib/kgrader/cli.rb Целия файл

@@ -1,6 +1,3 @@
require_relative 'course'
require_relative 'filesystem'

module KGrader
class CLI

@@ -65,7 +62,7 @@ module KGrader

puts "#{pad}assignments:"
course.assignments.each do |assignment|
puts "#{pad} - #{assignment}"
puts "#{pad} - #{assignment.name}"
end
end



+ 6
- 4
lib/kgrader/course.rb Целия файл

@@ -1,6 +1,3 @@
require_relative 'roster'
require_relative 'task'

module KGrader
class Course
attr_reader :name
@@ -11,6 +8,7 @@ module KGrader

@config = @fs.load @fs.course_config(@name)
@rosters = {}
@assignments = {}
rescue FilesystemError
raise CourseError, "unknown or invalid course: #{name}"
end
@@ -19,6 +17,10 @@ module KGrader
@rosters[semester] ||= Roster.new @fs, self, semester
end

def assignment(name)
@assignments[name] ||= Assignment.new @fs, self, name
end

def task(semester, assignment)
Task.new @fs, self, semester, assignment
end
@@ -28,7 +30,7 @@ module KGrader
end

def assignments
@fs.assignments @name
@fs.assignments(@name).map! { |name| assignment name }
end

def current_semester


+ 3
- 0
lib/kgrader/errors.rb Целия файл

@@ -14,6 +14,9 @@ module KGrader
class CourseError < KGraderError
end

class AssignmentError < KGraderError
end

class RosterError < KGraderError
end
end

+ 16
- 8
lib/kgrader/filesystem.rb Целия файл

@@ -19,6 +19,8 @@ module KGrader
File.join @root, 'spec'
end

# -------------------------------------------------------------------------

def course(name)
File.join spec, name
end
@@ -27,24 +29,30 @@ module KGrader
File.join course(name), '_config.yml'
end

def roster(course_name, semester)
File.join desk, course_name, semester, '_roster.csv'
def assignment(courseid, name)
File.join course(courseid), name, '_config.yml'
end

def roster(courseid, semester)
File.join desk, courseid, semester, '_roster.csv'
end

# -------------------------------------------------------------------------

def courses
Dir[File.join spec, '*', ''].map! { |fn| File.basename fn }
end

def assignments(course_name)
Dir[File.join course(course_name), '*', '_config.yml'].map! do |fn|
File.basename File.dirname fn
end
def assignments(courseid)
Dir[assignment courseid '*'].map! { |fn| File.basename File.dirname fn }
end

def semesters(course_name)
Dir[roster course_name, '*'].map! { |fn| File.basename File.dirname fn }
def semesters(courseid)
Dir[roster courseid, '*'].map! { |fn| File.basename File.dirname fn }
end

# -------------------------------------------------------------------------

def load(path)
case File.extname path
when '.yml', '.yaml'


+ 4
- 3
lib/kgrader/task.rb Целия файл

@@ -5,7 +5,8 @@ module KGrader
@fs = filesystem
@course = course
@semester = semester
@assignment = assignment

@assignment = @course.assignment assignment
@students = @course.roster(@semester).students
end

@@ -18,7 +19,7 @@ module KGrader
regrade = options.fetch(:regrade, false)

# TODO
puts "Grading #{@course.name}:#{@semester} assignment #{@assignment}..."
puts "Grading #{@course.name}:#{@semester} assignment #{@assignment.name}..."
puts "- students: #{students.inspect}"
puts "- due: #{due}"
puts "- fetch: #{fetch}"
@@ -30,7 +31,7 @@ module KGrader
students &= options[:students] unless options[:students].nil?

# TODO
puts "Committing #{@course.name}:#{@semester} assignment #{@assignment}..."
puts "Committing #{@course.name}:#{@semester} assignment #{@assignment.name}..."
puts "- students: #{students.inspect}"
end
end


Зареждане…
Отказ
Запис