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.

roster.rb 708 B

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12345678910111213141516171819202122232425262728293031
  1. module KGrader
  2. class Roster
  3. attr_reader :semester
  4. def initialize(filesystem, course, semester)
  5. @fs = filesystem
  6. @course = course
  7. @semester = semester
  8. @students = nil
  9. end
  10. def load(filename)
  11. @students = @fs.load(filename).map! &:first
  12. FileUtils.mkdir_p File.dirname(rosterfile)
  13. File.write rosterfile, @students.join("\n")
  14. rescue FilesystemError => err
  15. raise RosterError, err
  16. end
  17. def students
  18. @students ||= @fs.load(rosterfile).map! &:first
  19. rescue FilesystemError
  20. raise RosterError, "unknown semester: #{semester}"
  21. end
  22. private
  23. def rosterfile
  24. @fs.roster @course.name, @semester
  25. end
  26. end
  27. end