A code autograder for student homework submissions
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rakefile 1.5 KiB

há 8 anos
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 {} }
  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
  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. run { |cli| cli.list }
  30. end
  31. task :roster do
  32. course, rosterfile, options = parse_args 2, { :semester => :string }
  33. run { |cli| cli.roster course, options[:semester], rosterfile }
  34. end
  35. task :grade do
  36. course, assignment, options = parse_args 2,
  37. { :semester => :string, :students => :array, :due => :time,
  38. :fetch => :bool, :regrade => :bool }
  39. run { |cli| cli.grade course, options[:semester], assignment, options }
  40. end
  41. task :commit do
  42. course, assignment, options = parse_args 2,
  43. { :semester => :string, :students => :array }
  44. run { |cli| cli.commit course, options[:semester], assignment, options }
  45. end
  46. task :clean do
  47. run { |cli| cli.clean }
  48. end
  49. task :clobber do
  50. run { |cli| cli.clobber }
  51. end