forked from expertiza/expertiza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added in what I beleive were the necessary files from the previous im…
…plementations various models,views and controllers were added or modified based on the previous teams pull request - Erik Lopez-Godinez
- Loading branch information
Showing
13 changed files
with
146 additions
and
0 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
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,4 @@ | ||
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,7 @@ | ||
%h1 Editing grading_history | ||
|
||
= render 'form' | ||
|
||
= link_to 'Show', @grading_history | ||
\| | ||
= link_to 'Back', grading_histories_path |
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:1500px;"> | ||
<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:60px; 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
%h1 New grading_history | ||
|
||
= render 'form' | ||
|
||
= link_to 'Back', grading_histories_path |
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 @@ | ||
%p#notice= notice | ||
|
||
|
||
= link_to 'Edit', edit_grading_history_path(@grading_history) | ||
\| | ||
= link_to 'Back', grading_histories_path |
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