A code autograder for student homework submissions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rakefile 1.7 KiB

8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. require_relative 'lib/kgrader'
  2. def die(error)
  3. abort "fatal: [#{error.class}] #{error}"
  4. end
  5. def run
  6. yield KGrader::CLI.new Rake.application.original_dir
  7. rescue KGrader::KGraderError => err
  8. die err
  9. end
  10. def parse_args(num, keywords = {})
  11. args, options = KGrader::parse_args ARGV.drop(1), num, keywords
  12. args.each { |arg| task arg.to_sym {} unless arg.nil? }
  13. args + [options]
  14. rescue KGrader::KGraderError => err
  15. die err
  16. end
  17. task :default => :help do ; end
  18. task :help do
  19. puts %{usage:
  20. - rake list [<course>] [<semester>]
  21. - rake roster <course> <rosterfile> [<semester>]
  22. - rake grade <course> <assignment> [semester=<...>] [students=<...>]
  23. [due=<...>] [fetch=<yes/no>] [regrade=<yes/no>]
  24. - rake commit <course> <assignment> [semester=<...>] [students=<...>]
  25. - rake clean
  26. - rake clobber}
  27. end
  28. task :list do
  29. course, semester = parse_args 0..2
  30. run { |cli| cli.list course, semester }
  31. end
  32. task :roster do
  33. course, rosterfile, semester = parse_args 2..3
  34. run { |cli| cli.roster course, semester, rosterfile }
  35. end
  36. task :grade do
  37. course, assignment, options = parse_args 2..2,
  38. { :semester => :string, :students => :array, :due => :time,
  39. :fetch => :bool, :regrade => :bool }
  40. semester, students = options[:semester], options[:students]
  41. run { |cli| cli.grade course, semester, assignment, students, options }
  42. end
  43. task :commit do
  44. course, assignment, options = parse_args 2..2,
  45. { :semester => :string, :students => :array }
  46. semester, students = options[:semester], options[:students]
  47. run { |cli| cli.commit course, semester, assignment, students }
  48. end
  49. task :clean do
  50. run { |cli| cli.clean }
  51. end
  52. task :clobber do
  53. run { |cli| cli.clobber }
  54. end