| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| app/helpers/submissions_helper.rb | 116 | 93 | 80.17%
|
76.34%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 module SubmissionsHelper |
2 |
3 def find_appropriate_grouping(assignment_id, params) |
4 if current_user.admin? || current_user.ta? |
5 return Grouping.find(params[:grouping_id]) |
6 else |
7 return current_user.accepted_grouping_for(assignment_id) |
8 end |
9 end |
10 |
11 def set_release_on_results(groupings, release, errors) |
12 changed = 0 |
13 groupings.each do |grouping| |
14 begin |
15 raise I18n.t("marking_state.no_submission", :group_name => grouping.group_name) if !grouping.has_submission? |
16 submission = grouping.current_submission_used |
17 raise I18n.t("marking_state.no_result", :group_name => grouping.group.group_name) if !submission.has_result? |
18 raise I18n.t("marking_state.not_complete", :group_name => grouping.group.group_name) if submission.result.marking_state != Result::MARKING_STATES[:complete] |
19 submission.result.released_to_students = release |
20 if !submission.result.save |
21 raise I18n.t("marking_state.result_not_saved", :group_name => grouping.group.group_name) |
22 end |
23 changed += 1 |
24 rescue Exception => e |
25 errors.push(e.message) |
26 end |
27 end |
28 return changed |
29 end |
30 |
31 def construct_file_manager_dir_table_row(directory_name, directory) |
32 table_row = {} |
33 table_row[:id] = directory.id |
34 table_row[:filter_table_row_contents] = render_to_string :partial => 'submissions/table_row/directory_table_row', :locals => {:directory_name => directory_name, :directory => directory} |
35 table_row[:filename] = directory_name |
36 table_row[:last_modified_date_unconverted] = directory.last_modified_date.strftime('%b %d, %Y %H:%M') |
37 table_row[:revision_by] = directory.user_id |
38 return table_row |
39 |
40 end |
41 |
42 def construct_file_manager_table_row(file_name, file) |
43 table_row = {} |
44 table_row[:id] = file.id |
45 table_row[:filter_table_row_contents] = render_to_string :partial => 'submissions/table_row/filter_table_row', :locals => {:file_name => file_name, :file => file} |
46 |
47 table_row[:filename] = file_name |
48 |
49 table_row[:last_modified_date] = file.last_modified_date.strftime('%d %B, %l:%M%p') |
50 |
51 table_row[:last_modified_date_unconverted] = file.last_modified_date.strftime('%b %d, %Y %H:%M') |
52 |
53 table_row[:revision_by] = file.user_id |
54 |
55 return table_row |
56 end |
57 |
58 |
59 def construct_file_manager_table_rows(files) |
60 result = {} |
61 files.each do |file_name, file| |
62 result[file.id] = construct_file_manager_table_row(file_name, file) |
63 end |
64 return result |
65 end |
66 |
67 def construct_repo_browser_table_row(file_name, file) |
68 table_row = {} |
69 table_row[:id] = file.id |
70 table_row[:filter_table_row_contents] = render_to_string :partial => 'submissions/repo_browser/filter_table_row', :locals => {:file_name => file_name, :file => file} |
71 table_row[:filename] = file_name |
72 table_row[:last_modified_date] = file.last_modified_date.strftime('%d %B, %l:%M%p') |
73 table_row[:last_modified_date_unconverted] = file.last_modified_date.strftime('%b %d, %Y %H:%M') |
74 table_row[:revision_by] = file.user_id |
75 return table_row |
76 end |
77 |
78 def construct_repo_browser_directory_table_row(directory_name, directory) |
79 table_row = {} |
80 table_row[:id] = directory.id |
81 table_row[:filter_table_row_contents] = render_to_string :partial => 'submissions/repo_browser/directory_row', :locals => {:directory_name => directory_name, :directory => directory} |
82 table_row[:filename] = directory_name |
83 table_row[:last_modified_date] = directory.last_modified_date.strftime('%d %B, %l:%M%p') |
84 table_row[:last_modified_date_unconverted] = directory.last_modified_date.strftime('%b %d, %Y %H:%M') |
85 table_row[:revision_by] = directory.user_id |
86 return table_row |
87 end |
88 |
89 def construct_repo_browser_table_rows(files) |
90 result = {} |
91 files.each do |file_name, file| |
92 result[file.id] = construct_repo_browser_row(file_name, file) |
93 end |
94 return result |
95 end |
96 |
97 |
98 def sanitize_file_name(file_name) |
99 # If file_name is blank, return the empty string |
100 return "" if file_name.nil? |
101 return File.basename(file_name).gsub( |
102 SubmissionFile::FILENAME_SANITIZATION_REGEXP, |
103 SubmissionFile::SUBSTITUTION_CHAR) |
104 end |
105 |
106 |
107 # Helper methods to determine remark request status on a submission |
108 def remark_in_progress(submission) |
109 return (submission.remark_result and submission.remark_result.marking_state == Result::MARKING_STATES[:partial]) |
110 end |
111 |
112 def remark_complete_but_unreleased(submission) |
113 return (submission.remark_result and submission.remark_result.marking_state == Result::MARKING_STATES[:complete] and !submission.remark_result.released_to_students) |
114 end |
115 |
116 end |
Generated on Tue Feb 07 00:07:35 -0500 2012 with rcov 0.9.10