A code autograder for student homework submissions
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rakefile 1.5 KiB

8 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. run { |cli| cli.grade course, options[:semester], assignment, options }
  41. end
  42. task :commit do
  43. course, assignment, options = parse_args 2..2,
  44. { :semester => :string, :students => :array }
  45. run { |cli| cli.commit course, options[:semester], assignment, options }
  46. end
  47. task :clean do
  48. run { |cli| cli.clean }
  49. end
  50. task :clobber do
  51. run { |cli| cli.clobber }
  52. end