A code autograder for student homework submissions
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

32 行
708 B

  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