clean up some rubric assessment requests stuff
refs CNVS-7414 first, start at RubricsController#assessments. there is no route for it, so remove the action and it's view. The rubric_association partial was only used from that view, so remove it as well. Then in RubricAssessmentController and RubricAssociationsController #create, note that nothing ever provides an invitations param, so remove that, and cascade down to removing or simplifying a few other methods (particularly RubricAssociation#invite_assessors, which created users in a bad way, and RubricAssociation#invite_assessor, which never assigned assessor_asset, which will shortly be non-null, and is obviously never used cause that column is never null in production). Finally, fix some specs to properly create rubric assessments since the (bad) helper methods are now gone. test plan: * specs * basic regression test around using rubrics for grading and peer reviews Change-Id: Ibd7713d9fc1f847d49c47b95d8c51ce28fa41e92 Reviewed-on: https://gerrit.instructure.com/23412 Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
68599ef914
commit
5254bfc09d
|
@ -60,19 +60,7 @@ class RubricAssessmentsController < ApplicationController
|
|||
def create
|
||||
update
|
||||
end
|
||||
|
||||
def invite
|
||||
@association = @context.rubric_associations.find(params[:rubric_association_id])
|
||||
@rubric = @association.rubric
|
||||
assessor_email = params[:rubric_assessment][:assessor_email]
|
||||
# If an email address is specified, this is an invitation for someone to assess
|
||||
if authorized_action(@association, @current_user, :manage)
|
||||
@assessment_requests = @association.invite_assessors(@current_user, assessor_email, @association.association.find_asset_for_assessment(@association, @current_user.id)[0])
|
||||
@assessment_request = @assessment_requests.first
|
||||
render :json => @assessment_request.to_json(:methods => :assessor_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def remind
|
||||
@association = @context.rubric_associations.find(params[:rubric_association_id])
|
||||
@rubric = @association.rubric
|
||||
|
|
|
@ -19,13 +19,11 @@
|
|||
class RubricAssociationsController < ApplicationController
|
||||
before_filter :require_context
|
||||
def create
|
||||
@invitees = params[:rubric_association].delete(:invitations) rescue nil
|
||||
update
|
||||
end
|
||||
|
||||
def update
|
||||
params[:rubric_association] ||= {}
|
||||
params[:rubric_association].delete(:invitations)
|
||||
@association = @context.rubric_associations.find(params[:id]) rescue nil
|
||||
@association_object = RubricAssociation.get_association_object(params[:rubric_association])
|
||||
@association_object = nil unless @association_object && @association_object.try(:context) == @context
|
||||
|
@ -41,7 +39,7 @@ class RubricAssociationsController < ApplicationController
|
|||
params[:rubric_association][:association] = @association.association if @association
|
||||
params[:rubric_association][:association] ||= @association_object
|
||||
params[:rubric_association][:id] = @association.id if @association
|
||||
@association = RubricAssociation.generate_with_invitees(@current_user, @rubric, @context, params[:rubric_association], @invitees)
|
||||
@association = RubricAssociation.generate(@current_user, @rubric, @context, params[:rubric_association])
|
||||
json_res = {
|
||||
:rubric => ActiveSupport::JSON.decode(@rubric.to_json(:methods => :criteria, :include_root => false, :permissions => {:user => @current_user, :session => session})),
|
||||
:rubric_association => ActiveSupport::JSON.decode(@association.to_json(:include_root => false, :include => [:rubric_assessments, :assessment_requests], :methods => :assessor_name, :permissions => {:user => @current_user, :session => session}))
|
||||
|
|
|
@ -38,15 +38,7 @@ class RubricsController < ApplicationController
|
|||
@actual_rubric = @rubric_association.rubric
|
||||
end
|
||||
|
||||
def assessments
|
||||
if authorized_action(@context, @current_user, :manage)
|
||||
@rubric_associations = @context.rubric_associations.bookmarked
|
||||
@rubrics = @rubric_associations.map{|r| r.rubric}
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@invitees = params[:rubric_association].delete(:invitations) rescue nil
|
||||
update
|
||||
end
|
||||
|
||||
|
@ -58,7 +50,6 @@ class RubricsController < ApplicationController
|
|||
# instead of the old one.
|
||||
def update
|
||||
params[:rubric_association] ||= {}
|
||||
params[:rubric_association].delete(:invitations)
|
||||
@association_object = RubricAssociation.get_association_object(params[:rubric_association])
|
||||
params[:rubric][:user] = @current_user if params[:rubric]
|
||||
if (!@association_object || authorized_action(@association_object, @current_user, :read)) && authorized_action(@context, @current_user, :manage_rubrics)
|
||||
|
@ -84,7 +75,7 @@ class RubricsController < ApplicationController
|
|||
@rubric.user = @current_user
|
||||
end
|
||||
if params[:rubric] && (@rubric.grants_right?(@current_user, session, :update) || (@association && @association.grants_right?(@current_user, session, :update))) #authorized_action(@rubric, @current_user, :update)
|
||||
@association = @rubric.update_with_association(@current_user, params[:rubric], @context, params[:rubric_association], @invitees)
|
||||
@association = @rubric.update_with_association(@current_user, params[:rubric], @context, params[:rubric_association])
|
||||
@rubric = @association.rubric if @association
|
||||
end
|
||||
json_res = {}
|
||||
|
|
|
@ -149,26 +149,12 @@ class Rubric < ActiveRecord::Base
|
|||
self.rubric_associations.create(:association => association, :context => context, :use_for_grading => !!opts[:use_for_grading], :purpose => purpose)
|
||||
end
|
||||
|
||||
def clone_for_association(current_user, association, rubric_params, association_params, invitees="")
|
||||
rubric = Rubric.new
|
||||
self.attributes.delete_if{|k, v| false}.each do |key, value|
|
||||
rubric.send("#{key}=", value) if rubric.respond_to?(key)
|
||||
end
|
||||
rubric.migration_id = "cloned_from_#{self.id}"
|
||||
rubric.rubric_id = self.id
|
||||
rubric.free_form_criterion_comments = rubric_params[:free_form_criterion_comments] == '1' if rubric_params[:free_form_criterion_comments]
|
||||
rubric.user = current_user
|
||||
rubric_params[:hide_score_total] ||= association_params[:hide_score_total]
|
||||
rubric.update_criteria(rubric_params)
|
||||
RubricAssociation.generate_with_invitees(current_user, rubric, context, association_params, invitees) if association_params[:association] || association_params[:url]
|
||||
end
|
||||
|
||||
def update_with_association(current_user, rubric_params, context, association_params, invitees="")
|
||||
def update_with_association(current_user, rubric_params, context, association_params)
|
||||
self.free_form_criterion_comments = rubric_params[:free_form_criterion_comments] == '1' if rubric_params[:free_form_criterion_comments]
|
||||
self.user ||= current_user
|
||||
rubric_params[:hide_score_total] ||= association_params[:hide_score_total]
|
||||
self.update_criteria(rubric_params)
|
||||
RubricAssociation.generate_with_invitees(current_user, self, context, association_params, invitees) if association_params[:association] || association_params[:url]
|
||||
RubricAssociation.generate(current_user, self, context, association_params) if association_params[:association] || association_params[:url]
|
||||
end
|
||||
|
||||
def unique_item_id(id=nil)
|
||||
|
|
|
@ -142,36 +142,13 @@ class RubricAssociation < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
protected :update_assignment_points
|
||||
|
||||
def invite_assessor(assessee, assessor, asset, invite=false)
|
||||
# Invitations should be unique per asset, user and assessor
|
||||
assessment_request = self.assessment_requests.find_by_user_id_and_assessor_id(assessee.id, assessor.id)
|
||||
assessment_request ||= self.assessment_requests.build(:user => assessee, :assessor => assessor)
|
||||
assessment_request.workflow_state = "assigned" if assessment_request.new_record?
|
||||
assessment_request.asset = asset
|
||||
invite ? assessment_request.send_reminder! : assessment_request.save!
|
||||
assessment_request
|
||||
end
|
||||
|
||||
|
||||
def remind_user(assessee)
|
||||
assessment_request = self.assessment_requests.find_by_user_id(assessee.id)
|
||||
assessment_request ||= self.assessment_requests.build(:user => assessee)
|
||||
assessment_request.send_reminder! if assessment_request.assigned?
|
||||
assessment_request
|
||||
end
|
||||
|
||||
def invite_assessors(assessee, invitations, asset)
|
||||
assessors = TmailParser.new(invitations).parse
|
||||
assessors.map do |assessor|
|
||||
cc = CommunicationChannel.find_or_create_by_path(assessor[:email])
|
||||
user = cc.user || User.create() { |u| u.workflow_state = :creation_pending }
|
||||
user.assert_name(assessor[:name] || assessor[:email])
|
||||
cc.user ||= user
|
||||
cc.save!
|
||||
user.reload
|
||||
invite_assessor(assessee, user, asset, true)
|
||||
end
|
||||
end
|
||||
|
||||
def update_rubric
|
||||
cnt = self.rubric.rubric_associations.for_grading.length rescue 0
|
||||
|
@ -207,7 +184,7 @@ class RubricAssociation < ActiveRecord::Base
|
|||
self.context.students - self.rubric_assessments.map{|a| a.user} - self.assessment_requests.map{|a| a.user}
|
||||
end
|
||||
|
||||
def self.generate_with_invitees(current_user, rubric, context, params, invitees=nil)
|
||||
def self.generate(current_user, rubric, context, params)
|
||||
raise "context required" unless context
|
||||
association_object = params.delete :association
|
||||
if (association_id = params.delete(:id)) && association_id.present?
|
||||
|
@ -223,10 +200,6 @@ class RubricAssociation < ActiveRecord::Base
|
|||
association.skip_updating_points_possible = params.delete :skip_updating_points_possible
|
||||
association.update_attributes(params)
|
||||
association.association = association_object
|
||||
# Invite any recipients from the get-go
|
||||
if invitees && association
|
||||
assessments = association.invite_assessors(current_user, invitees, association_object.find_asset_for_assessment(association, current_user.id)[0])
|
||||
end
|
||||
association
|
||||
end
|
||||
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
<% association = rubric_association || nil %>
|
||||
<div id="association_<%= association ? association.id : "blank" %>" class="rubric_association" style="<%= hidden unless association %>">
|
||||
<a name="association_<%= association ? association.id : "{{ id }}" %>"></a>
|
||||
<div class="header">
|
||||
<div class="links">
|
||||
<a href="#" class="edit_association_link no-hover"><%= image_tag "edit.png" %></a>
|
||||
<a href="<%= context_url(@context, :context_rubric_association_url, association ? association.id : "{{ id }}") %>" class="delete_association_link no-hover"><%= image_tag "delete.png" %></a>
|
||||
</div>
|
||||
<div class="association_display title">
|
||||
<a href="<%= context_url(@context, :context_rubric_association_rubric_assessments_url, association ? association.id : "{{ id }}") %>"><%= (association.title || t('no_name', "No Name")) rescue t('no_name', "No Name") %></a>
|
||||
</div>
|
||||
<div class="association_edit">
|
||||
<%= blabel :rubric_association, :title, :en => "Name" %>
|
||||
<%= text_field :rubric_association, :title, :value => ((association.title || t('assessment_name', "Assessment Name")) rescue t('assessment_name', "Assessment Name")) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<% if @context.is_a?(User) %>
|
||||
<div class="association_display" style="text-align: left; margin-bottom: 10px;">
|
||||
<a href="<%= association.url rescue "{{ url }}" %>" class="association_url link"><%= t('view_assessed_page', 'View the Page Being Assessed') %></a>
|
||||
</div>
|
||||
<div class="association_edit">
|
||||
<%= blabel :rubric_association, :url, :en => "URL to Assess" %>
|
||||
<%= text_field :rubric_association, :url, :value => ((association.url || "http://") rescue "http://") %>
|
||||
</div>
|
||||
<div class="association_display" style="font-size: 0.8em;">
|
||||
<table style="width: 100%;"><tr>
|
||||
<td style="vertical-align: top;">
|
||||
<%= before_label('invited_assessors', 'Invited Assessors') %>
|
||||
<ul class="unstyled_list assessor_list" style="margin-left: 20px;">
|
||||
<% if !association || association.assessment_requests.incomplete.empty? %>
|
||||
<li class="none_assigned_message"><%= t('none_invited', 'None Invited') %></li>
|
||||
<% else %>
|
||||
<% association.assessment_requests.incomplete.each do |assessment| %>
|
||||
<li style="<%= 'font-weight: bold;' if assessment.completed? %>" title="<%= t('assessment_completed', 'Assessment Completed') if assessment.completed? %>"><%= assessment.assessor_name %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if association && !association.rubric_assessments.empty? %>
|
||||
<%= before_label('completed_assessments', 'Completed Assessments') %>
|
||||
<ul class="unstyled_list" style="margin-left: 20px;">
|
||||
<% association.rubric_assessments.each do |assessment| %>
|
||||
<li><%= assessment.assessor_name %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<div style="margin: 10px 0 0;" class="rubric_assessment_invitation">
|
||||
<a href="#" class="add_rubric_assessment_link add-small"><%= t('invite_new_assessor', 'Invite New Assessor') %></a>
|
||||
<a href="<%= context_url(@context, :context_rubric_association_invite_assessor_url, (association ? association.id : "{{ id }}")) %>" class="add_rubric_assessment_url" style="display: none;"> </a>
|
||||
<% form_for :rubric_assessment, :url => ".", :html => {:class => "add_rubric_assessment_form", :style => "display: none;"} do |f| %>
|
||||
<%= text_field :rubric_assessment, :assessor_email, :style => "width: 150px;" %>
|
||||
<div class="button-container">
|
||||
<button type="submit" class="btn"><%= t('buttons.invite', 'Invite') %></button>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</td><td style="vertical-align: top; width: 60%;" class="description">
|
||||
<%= association && association.description || t("no_description", "No Description") %>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<div class="association_edit" style="margin-top: 10px;">
|
||||
<table><tr>
|
||||
<td>
|
||||
<div class="association_new">
|
||||
<%= blabel :rubric_association, :invitations, :en => "People to Assess" %><br/>
|
||||
<%= text_area :rubric_association, :invitations, :value => t('emails_to_invite', '"Paste in here the email addresses of those you want to invite to assess this work"') , :style => "width: 90%; height: 75px;" %>
|
||||
</div>
|
||||
</td><td>
|
||||
<%= blabel :rubric_association, :description, :en => "Assessment Instructions" %><br/>
|
||||
<%= text_area :rubric_association, :description, :value => ((association.description || t('instructions', "Instructions")) rescue t('special_instructions', "Type any special instructions you have for those assessing your work")), :style => "width: 90%; height: 75px;" %>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="association_display" style="font-size: 0.8em;">
|
||||
<table style="width: 100%;"><tr>
|
||||
<td style="vertical-align: top;">
|
||||
<%= before_label('unsubmitted_assessments', 'Unsubmitted') %>
|
||||
<ul class="unstyled_list" style="margin-left: 20px;">
|
||||
<% if association %>
|
||||
<% association.unsubmitted_users.each do |user| %>
|
||||
<li><%= context_user_name(@context, user) %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if association && !association.rubric_assessments.empty? %>
|
||||
<%= before_label('submitted_and_incomplete_assessments', 'Submitted and Incomplete') %>
|
||||
<ul class="unstyled_list" style="margin-left: 20px;">
|
||||
<% association.assessment_requests.incomplete.each do |assessment| %>
|
||||
<li><%= context_user_name(@context, assessment.user) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= before_label('submitted_and_completed_assessments', 'Submitted and Completed') %>
|
||||
<ul class="unstyled_list" style="margin-left: 20px;">
|
||||
<% association.rubric_assessments.each do |assessment| %>
|
||||
<li><%= context_user_name(@context, assessment.user) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</td><td style="vertical-align: top; width: 60%;" class="description">
|
||||
<%= association && association.description || t("no_description", "No Description") %>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<div class="association_edit" style="margin-top: 10px;">
|
||||
<table><tr>
|
||||
<td>
|
||||
</td><td>
|
||||
<%= blabel :rubric_association, :description, :en => "Assessment Instructions" %><br/>
|
||||
<% if @context.is_a?(User) %>
|
||||
<%= text_area :rubric_association, :description, :value => ((association.description || t('instructions', "Instructions")) rescue t('special_instructions', "Type any special instructions you have for those assessing your work")), :style => "width: 90%; height: 75px;" %>
|
||||
<% else %>
|
||||
<%= text_area :rubric_association, :description, :value => ((association.description || t('instructions', "Instructions")) rescue t('submitting_instructions', "Type any instructions for those submitting items for assessment")), :style => "width: 90%; height: 75px;" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<% end %>
|
||||
<div style="text-align: right; font-size: 0.8em; margin-top: 0;">
|
||||
<a href="#" class="toggle_rubric_link"><%= t 'links.show_rubric', 'Show Rubric' %></a>
|
||||
</div>
|
||||
<div class="rubric_holder" style="display: none;">
|
||||
<%= render :partial => "shared/rubric", :object => (association.rubric rescue nil), :locals => {:editable => true, :rubric_association => association} %>
|
||||
</div>
|
||||
<div class="association_buttons association_edit button-container">
|
||||
<button type="button" class="save_button btn"><%= t('buttons.save_assessment', 'Save Assessment') %></button>
|
||||
<button type="button" class="cancel_button btn button-secondary"><%= t('#buttons.cancel', 'Cancel') %></button>
|
||||
</div>
|
||||
<a href="<%= context_url(@context, :context_rubric_association_url, association ? association.id : "{{ id }}") %>" style="display: none;" class="update_rubric_association_url"> </a>
|
||||
</div>
|
||||
</div>
|
|
@ -1,193 +0,0 @@
|
|||
<% content_for :page_title, t(:page_title, "Assessments") %>
|
||||
|
||||
<% content_for :right_side do %>
|
||||
<a href="<%= context_url(@context, :context_rubrics_url) %>" class="add_rubric_association_link add"><%= t('add_rubric_assessment', 'Add Rubric Assessment') %></a>
|
||||
<% end %>
|
||||
<% content_for :stylesheets do %>
|
||||
<style>
|
||||
.rubric_association {
|
||||
border: 1px solid #aaa;
|
||||
-moz-border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.rubric_association .header {
|
||||
-moz-border-radius-topleft: 3px;
|
||||
-moz-border-radius-topright: 3px;
|
||||
background-color: #ddd;
|
||||
padding: 2px 5px;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
.rubric_association .content {
|
||||
padding: 10px;
|
||||
}
|
||||
.rubric_association .links {
|
||||
float: right;
|
||||
}
|
||||
.rubric_association#association_new .association_new {
|
||||
display: block;
|
||||
}
|
||||
.rubric_association .association_new {
|
||||
display: none;
|
||||
}
|
||||
.rubric_association.editing .association_display {
|
||||
display: none;
|
||||
}
|
||||
.rubric_association.editing .association_edit {
|
||||
display: block;
|
||||
}
|
||||
.rubric_association .association_edit {
|
||||
display: none;
|
||||
}
|
||||
.rubric_association .rubric .rubric_title .links {
|
||||
display: none;
|
||||
}
|
||||
.rubric_association table.rubric {
|
||||
margin-top: 0;
|
||||
}
|
||||
.rubric_association table.rubric td,
|
||||
.rubric_association table.rubric th,
|
||||
.rubric_association table.rubric table.ratings td {
|
||||
border-color: #ccc;
|
||||
}
|
||||
.rubric_association table.rubric thead th {
|
||||
background-color: #eee;
|
||||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<% js_bundle :edit_rubric %>
|
||||
<% js_block do %>
|
||||
<script>
|
||||
require([
|
||||
'i18nObj' /* I18n.t */,
|
||||
'jquery' /* $ */,
|
||||
'jquery.ajaxJSON' /* ajaxJSON */,
|
||||
'jquery.instructure_forms' /* formSubmit, getFormData */,
|
||||
'jquery.instructure_misc_plugins' /* confirmDelete */,
|
||||
'jquery.loadingImg' /* loadingImage */,
|
||||
'jquery.templateData' /* fillTemplateData */,
|
||||
'vendor/jquery.scrollTo' /* /\.scrollTo/ */
|
||||
], function(I18n, $) {
|
||||
|
||||
window.rubricEditing = null;
|
||||
window.rubricAssociation = {
|
||||
addAssessment: function($association, assessment) {
|
||||
$association.find(".assessor_list").find(".none_assigned_message").remove();
|
||||
$association.find(".assessor_list").append("<li>" + assessment.assessor_name + "</li>");
|
||||
}
|
||||
}
|
||||
$(document).ready(function() {
|
||||
$(".association_edit textarea").focus(function() {
|
||||
$(this).select();
|
||||
});
|
||||
$(".add_rubric_assessment_link").click(function(event) {
|
||||
event.preventDefault();
|
||||
var $form = $(this).parents(".rubric_assessment_invitation").find(".add_rubric_assessment_form");
|
||||
$form.slideToggle();
|
||||
$form.attr('action', $(this).parents(".rubric_assessment_invitation").find(".add_rubric_assessment_url").attr('href'));
|
||||
});
|
||||
$(".rubric_association .add_rubric_assessment_form").formSubmit({
|
||||
beforeSubmit: function(data) {
|
||||
$(this).loadingImage();
|
||||
},
|
||||
success: function(data) {
|
||||
$(this).loadingImage('remove');
|
||||
$(this).slideUp();
|
||||
rubricAssociation.addAssessment($(this).parents(".rubric_association"), data.assessment_request);
|
||||
}
|
||||
});
|
||||
$(".add_rubric_association_link").click(function(event) {
|
||||
event.preventDefault();
|
||||
if ($("#association_new").length > 0) {
|
||||
return;
|
||||
}
|
||||
var $association = $("#association_blank").clone(true).removeAttr('id');
|
||||
$association.find(".rubric").removeAttr('id').show();
|
||||
$association.attr('id', 'association_new');
|
||||
$association.find(".edit_association_link").click();
|
||||
$association.find(".toggle_rubric_link").click();
|
||||
$("#rubrics").prepend($association.show());
|
||||
$("html,body").scrollTo($association);
|
||||
});
|
||||
$(".edit_association_link").click(function(event) {
|
||||
event.preventDefault();
|
||||
if ($(this).parents(".rubric_association").hasClass('editing')) {
|
||||
return;
|
||||
}
|
||||
$(this).parents(".rubric_association").addClass('editing');
|
||||
var $rubric = rubricEditing.editRubric($(this).parents(".rubric_association").find(".rubric:first"));
|
||||
$rubric.find("tr.summary").next().hide();
|
||||
$(this).parents(".rubric_association").find(":text:visible:first").focus().select();
|
||||
});
|
||||
$(".rubric_association .association_buttons .cancel_button").click(function() {
|
||||
$(this).parents(".rubric_association").removeClass('editing');
|
||||
rubricEditing.hideEditRubric($(this).parents(".rubric_association").find(".rubric"));
|
||||
if ($(this).parents(".rubric_association").attr('id') == 'association_new') {
|
||||
$(this).parents(".rubric_association").slideUp(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
$(".rubric_association .delete_association_link").click(function(event) {
|
||||
event.preventDefault();
|
||||
$(this).parents(".rubric_association").confirmDelete({
|
||||
url: $(this).attr('href'),
|
||||
message: <%= jt('are_you_sure_prompt', "Are you sure you want to delete this assessment? All results will be lost.") %>,
|
||||
success: function() {
|
||||
$(this).slideUp(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
$(".rubric_association .toggle_rubric_link").click(function(event) {
|
||||
event.preventDefault();
|
||||
$(this).parents(".rubric_association").find(".rubric_holder").slideToggle();
|
||||
$(this).text($(this).text() == "Show Rubric" ? "Hide Rubric" : "Show Rubric");
|
||||
});
|
||||
$(".rubric_association .association_buttons .save_button").click(function() {
|
||||
var $association = $(this).parents(".rubric_association");
|
||||
$association.loadingImage();
|
||||
var url = $association.attr('id') == 'association_new' ? $(".add_rubric_association_url").attr('href') : $association.find(".update_rubric_association_url").attr('href');
|
||||
var method = $association.attr('id') == 'association_new' ? "POST" : "PUT";
|
||||
var data = rubricEditing.rubricData($association.find(".rubric:first"));
|
||||
data = $.extend(data, $association.find(".association_edit").getFormData());
|
||||
data.match_assessment_to_association = "1";
|
||||
data['rubric_assessment[user_id]'] = $(".current_user_id").text();
|
||||
$.ajaxJSON(url, method, data, function(data) {
|
||||
var association = data.rubric_association;
|
||||
$association.loadingImage('remove')
|
||||
$association.fillTemplateData({
|
||||
data: association,
|
||||
hrefValues: ['id', 'rubric_id'],
|
||||
id: 'association_' + association.id
|
||||
});
|
||||
$association.find(".association_url").attr('href', association.url);
|
||||
for (var idx in association.assessment_requests) {
|
||||
var assessment = association.assessment_requests[idx];
|
||||
rubricAssociation.addAssessment($association, assessment);
|
||||
}
|
||||
$association.find(".association_buttons .cancel_button").click();
|
||||
var rubric = data.rubric;
|
||||
rubric.rubric_association_id = association.id;
|
||||
rubricEditing.updateRubric($association.find(".rubric:first"), rubric);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<div id="rubrics">
|
||||
<div style="display: none;" id="rubric_parameters">
|
||||
<input type="hidden" name="association_type" value="<%= @context.class.to_s %>"/>
|
||||
<input type="hidden" name="association_id" value="<%= @context.id %>"/>
|
||||
<input type="hidden" name="purpose" value="bookmark"/>
|
||||
</div>
|
||||
<span class="current_user_id" style="display: none;"><%= @current_user.id %></span>
|
||||
<a href="<%= context_url(@context, :context_rubric_associations_url) %>" class="add_rubric_association_to_existing_rubric_url" style="display: none;"> </a>
|
||||
<a href="<%= context_url(@context, :context_rubrics_url) %>" class="add_rubric_association_url" style="display: none;"> </a>
|
||||
<%= render :partial => "rubric_association", :collection => @rubric_associations %>
|
||||
</div>
|
||||
<%= render :partial => "rubric_association", :object => nil %>
|
||||
<%= render :partial => "shared/rubric_forms" %>
|
|
@ -342,7 +342,6 @@ FakeRails3Routes.draw do
|
|||
resources :gradebook_uploads
|
||||
resources :rubrics
|
||||
resources :rubric_associations do
|
||||
match 'invite' => 'rubric_assessments#invite', :as => :invite_assessor
|
||||
match 'remind/:assessment_request_id' => 'rubric_assessments#remind', :as => :remind_assessee
|
||||
resources :rubric_assessments, :path => 'assessments'
|
||||
end
|
||||
|
@ -643,7 +642,6 @@ FakeRails3Routes.draw do
|
|||
match 'external_tools/:id' => 'users#external_tool', :as => :external_tool
|
||||
resources :rubrics
|
||||
resources :rubric_associations do
|
||||
match 'invite' => 'rubric_assessments#invite', :as => :invite_assessor
|
||||
resources :rubric_assessments, :path => :assessments
|
||||
end
|
||||
|
||||
|
|
|
@ -88,39 +88,29 @@ describe RubricAssessmentsController do
|
|||
end
|
||||
|
||||
describe "POST 'remind'" do
|
||||
it "should require authorization" do
|
||||
before do
|
||||
course_with_teacher(:active_all => true)
|
||||
rubric_association_model(:user => @user, :context => @course)
|
||||
@assessment_request = @rubric_association.invite_assessors(@user, "bob@example.com", @rubric_association.association.submission_for_student(@user)).first
|
||||
assessor = User.create!
|
||||
@course.enroll_student(assessor)
|
||||
assessor_asset = @rubric_association.association.find_or_create_submission(assessor)
|
||||
user_asset = @rubric_association.association.find_or_create_submission(assessor)
|
||||
@assessment_request = @rubric_association.assessment_requests.create!(user: @user, asset: user_asset, assessor: assessor, assessor_asset: assessor_asset)
|
||||
end
|
||||
|
||||
it "should require authorization" do
|
||||
post 'remind', :course_id => @course.id, :rubric_association_id => @rubric_association.id, :assessment_request_id => @assessment_request.id
|
||||
assert_unauthorized
|
||||
end
|
||||
it "should send reminder" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
rubric_association_model(:user => @user, :context => @course)
|
||||
@assessment_request = @rubric_association.invite_assessors(@user, "bob@example.com", @rubric_association.association.submission_for_student(@user)).first
|
||||
user_session(@teacher)
|
||||
post 'remind', :course_id => @course.id, :rubric_association_id => @rubric_association.id, :assessment_request_id => @assessment_request.id
|
||||
assigns[:request].should_not be_nil
|
||||
assigns[:request].should eql(@assessment_request)
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST 'invite'" do
|
||||
it "should require authorization" do
|
||||
course_with_teacher(:active_all => true)
|
||||
rubric_association_model(:user => @user, :context => @course, :purpose => 'grading')
|
||||
post 'invite', :course_id => @course.id, :rubric_association_id => @rubric_association.id, :rubric_assessment => {:assessor_email => "bob@example.com"}
|
||||
assert_unauthorized
|
||||
end
|
||||
it "should send invitation" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
rubric_association_model(:user => @user, :context => @course, :purpose => 'grading')
|
||||
post 'invite', :course_id => @course.id, :rubric_association_id => @rubric_association.id, :rubric_assessment => {:assessor_email => "bob@example.com"}
|
||||
assigns[:assessment_request].should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "DELETE 'destroy'" do
|
||||
it "should require authorization" do
|
||||
course_with_teacher(:active_all => true)
|
||||
|
@ -207,7 +197,8 @@ describe RubricAssessmentsController do
|
|||
@assignment.update_attributes(:peer_review_count => 2)
|
||||
res = @assignment.assign_peer_reviews
|
||||
res.should_not be_empty
|
||||
res.length.should eql(6)
|
||||
# two of the six possible combinations have already been created
|
||||
res.length.should eql(4)
|
||||
res.to_a.find{|r| r.assessor == @student1 && r.user == @student2}.should_not be_nil
|
||||
|
||||
post 'create', :course_id => @course.id, :rubric_association_id => @rubric_association.id, :rubric_assessment => {:user_id => @student2.id, :assessment_type => 'peer_review'}
|
||||
|
@ -228,7 +219,9 @@ def setup_course_assessment
|
|||
@course.enroll_teacher(@teacher2).accept!
|
||||
@assignment = @course.assignments.create!(:title => "Some Assignment")
|
||||
rubric_assessment_model(:user => @user, :context => @course, :association => @assignment, :purpose => 'grading')
|
||||
@rubric_association.invite_assessor(@student1, @student2, @assignment.find_or_create_submission(@student1))
|
||||
@rubric_association.invite_assessor(@student1, @student3, @assignment.find_or_create_submission(@student1))
|
||||
@rubric_association.invite_assessor(@student1, @teacher2, @assignment.find_or_create_submission(@student1))
|
||||
student1_asset = @assignment.find_or_create_submission(@student1)
|
||||
student2_asset = @assignment.find_or_create_submission(@student2)
|
||||
student3_asset = @assignment.find_or_create_submission(@student3)
|
||||
@rubric_association.assessment_requests.create!(user: @student1, asset: student1_asset, assessor: @student2, assessor_asset: student2_asset)
|
||||
@rubric_association.assessment_requests.create!(user: @student1, asset: student1_asset, assessor: @student3, assessor_asset: student3_asset)
|
||||
end
|
||||
|
|
|
@ -34,15 +34,6 @@ describe RubricAssociationsController do
|
|||
assigns[:association].title.should eql("some association")
|
||||
response.should be_success
|
||||
end
|
||||
it "should invite users if specified" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
rubric_association_model(:user => @user, :context => @course, :purpose => 'grading')
|
||||
post 'create', :course_id => @course.id, :rubric_association => {:rubric_id => @rubric.id, :title => "some association", :invitations => "bob@example.com", :association_type => @rubric_association.association.class.name, :association_id => @rubric_association.association.id, :purpose => 'grading'}
|
||||
assigns[:association].should_not be_nil
|
||||
assigns[:association].title.should eql("some association")
|
||||
assigns[:association].assessment_requests.should_not be_empty
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT 'update'" do
|
||||
|
|
|
@ -64,17 +64,6 @@ describe RubricsController do
|
|||
assigns[:rubric].rubric_associations.length.should eql(1)
|
||||
response.should be_success
|
||||
end
|
||||
it "should invite users if specified" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
association = @course.assignments.create!(assignment_valid_attributes)
|
||||
post 'create', :course_id => @course.id, :rubric => {}, :rubric_association => {:association_type => association.class.to_s, :association_id => association.id, :invitations => "bob@example.com", :purpose => 'grading'}
|
||||
assigns[:rubric].should_not be_nil
|
||||
assigns[:rubric].should_not be_new_record
|
||||
assigns[:rubric].rubric_associations.length.should eql(1)
|
||||
assigns[:rubric].rubric_associations.first.assessment_requests.should_not be_empty
|
||||
assigns[:rubric].rubric_associations.first.assessment_requests.first.assessor.email.should eql("bob@example.com")
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT 'update'" do
|
||||
|
|
|
@ -47,7 +47,7 @@ describe RubricAssociation do
|
|||
"skip_updating_points_possible"=>false, "update_if_existing"=>true,
|
||||
"use_for_grading"=>"1", "association"=>@assignment}) #, "id"=>3})
|
||||
|
||||
@rubric_assoc = RubricAssociation.generate_with_invitees(@teacher, @rubric, @test_course, rubric_association)
|
||||
@rubric_assoc = RubricAssociation.generate(@teacher, @rubric, @test_course, rubric_association)
|
||||
|
||||
# students complete it
|
||||
@assignment.submit_homework(@student_1, :submission_type => 'online_text_entry', :body => 'Finished first')
|
||||
|
@ -96,7 +96,7 @@ describe RubricAssociation do
|
|||
"skip_updating_points_possible"=>false, "update_if_existing"=>true,
|
||||
"use_for_grading"=>"1", "association"=>@assignment}) #, "id"=>3})
|
||||
|
||||
@rubric_assoc = RubricAssociation.generate_with_invitees(@teacher, @rubric, @test_course, rubric_association)
|
||||
@rubric_assoc = RubricAssociation.generate(@teacher, @rubric, @test_course, rubric_association)
|
||||
end
|
||||
|
||||
it "should have 2 assessment_requests" do
|
||||
|
@ -116,7 +116,7 @@ describe RubricAssociation do
|
|||
rubric_params = HashWithIndifferentAccess.new({"title"=>"Some Rubric", "criteria"=>{"0"=>{"learning_outcome_id"=>"", "ratings"=>{"0"=>{"points"=>"5", "id"=>"blank", "description"=>"Full Marks"}, "1"=>{"points"=>"0", "id"=>"blank_2", "description"=>"No Marks"}}, "points"=>"5", "long_description"=>"", "id"=>"", "description"=>"Description of criterion"}}, "points_possible"=>"5", "free_form_criterion_comments"=>"0"})
|
||||
rubric_association_params = HashWithIndifferentAccess.new({:association=>@account, :hide_score_total=>"0", :use_for_grading=>"0", :purpose=>"bookmark"})
|
||||
#8864: the below raised a MethodNotFound error by trying to call @account.submissions
|
||||
lambda { @rubric.update_with_association(@user, rubric_params, @account, rubric_association_params, nil) }.should_not raise_error
|
||||
lambda { @rubric.update_with_association(@user, rubric_params, @account, rubric_association_params) }.should_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue