A code autograder for student homework submissions
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

64 rindas
1.5 KiB

  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