@@ -667,107 +667,6 @@ def summary_json(user)
667667 ltiDeployments : lti_deployments }
668668 end
669669
670- # Generates the summary of the most test results associated with an assignment.
671- def summary_test_results
672- latest_test_run_by_grouping = TestRun . select ( 'created_at as test_runs_created_at' ,
673- 'grouping_id' )
674- . where . not ( submission_id : nil )
675- . to_sql
676-
677- latest_test_runs = TestRun
678- . joins ( grouping : :group )
679- . joins ( "INNER JOIN (#{ latest_test_run_by_grouping } ) latest_test_run_by_grouping \
680- ON latest_test_run_by_grouping.grouping_id = test_runs.grouping_id \
681- AND latest_test_run_by_grouping.test_runs_created_at = test_runs.created_at")
682- . select ( 'id' , 'test_runs.grouping_id' , 'groups.group_name' )
683- . to_sql
684-
685- self . test_groups . joins ( test_group_results : :test_results )
686- . joins ( "INNER JOIN (#{ latest_test_runs } ) latest_test_runs \
687- ON test_group_results.test_run_id = latest_test_runs.id")
688- . select ( 'test_groups.name' ,
689- 'test_groups.id as test_groups_id' ,
690- 'latest_test_runs.group_name' ,
691- 'test_results.name as test_result_name' ,
692- 'test_results.status' ,
693- 'test_results.marks_earned' ,
694- 'test_results.marks_total' ,
695- :output , :extra_info , :error_type )
696- end
697-
698- def latest_summary_test_results
699- latest_test_run_by_grouping = TestRun . group ( 'grouping_id' ) . select ( 'MAX(created_at) as test_runs_created_at' ,
700- 'grouping_id' )
701- . where . not ( submission_id : nil )
702- . to_sql
703-
704- latest_test_runs = TestRun
705- . joins ( grouping : :group )
706- . joins ( "INNER JOIN (#{ latest_test_run_by_grouping } ) latest_test_run_by_grouping \
707- ON latest_test_run_by_grouping.grouping_id = test_runs.grouping_id \
708- AND latest_test_run_by_grouping.test_runs_created_at = test_runs.created_at")
709- . select ( 'id' , 'test_runs.grouping_id' , 'groups.group_name' )
710- . to_sql
711-
712- self . test_groups . joins ( test_group_results : :test_results )
713- . joins ( "INNER JOIN (#{ latest_test_runs } ) latest_test_runs \
714- ON test_group_results.test_run_id = latest_test_runs.id")
715- . select ( 'test_groups.name' ,
716- 'test_groups.id as test_groups_id' ,
717- 'latest_test_runs.group_name' ,
718- 'test_results.name as test_result_name' ,
719- 'test_results.status' ,
720- 'test_results.marks_earned' ,
721- 'test_results.marks_total' ,
722- :output , :extra_info , :error_type )
723- end
724-
725- # Generate a JSON summary of the most recent test results associated with an assignment.
726- def summary_test_result_json ( latest : true )
727- test_results = latest ? latest_summary_test_results : summary_test_results
728-
729- test_results . group_by ( &:group_name ) . transform_values do |grouping |
730- grouping . group_by ( &:name )
731- end . to_json
732- end
733-
734- # Generate a CSV summary of the most recent test results associated with an assignment.
735- def summary_test_result_csv
736- results = { }
737- headers = Set . new
738- summary_test_results = self . latest_summary_test_results . as_json
739-
740- summary_test_results . each do |test_result |
741- header = "#{ test_result [ 'name' ] } :#{ test_result [ 'test_result_name' ] } "
742-
743- if results . key? ( test_result [ 'group_name' ] )
744- results [ test_result [ 'group_name' ] ] [ header ] = test_result [ 'status' ]
745- else
746- results [ test_result [ 'group_name' ] ] = { header => test_result [ 'status' ] }
747- end
748-
749- headers << header
750- end
751- headers = headers . sort
752-
753- CSV . generate do |csv |
754- csv << [ nil , *headers ]
755-
756- results . sort_by ( &:first ) . each do |( group_name , _test_group ) |
757- row = [ group_name ]
758-
759- headers . each do |header |
760- if results [ group_name ] . key? ( header )
761- row << results [ group_name ] [ header ]
762- else
763- row << nil
764- end
765- end
766- csv << row
767- end
768- end
769- end
770-
771670 # Generate CSV summary of grades for this assignment
772671 # for the current user. The user should be an instructor or TA.
773672 def summary_csv ( role )
0 commit comments