Ver a proveniência

Implement more stuff

master
Ben Kurtovic há 8 anos
ascendente
cometimento
fa32007555
6 ficheiros alterados com 70 adições e 18 eliminações
  1. +20
    -11
      lib/kgrader/cli.rb
  2. +17
    -0
      lib/kgrader/course.rb
  3. +22
    -6
      lib/kgrader/filesystem.rb
  4. +6
    -0
      lib/kgrader/roster.rb
  5. +4
    -0
      lib/kgrader/util.rb
  6. +1
    -1
      spec/cs241h

+ 20
- 11
lib/kgrader/cli.rb Ver ficheiro

@@ -9,8 +9,20 @@ module KGrader
end

def list
# TODO
puts "[list]"
@fs.courses.each do |name|
puts "course: #{name}"
course = Course.new(@fs, name)

puts " rosters:"
course.rosters.each do |roster|
puts " - #{roster.semester} (#{roster.students.size} students)"
end

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

def roster(course, semester, rosterfile)
@@ -18,18 +30,15 @@ module KGrader
end

def grade(course, semester, assignment, options = {})
# TODO
# need to get default semester...
semester ||= 'DEFAULT'
task = Course.new(@fs, course).task semester, assignment
task.grade options
course = Course.new @fs, course
semester ||= course.current_semester
course.task(semester, assignment).grade options
end

def commit(course, semester, assignment, options = {})
# TODO
semester ||= 'DEFAULT'
task = Course.new(@fs, course).task semester, assignment
task.commit options
course = Course.new @fs, course
semester ||= course.current_semester
course.task(semester, assignment).commit options
end

def clean


+ 17
- 0
lib/kgrader/course.rb Ver ficheiro

@@ -20,5 +20,22 @@ module KGrader
# TODO: cache
Task.new @fs, self, semester, assignment
end

def rosters
@fs.semesters(@name).map! { |semester| roster semester }
end

def assignments
@fs.assignments @name
end

def current_semester
case @config['semesters']
when 'faspYY'
KGrader::season + DateTime.now.strftime('%y')
when 'faspYYYY'
KGrader::season + DateTime.now.strftime('%Y')
end
end
end
end

+ 22
- 6
lib/kgrader/filesystem.rb Ver ficheiro

@@ -7,8 +7,20 @@ module KGrader
@root = root
end

def desk
File.join @root, 'desk'
end

def jail
File.join @root, 'jail'
end

def spec
File.join @root, 'spec'
end

def course(name)
File.join @root, 'spec', name
File.join spec, name
end

def course_config(name)
@@ -16,15 +28,19 @@ module KGrader
end

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

def desk
File.join @root, 'desk'
def assignments(course)
Dir[File.join spec, course, '*', '_config.yml'].map! do |fn|
File.basename File.dirname fn
end
end

def jail
File.join @root, 'jail'
def semesters(course)
Dir[File.join desk, course, '*', '_roster.csv'].map! do |fn|
File.basename File.dirname fn
end
end

def load(path)


+ 6
- 0
lib/kgrader/roster.rb Ver ficheiro

@@ -1,5 +1,6 @@
module KGrader
class Roster
attr_reader :semester

def initialize(filesystem, course, semester)
@fs = filesystem
@@ -11,5 +12,10 @@ module KGrader
# TODO
puts "Loading roster for #{@course.name}:#{@semester} from [#{filename}]..."
end

def students
# TODO
["ksmith12"]
end
end
end

+ 4
- 0
lib/kgrader/util.rb Ver ficheiro

@@ -33,4 +33,8 @@ module KGrader
abort "too many arguments" if args.size > num
return args, options
end

def self.season
DateTime.now.strftime('%m').to_i <= 6 ? 'sp' : 'fa'
end
end

+ 1
- 1
spec/cs241h

@@ -1 +1 @@
Subproject commit 54398ad4a16ac3d9f7344ecf680f4dd167e05818
Subproject commit 3c6f5d050d8a66de6b3c36ce1985c225700a5c2f

Carregando…
Cancelar
Guardar