Skip to content

Commit

Permalink
Added Post Assignment to SIS
Browse files Browse the repository at this point in the history
fixes SIS-214
fixes SIS-229
fixes SIS-230

TestPlan:
 - go to account settings and verify post grades feature is enabled
 - go to course settings and verify post grades feature is off
 - create a new assignment, verify "Post Assignment to SIS" checkbox is not present in the view
 - go to course settings and enable Post Grades
 - create a new assignment and verify Post Assignment to SIS is present in the view and checked. NOTE: it should be checked by default if this is a NEW assignment
 - save the assignment
 - edit the assignment again and the post grades checkbox should be true
 - uncheck the post assignment to sis checkbox, save
 - re-edit the assignment, the post grades checkbox should be unchecked

Conflicts:
	app/coffeescripts/models/Assignment.coffee

Change-Id: I34cba5add03b3cb935b502e47b4537bf93c5b7c1
Reviewed-on: https://gerrit.instructure.com/33411
Reviewed-by: Eric Adams <[email protected]>
QA-Review: Jeremy Putnam <[email protected]>
Reviewed-by: Duane Johnson <[email protected]>
Product-Review: Eric Adams <[email protected]>
Tested-by: Jenkins <[email protected]>
  • Loading branch information
Eric Adams committed Apr 25, 2014
1 parent cd60456 commit be040d6
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 21 deletions.
40 changes: 25 additions & 15 deletions app/coffeescripts/gradebook2/PostGradesDialog.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,37 @@ define [
postGrades: (e)->
json_to_post = {}
json_to_post['canvas_domain'] = document.domain
json_to_post['assignments'] = _.map(@model.get('assignments_to_post'), (assignment) -> assignment.id)
if @model.get('section_id')
json_to_post['section_id'] = @model.get('section_id')
$.ajax 'http://localhost:9292/grades/section/' + @model.get('section_id'), #need to add SIS APP endpoint to post data
type: 'POST'
data: JSON.stringify(json_to_post)
contentType: 'application/json; charset=utf-8'
error: (data) ->
$.flashError('An error occurred posting your grades. ' + "HTTP Error " + data.status + " : " + data.statusText)
success: (data) ->
$.flashMessage('Assignments are being posted.')
console.log(data)

@close()
else
json_to_post['course_id'] = @model.get('course_id')
$.ajax 'http://localhost:9292/grades/course' + @model.get('course_id'), #need to add SIS APP endpoint to post data
type: 'POST'
data: JSON.stringify(json_to_post)
contentType: 'application/json; charset=utf-8'
error: (data) ->
$.flashError('An error occurred posting your grades. ' + "HTTP Error " + data.status + " : " + data.statusText)
success: (data) ->
$.flashMessage('Assignments are being posted.')
console.log(data)

@close()



json_to_post['assignments'] = _.map(@model.get('assignments_to_post'), (assignment) -> assignment.id)

$.ajax 'http://localhost:4567/post', #need to add SIS APP endpoint to post data
type: 'POST'
data: JSON.stringify(json_to_post)
contentType: 'application/json; charset=utf-8'
error: (data) ->
window.response_data = data
$.flashError('An error occurred posting your grades. ' + "HTTP Error " + data.status + " : " + data.statusText)
console.log(data)
success: (data) ->
$.flashMessage('Assignments are being posted.')
window.data = data
console.log(data)

@close()



Expand Down
11 changes: 10 additions & 1 deletion app/coffeescripts/models/Assignment.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ define [
silent: true
if (all_dates = @get('all_dates'))?
@set 'all_dates', new DateGroupCollection(all_dates)
if (@postToSISEnabled())
unless @get('post_to_sis') == true || @get('post_to_sis') == false
@set 'post_to_sis', true

isQuiz: => @_hasOnlyType 'online_quiz'
isDiscussionTopic: => @_hasOnlyType 'discussion_topic'
Expand Down Expand Up @@ -65,6 +68,9 @@ define [
return @get 'name' unless arguments.length > 0
@set 'name', newName

postToSIS: =>
return @get 'post_to_sis' unless arguments.length > 0

pointsPossible: (points) =>
return @get('points_possible') || 0 unless arguments.length > 0
@set 'points_possible', points
Expand Down Expand Up @@ -235,6 +241,9 @@ define [
labelId: =>
return @id

postToSISEnabled: =>
return ENV.POST_TO_SIS

defaultDates: =>
group = new DateGroup
due_at: @get("due_at")
Expand Down Expand Up @@ -272,7 +281,7 @@ define [
'gradeGroupStudentsIndividually', 'groupCategoryId', 'frozen',
'frozenAttributes', 'freezeOnCopy', 'canFreeze', 'isSimple',
'gradingStandardId', 'isLetterGraded', 'isGpaScaled', 'assignmentGroupId', 'iconType',
'published', 'htmlUrl', 'htmlEditUrl', 'labelId', 'position',
'published', 'htmlUrl', 'htmlEditUrl', 'labelId', 'position', 'postToSIS',
'multipleDueDates', 'allDates', 'isQuiz', 'singleSectionDueDate'
]
hash = id: @get 'id'
Expand Down
3 changes: 3 additions & 0 deletions app/coffeescripts/views/assignments/EditView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ AssignmentGroupSelector, GroupCategorySelector, toggleAccessibly) ->
data = @assignment.toView()
_.extend data,
kalturaEnabled: ENV?.KALTURA_ENABLED or false
postToSISEnabled: ENV?.POST_TO_SIS or false
isLargeRoster: ENV?.IS_LARGE_ROSTER or false
submissionTypesFrozen: _.include(data.frozenAttributes, 'submission_types')

Expand All @@ -197,6 +198,8 @@ AssignmentGroupSelector, GroupCategorySelector, toggleAccessibly) ->
unless ENV?.IS_LARGE_ROSTER
data = @groupCategorySelector.filterFormData data
# should update the date fields.. pretty hacky.
unless data.post_to_sis
data.post_to_sis = false
@dueDateOverrideView.updateOverrides()
defaultDates = @dueDateOverrideView.getDefaultDueDate()
data.lock_at = defaultDates?.get('lock_at') or null
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/assignments_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@
# "example": 1,
# "type": "integer"
# },
# "post_to_sis": {
# "example": true,
# "type" : "boolean",
# "description" : "(optional, present if Post Grades to SIS feature is enabled)"
# },
# "muted": {
# "description": "whether the assignment is muted",
# "type": "integer"
Expand Down Expand Up @@ -658,7 +663,6 @@ def show
def create
@assignment = @context.assignments.build
@assignment.workflow_state = 'unpublished' if @context.feature_enabled?(:draft_state)

if authorized_action(@assignment, @current_user, :create)
save_and_render_response
end
Expand All @@ -682,7 +686,6 @@ def create
# @returns Assignment
def update
@assignment = @context.assignments.find(params[:id])

if authorized_action(@assignment, @current_user, :update)
save_and_render_response
end
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def create
group = get_assignment_group(params[:assignment])
@assignment ||= @context.assignments.build(params[:assignment])
@assignment.workflow_state ||= @context.feature_enabled?(:draft_state) ? "unpublished" : "published"
@assignment.post_to_sis ||= @context.feature_enabled?(:post_to_sis) ? true : false
@assignment.updating_user = @current_user
@assignment.content_being_saved_by(@current_user)
@assignment.assignment_group = group if group
Expand Down Expand Up @@ -354,7 +355,7 @@ def edit
@assignment.submission_types = params[:submission_types] if params[:submission_types]
@assignment.assignment_group_id = params[:assignment_group_id] if params[:assignment_group_id]
@assignment.ensure_assignment_group(false)

@assignment.post_to_sis = params[:post_to_sis] if params[:post_to_sis]
if @assignment.submission_types == 'online_quiz' && @assignment.quiz
return redirect_to edit_course_quiz_url(@context, @assignment.quiz, index_edit_params)
elsif @assignment.submission_types == 'discussion_topic' && @assignment.discussion_topic
Expand All @@ -374,6 +375,7 @@ def edit
:ASSIGNMENT_GROUPS => json_for_assignment_groups,
:GROUP_CATEGORIES => group_categories,
:KALTURA_ENABLED => !!feature_enabled?(:kaltura),
:POST_TO_SIS => @context.feature_enabled?(:post_grades),
:SECTION_LIST => (@context.course_sections.active.map { |section|
{:id => section.id, :name => section.name }
}),
Expand All @@ -400,6 +402,7 @@ def update
if authorized_action(@assignment, @current_user, :update)
params[:assignment][:time_zone_edited] = Time.zone.name if params[:assignment]
params[:assignment] ||= {}
@assignment.post_to_sis = params[:assignment][:post_to_sis]
@assignment.updating_user = @current_user
if params[:assignment][:default_grade]
params[:assignment][:overwrite_existing_grades] = (params[:assignment][:overwrite_existing_grades] == "1")
Expand Down
3 changes: 2 additions & 1 deletion app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Assignment < ActiveRecord::Base
:notify_of_update, :time_zone_edited, :turnitin_enabled,
:turnitin_settings, :context, :position, :allowed_extensions,
:external_tool_tag_attributes, :freeze_on_copy, :assignment_group_id,
:only_visible_to_overrides
:only_visible_to_overrides, :post_to_sis

attr_accessor :previous_id, :updating_user, :copying

Expand Down Expand Up @@ -124,6 +124,7 @@ def group_category_changes_ok?
all_day_date
created_at
updated_at
post_to_sis
)
# create a shim for plugins that use the old association name. this is
# TEMPORARY. the plugins should update to use the new association name, and
Expand Down
18 changes: 17 additions & 1 deletion app/views/jst/assignments/EditView.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@

</div>


<div class="control-group">

<div class="form-column-left no-group">
<label for="assignment_points_possible">
{{#t "points_possible"}}Points{{/t}}
Expand All @@ -61,11 +61,27 @@
</div>
</div>


<fieldset id="assignment_group_selector" class="control-group">
</fieldset>

<div id="grading_type_selector"></div>

{{#if postToSISEnabled}}
<div class="form-column-left"></div>
<div class="form-column-right">
<fieldset>
<label class="checkbox">
{{checkbox "postToSIS"
id="assignment_post_to_sis"
name="post_to_sis"
}}
{{#t "post_to_sis"}}Post to SIS{{/t}}
</label>
</fieldset>
</div>
{{/if}}

<div id="graded_assignment_fields"
aria-expanded="{{not isNotGraded}}"
style="{{hiddenIf isNotGraded}}">
Expand Down
9 changes: 9 additions & 0 deletions lib/api/v1/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Api::V1::Assignment
assignment_group_id
peer_reviews
automatic_peer_reviews
post_to_sis
grade_group_students_individually
group_category_id
grading_standard_id
Expand All @@ -46,6 +47,7 @@ module Api::V1::Assignment
points_possible
due_at
assignment_group_id
post_to_sis
)
}

Expand All @@ -67,6 +69,8 @@ def assignment_json(assignment, user, session, opts = {})
hash = api_json(assignment, user, session, fields)
hash['course_id'] = assignment.context_id
hash['name'] = assignment.title

hash['post_to_sis'] = assignment.post_to_sis
hash['submission_types'] = assignment.submission_types_array
hash['has_submitted_submissions'] = assignment.has_submitted_submissions?

Expand Down Expand Up @@ -403,6 +407,11 @@ def update_from_params(assignment, assignment_params)
end
end

if assignment.context.feature_enabled?(:post_grades)
if assignment_params.has_key? "post_to_sis"
assignment.post_to_sis = value_to_boolean(assignment_params['post_to_sis'])
end
end
assignment.updating_user = @current_user
assignment.attributes = update_params
assignment.infer_times
Expand Down

0 comments on commit be040d6

Please sign in to comment.