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.

56 lines
961 B

  1. require 'yaml'
  2. module KGrader
  3. class Filesystem
  4. def initialize(root)
  5. @root = root
  6. end
  7. def desk
  8. File.join @root, 'desk'
  9. end
  10. def jail
  11. File.join @root, 'jail'
  12. end
  13. def spec
  14. File.join @root, 'spec'
  15. end
  16. def course(name)
  17. File.join spec, name
  18. end
  19. def course_config(name)
  20. File.join course(name), '_config.yml'
  21. end
  22. def courses
  23. Dir[File.join spec, '*', ''].map! { |fn| File.basename fn }
  24. end
  25. def assignments(course)
  26. Dir[File.join spec, course, '*', '_config.yml'].map! do |fn|
  27. File.basename File.dirname fn
  28. end
  29. end
  30. def semesters(course)
  31. Dir[File.join desk, course, '*', '_roster.csv'].map! do |fn|
  32. File.basename File.dirname fn
  33. end
  34. end
  35. def load(path)
  36. case File.extname path
  37. when '.yml', '.yaml'
  38. YAML.load File.read(path)
  39. when '.csv'
  40. # TODO
  41. end
  42. end
  43. end
  44. end