@@ -31,18 +31,18 @@ To show all known classes, semesters, and assignments: | |||
rake list | |||
To load a roster (a newline-delimited list of student identifiers) for a | |||
specific semester: | |||
To load a roster (a newline-delimited list of student identifiers) for the | |||
current semester of a particular course (e.g. "cs123"): | |||
rake roster cs123 myroster.csv semester=sp16 | |||
rake roster cs123 myroster.csv | |||
To load a roster for the current semester: | |||
You can also specify the semester: | |||
rake roster cs123 myroster.csv | |||
rake roster cs123 myroster.csv sp16 | |||
### Grading | |||
To grade a particular assignment (e.g., "mp1" for the "cs123" course): | |||
To grade a particular assignment (e.g., "mp1" for "cs123"): | |||
rake grade cs123 mp1 | |||
@@ -88,5 +88,5 @@ repo has changed since the last run. To forcibly regrade: | |||
rake grade cs123 mp1 regrade=yes | |||
You can combine these arguments in any meaningful way. `semester` is available | |||
for `roster` and `commit`, and and `students` is available for `commit`. | |||
You can combine these arguments in any meaningful way. `semester` and | |||
`students` are also available options for `commit`. |
@@ -8,19 +8,15 @@ module KGrader | |||
@fs = Filesystem.new dir | |||
end | |||
def 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}" | |||
def list(course, semester) | |||
if semester | |||
puts Course.new(@fs, course).roster(semester).students | |||
elsif course | |||
list_course course, 0 | |||
else | |||
@fs.courses.each do |name| | |||
puts "course: #{name}" | |||
list_course name, 1 | |||
end | |||
end | |||
end | |||
@@ -58,6 +54,21 @@ module KGrader | |||
end | |||
private | |||
def list_course(name, indent = 0) | |||
course = Course.new(@fs, name) | |||
pad = ' ' * indent | |||
puts "#{pad}rosters:" | |||
course.rosters.each do |roster| | |||
puts "#{pad} - #{roster.semester} (#{roster.students.size} students)" | |||
end | |||
puts "#{pad}assignments:" | |||
course.assignments.each do |assignment| | |||
puts "#{pad} - #{assignment}" | |||
end | |||
end | |||
def reset_jail | |||
FileUtils.rm_rf @fs.jail | |||
FileUtils.mkdir @fs.jail | |||
@@ -1,7 +1,7 @@ | |||
require 'time' | |||
module KGrader | |||
def self.parse_args(raw, num, keywords) | |||
def self.parse_args(raw, range, keywords) | |||
args = [] | |||
options = {} | |||
@@ -27,8 +27,9 @@ module KGrader | |||
end | |||
end | |||
raise ArgumentError, "too few arguments" if args.size < num | |||
raise ArgumentError, "too many arguments" if args.size > num | |||
raise ArgumentError, "too few arguments" if args.size < range.begin | |||
raise ArgumentError, "too many arguments" if args.size > range.end | |||
args[range.end - 1] = nil unless args.size == range.end | |||
return args, options | |||
end | |||
@@ -12,7 +12,7 @@ end | |||
def parse_args(num, keywords = {}) | |||
args, options = KGrader::parse_args ARGV.drop(1), num, keywords | |||
args.each { |arg| task arg.to_sym {} } | |||
args.each { |arg| task arg.to_sym {} unless arg.nil? } | |||
args + [options] | |||
rescue KGrader::KGraderError => err | |||
die err | |||
@@ -22,8 +22,8 @@ task :default => :help do ; end | |||
task :help do | |||
puts %{usage: | |||
- rake list | |||
- rake roster <course> <rosterfile> [semester=<...>] | |||
- rake list [<course>] [<semester>] | |||
- rake roster <course> <rosterfile> [<semester>] | |||
- rake grade <course> <assignment> [semester=<...>] [students=<...>] | |||
[due=<...>] [fetch=<yes/no>] [regrade=<yes/no>] | |||
- rake commit <course> <assignment> [semester=<...>] [students=<...>] | |||
@@ -32,23 +32,24 @@ task :help do | |||
end | |||
task :list do | |||
run { |cli| cli.list } | |||
course, semester = parse_args 0..2 | |||
run { |cli| cli.list course, semester } | |||
end | |||
task :roster do | |||
course, rosterfile, options = parse_args 2, { :semester => :string } | |||
run { |cli| cli.roster course, options[:semester], rosterfile } | |||
course, rosterfile, semester = parse_args 2..3 | |||
run { |cli| cli.roster course, semester, rosterfile } | |||
end | |||
task :grade do | |||
course, assignment, options = parse_args 2, | |||
course, assignment, options = parse_args 2..2, | |||
{ :semester => :string, :students => :array, :due => :time, | |||
:fetch => :bool, :regrade => :bool } | |||
run { |cli| cli.grade course, options[:semester], assignment, options } | |||
end | |||
task :commit do | |||
course, assignment, options = parse_args 2, | |||
course, assignment, options = parse_args 2..2, | |||
{ :semester => :string, :students => :array } | |||
run { |cli| cli.commit course, options[:semester], assignment, options } | |||
end | |||