From 5c07360a57500ec599bd7c4789a8bc0d30dab75a Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 6 Apr 2016 16:04:37 -0500 Subject: [PATCH] Clean desk --- lib/kgrader/cli.rb | 9 ++++++++- lib/kgrader/submission.rb | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/kgrader/cli.rb b/lib/kgrader/cli.rb index d14e772..54351a4 100644 --- a/lib/kgrader/cli.rb +++ b/lib/kgrader/cli.rb @@ -38,7 +38,7 @@ module KGrader def clean clear_jail - # TODO: also purge uncommitted grades: set all graded to ungraded and delete all pending files + clean_desk end def clobber @@ -73,5 +73,12 @@ module KGrader def clear_desk FileUtils.rm_rf Dir[File.join @fs.desk, '*', ''] end + + def clean_desk + Dir[File.join @fs.desk, '*', '*', '*', '*', 'status.txt'].each do |fn| + File.write fn, "ungraded" if File.read(fn) == "graded" + end + FileUtils.rm_rf Dir[File.join @fs.desk, '*', '*', '*', '*', 'pending'] + end end end diff --git a/lib/kgrader/submission.rb b/lib/kgrader/submission.rb index 48a876c..ecbfa51 100644 --- a/lib/kgrader/submission.rb +++ b/lib/kgrader/submission.rb @@ -73,19 +73,19 @@ module KGrader private def repo - File.join @root, "repo" + File.join @root, 'repo' end def statusfile - File.join @root, "status.txt" + File.join @root, 'status.txt' end def gradefile - File.join @root, "grade.txt" + File.join @root, 'grade.txt' end def pendingfile - File.join @root, "pending" + File.join @root, 'pending' end def revision