1- # TODO unit tests
21class Api ::Debugging ::PrintStatementsController < ApplicationController
32 CACHE_TTL = 1 . hour
43
5- # TODO: don't hardcode this
64 IGNORE_LINES = [
75 "print('All bees are vanquished. You win!')" ,
86 "print('The bees reached homebase or the queen ant queen has perished. Please try again :(')" ,
@@ -12,7 +10,6 @@ class Api::Debugging::PrintStatementsController < ApplicationController
1210 # Regex for Python print statements: print(...)
1311 PRINT_REGEX = /^\s *print\s *\( .*\) /
1412
15- # TODO deduplicate from FilesController
1613 def fetch_file_from_local ( object_key )
1714 file_path = Rails . root . join ( "../../data/private/#{ object_key } " )
1815 if File . exist? ( file_path )
@@ -65,8 +62,6 @@ def show
6562 return
6663 end
6764
68- # TODO error if student doesn't have any backups for this assignment and course
69-
7065 backups = BackupMetadatum . where (
7166 course : course . okpy_endpoint ,
7267 assignment : assignment . okpy_endpoint ,
@@ -95,14 +90,12 @@ def show
9590 problem : problem_names . join ( ", " ) ,
9691 timestamp : backup . created ,
9792 passing : is_passing ,
98- # TODO don't hardcode this (other assignments may have multiple files)
9993 files : [ { name : "ants.py" , contents : contents , hasPrint : has_print } ] ,
10094 has_print : has_print # internal flag for grouping
10195 }
10296 end
10397
10498 # Identify the indices of backups that contain prints
105- # TODO investigate why problem name can be empty. perhaps they just ran `python3 ok` without specifying a problem?
10699 print_indices = all_data . each_index . select { |i | all_data [ i ] [ :has_print ] and all_data [ i ] [ :problem ] != "" }
107100
108101 return render json : [ ] if print_indices . empty?
0 commit comments