-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
242 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,4 +220,5 @@ pg_data | |
.ruby-version | ||
mysql2psql.yml | ||
*.pem | ||
t.csv | ||
t.csvdb/schema.rb | ||
db/schema.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class GradingHistoriesController < ApplicationController | ||
include AuthorizationHelper | ||
before_action :set_grading_history, only: %i[show] | ||
|
||
# Checks if user is allowed to view a grading history | ||
def action_allowed? | ||
# admins and superadmins are always allowed | ||
return true if current_user_has_admin_privileges? | ||
# populate assignment fields | ||
assignment_for_history(params[:grade_type]) | ||
# if not admin/superadmin, check permissions | ||
if @assignment.instructor_id == current_user.id | ||
true | ||
elsif TaMapping.exists?(ta_id: current_user.id, course_id: @assignment.course_id) && | ||
(TaMapping.where(course_id: @assignment.course_id).include? TaMapping.where(ta_id: current_user.id, course_id: @assignment.course_id).first) | ||
true | ||
elsif @assignment.course_id && Course.find(@assignment.course_id).instructor_id == current_user.id | ||
true | ||
end | ||
end | ||
|
||
# populate the assignment fields according to type | ||
def assignment_for_history(type) | ||
# for a submission, the receiver is an AssignmentTeam | ||
# use this AssignmentTeam to find the assignment | ||
if type.eql? 'Submission' | ||
assignment_team = AssignmentTeam.find(params[:grade_receiver_id]) | ||
@assignment = Assignment.find(assignment_team.parent_id) | ||
end | ||
# for a review, the receiver is an AssignmentParticipant | ||
# use this AssignmentParticipant to find the assignment | ||
if type.eql? 'Review' | ||
participant_id = params[:participant_id] | ||
grade_receiver = AssignmentParticipant.find(participant_id) | ||
@assignment = Assignment.find(grade_receiver.parent_id) | ||
end | ||
end | ||
|
||
# return all grading history entries for the assignment | ||
# entries are returned in chronological order | ||
def index | ||
@grading_histories = GradingHistory.where(grade_receiver_id: params[:grade_receiver_id], grading_type: params[:grade_type]).reverse_order | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# E2383 Added for tracking histories | ||
|
||
class GradingHistory < ActiveRecord::Base | ||
belongs_to :instructor, inverse_of: :instructor_id | ||
belongs_to :assignment, inverse_of: :assignment_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class ReviewGradingHistory < GradingHistory | ||
attr_protected | ||
belongs_to :grade_receiver, class_name: 'Participant', inverse_of: :grade_receiver_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class SubmissionGradingHistory < GradingHistory | ||
attr_protected | ||
belongs_to :grade_receiver, class_name: 'Team', inverse_of: :grade_receiver_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
= form_for @grading_history do |f| | ||
- if @grading_history.errors.any? | ||
#error_explanation | ||
%h2= "#{pluralize(@grading_history.errors.count, "error")} prohibited this grading_history from being saved:" | ||
%ul | ||
- @grading_history.errors.full_messages.each do |message| | ||
%li= message | ||
|
||
.actions | ||
= f.submit 'Save' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<% record = @grading_histories[0] | ||
if record == nil | ||
receiver = "" | ||
assignment = "" | ||
else | ||
if record.grading_type == "Submission" | ||
receiver = "of " + Team.where(id: record.grade_receiver_id).pluck(:name).first | ||
assignment = "for the submission " + Assignment.where(id: record.assignment_id).pluck(:name).first | ||
else | ||
receiver = "of " + User.where(id: record.grade_receiver_id).pluck(:fullname).first | ||
assignment = "for review in " + Assignment.where(id: record.assignment_id).pluck(:name).first | ||
end | ||
|
||
end | ||
%> | ||
<h1 class="center">Grade History <%= receiver %> <%= assignment %></h1> | ||
|
||
<table style="border-collapse:collapse; table-layout:fixed; width:1350px;"> | ||
<thead> | ||
<tr> | ||
<th style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;">Instructor</th> | ||
<th style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;">Grade</th> | ||
<th style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;">Comment</th> | ||
<th style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;">Graded At</th> | ||
</tr> | ||
|
||
<!--This is the main view of the table. This will add table with either hyperlink or the content nased on the operation. --> | ||
<tbody> | ||
<% @grading_histories.each do |record| %> | ||
<tr> | ||
<td style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;"><%= User.where(id: record.instructor_id).pluck(:fullname).first %></td> | ||
<td style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;"><%= record.grade %></td> | ||
<td style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;"><%= record.comment %></td> | ||
<td style="padding:10px; border:solid 1.5px black; width:50px; word-wrap:break-word;"><%= record.created_at %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe GradingHistoriesController do | ||
let(:grading_history) { build(:grading_history) } | ||
|
||
describe ':create' do | ||
it 'successfully creates a grading history with valid parameters' do | ||
expect(grading_history.grade).to eq(100) | ||
expect(grading_history.comment).to eq("Good work!") | ||
expect(grading_history.instructor_id).to eq(6) | ||
expect(grading_history.assignment_id).to eq(1) | ||
expect(grading_history.grade_receiver_id).to eq(1) | ||
expect(grading_history.id).to eq(1) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
include GradeHistoriesHelperSpec | ||
|
||
describe "Feature Tests to check the grade audit trail: " do | ||
before(:each) do | ||
assignment_setup | ||
make_submission | ||
end | ||
|
||
describe 'The grade history' do | ||
it 'should be visible' do | ||
user = User.find_by(name: "instructor6") | ||
stub_current_user(user, user.role.name, user.role) | ||
visit '/assignments/list_submissions?id=1' | ||
click_link 'Assign Grade' | ||
fill_in "grade_for_submission", with: '80' | ||
fill_in "comment_for_submission", with: 'first comment' | ||
click_button 'Save' | ||
visit '/grading_histories?grade_receiver_id=1&grade_type=Submission' | ||
expect_page_content_to_have('first comment') | ||
end | ||
|
||
it 'should be shown in chronological order' do | ||
user = User.find_by(name: "instructor6") | ||
stub_current_user(user, user.role.name, user.role) | ||
visit '/assignments/list_submissions?id=1' | ||
click_link 'Assign Grade' | ||
fill_in "grade_for_submission", with: '80' | ||
fill_in "comment_for_submission", with: 'first comment' | ||
visit '/assignments/list_submissions?id=1' | ||
click_button 'Save' | ||
click_link 'Assign Grade' | ||
fill_in "grade_for_submission", with: '50' | ||
fill_in "comment_for_submission", with: 'second comment' | ||
click_button 'Save' | ||
visit '/grading_histories?grade_receiver_id=1&grade_type=Submission' | ||
table = page.all('table tr') | ||
expect(table[0]).to have_content?("second comment") | ||
expect(table[1]).to_have_content?("first comment") | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module GradeHistoriesHelperSpec | ||
def assignment_setup | ||
create(:assignment, name: "Assignment1684", directory_path: "Assignment1684") | ||
create_list(:participant, 3) | ||
create(:topic, topic_name: "Topic") | ||
create(:deadline_type, name: "submission") | ||
create(:deadline_type, name: "review") | ||
create(:deadline_type, name: "metareview") | ||
create(:deadline_type, name: "drop_topic") | ||
create(:deadline_type, name: "signup") | ||
create(:deadline_type, name: "team_formation") | ||
create(:deadline_right) | ||
create(:deadline_right, name: 'Late') | ||
create(:deadline_right, name: 'OK') | ||
create(:assignment_due_date, deadline_type: DeadlineType.where(name: "submission").first, due_at: DateTime.now.in_time_zone + 1.day) | ||
login_as("instructor6") | ||
user = User.find_by(name: "student2064") | ||
stub_current_user(user, user.role.name, user.role) | ||
visit '/student_task/list' | ||
click_link 'Assignment1684' | ||
click_link 'Signup sheet' | ||
assignment_id = Assignment.first.id | ||
visit "/sign_up_sheet/sign_up?id=#{assignment_id}&topic_id=1" | ||
visit '/student_task/list' | ||
click_link 'Assignment1684' | ||
click_link 'Your team' | ||
end | ||
|
||
def make_submission | ||
visit '/student_task/list' | ||
click_link "Assignment1684" | ||
click_link "Your work" | ||
fill_in 'submission', with: "https://www.ncsu.edu" | ||
click_on 'Upload link' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters