Skip to content

Commit

Permalink
Add an icon to quickly toggle post to SIS setting
Browse files Browse the repository at this point in the history
fixes CNVS-25467
fixes CNVS-25468

test plan:
- Go to assignment and quiz page
- Ensure that "Post grade to SIS enabled" icon is attached to
  all assignments that have the option enabled and that
  "Post grade to SIS disabled" icon is on the rest.
- Click "Post grade to SIS enabled" icon and ensure that
  it toggles on the screen and that the option toggles for the
  assignment
- Ensure that the icon is accesible
- Check that tooltip on icon is correct on both toggle positions
- Disable post grades to SIS at the account level
- Check both quizzes and assignments to ensure that the icon is
  no longer there

Change-Id: Ib6682a7ca4d77dcc9a5e05095e33920eac981e9b
Reviewed-on: https://gerrit.instructure.com/68635
Tested-by: Jenkins
Reviewed-by: Ryan Taylor <[email protected]>
QA-Review: Rajkumar Kethavath <[email protected]>
Product-Review: Jason Sparks <[email protected]>
  • Loading branch information
Davis McClellan committed Dec 15, 2015
1 parent 097c0d9 commit df114f4
Show file tree
Hide file tree
Showing 24 changed files with 286 additions and 18 deletions.
8 changes: 6 additions & 2 deletions .fontcustom-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"checksum": {
"previous": "2e26ccf447e726d45ebc10e81051358dbb016e7193463a6ffd9785df95970a5b",
"current": "2e26ccf447e726d45ebc10e81051358dbb016e7193463a6ffd9785df95970a5b"
"previous": "45d9b0691da78ff556bf10aeec96c955cfe96404dc5a5e5c34a63cdda6b647a5",
"current": "45d9b0691da78ff556bf10aeec96c955cfe96404dc5a5e5c34a63cdda6b647a5"
},
"fonts": [
"public/fonts/canvas/canvas-icons.ttf",
Expand Down Expand Up @@ -502,6 +502,10 @@
"codepoint": 61813,
"source": "public/fonts/icons/plus.svg"
},
"post-to-sis": {
"codepoint": 61880,
"source": "public/fonts/icons/post-to-sis.svg"
},
"prerequisite": {
"codepoint": 61814,
"source": "public/fonts/icons/prerequisite.svg"
Expand Down
2 changes: 1 addition & 1 deletion app/coffeescripts/models/Assignment.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ define [
'gradingStandardId', 'isLetterGraded', 'isGpaScaled', 'assignmentGroupId', 'iconType',
'published', 'htmlUrl', 'htmlEditUrl', 'labelId', 'position', 'postToSIS',
'multipleDueDates', 'nonBaseDates', 'allDates', 'isQuiz', 'singleSectionDueDate',
'moderatedGrading'
'moderatedGrading', 'postToSISEnabled'
]
if ENV.DIFFERENTIATED_ASSIGNMENTS_ENABLED
fields.push 'isOnlyVisibleToOverrides'
Expand Down
14 changes: 14 additions & 0 deletions app/coffeescripts/models/Quiz.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define [
lock_at: null
unpublishable: true
points_possible: null
post_to_sis: false

initialize: (attributes, options = {}) ->
super
Expand All @@ -33,10 +34,12 @@ define [
@initPointsCount()
@initAllDates()


# initialize attributes
initAssignment: ->
if @attributes.assignment
@set 'assignment', new Assignment(@attributes.assignment)
@set 'post_to_sis_enabled', @postToSISEnabled()

initAssignmentOverrides: ->
if @attributes.assignment_overrides
Expand All @@ -51,6 +54,7 @@ define [
@set 'edit_url', "#{@get 'base_url'}/#{@get 'id'}/edit"
@set 'publish_url', "#{@get 'base_url'}/publish"
@set 'unpublish_url', "#{@get 'base_url'}/unpublish"
@set 'toggle_post_to_sis_url', "#{@get 'base_url'}/#{@get 'id'}/toggle_post_to_sis"

initTitleLabel: ->
@set 'title_label', @get('title') or @get('readable_type')
Expand Down Expand Up @@ -106,6 +110,9 @@ define [
htmlUrl: =>
@get 'url'

togglePostToSISUrl: =>
@get 'toggle_post_to_sis_url'

defaultDates: =>
group = new DateGroup
due_at: @get("due_at")
Expand Down Expand Up @@ -136,6 +143,10 @@ define [
return @get('only_visible_to_overrides') || false unless arguments.length > 0
@set('only_visible_to_overrides', overrideFlag)

postToSIS: (postToSisBoolean) =>
return @get 'post_to_sis' unless arguments.length > 0
@set 'post_to_sis', postToSisBoolean

toView: =>
fields = [
'htmlUrl', 'multipleDueDates', 'nonBaseDates', 'allDates', 'dueAt', 'lockAt', 'unlockAt', 'singleSectionDueDate'
Expand All @@ -144,3 +155,6 @@ define [
for field in fields
hash[field] = @[field]()
hash

postToSISEnabled: =>
return ENV.FLAGS && ENV.FLAGS.post_to_sis_enabled
20 changes: 20 additions & 0 deletions app/coffeescripts/views/assignments/AssignmentListItemView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ define [
'click .delete_assignment': 'onDelete'
'click .tooltip_link': preventDefault ->
'keydown': 'handleKeys'
'click .post-to-sis-status': 'togglePostToSIS'

messages:
confirm: I18n.t('confirms.delete_assignment', 'Are you sure you want to delete this assignment?')
Expand Down Expand Up @@ -262,6 +263,25 @@ define [
editItem: =>
@$("#assignment_#{@model.id}_settings_edit_item").click()

togglePostToSIS: (e) =>
c = @model.postToSIS()
@model.postToSIS(!c)
e.preventDefault()
$t = $(e.currentTarget)
@model.save({}, {
success: =>
if c
$t.removeClass('post-to-sis-status enabled')
$t.addClass('post-to-sis-status disabled')
$t.find('.icon-post-to-sis').prop('title', I18n.t("Post grade to SIS disabled. Click to toggle."))
$t.find('.screenreader-only').text(I18n.t("The grade for this assignment will not sync to the student information system. Click here to toggle this setting."))
else
$t.removeClass('post-to-sis-status disabled')
$t.addClass('post-to-sis-status enabled')
$t.find('.icon-post-to-sis').prop('title', I18n.t("Post grade to SIS enabled. Click to toggle."))
$t.find('.screenreader-only').text(I18n.t("The grade for this assignment will sync to the student information system. Click here to toggle this setting."))
})

deleteItem: =>
@$("#assignment_#{@model.id}_settings_delete_item").click()

Expand Down
20 changes: 20 additions & 0 deletions app/coffeescripts/views/quizzes/QuizItemView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ define [
events:
'click': 'clickRow'
'click .delete-item': 'onDelete'
'click .post-to-sis-status': 'togglePostToSIS'

messages:
confirm: I18n.t('confirms.delete_quiz', 'Are you sure you want to delete this quiz?')
Expand Down Expand Up @@ -81,6 +82,25 @@ define [
updatePublishState: =>
@$('.ig-row').toggleClass('ig-published', @model.get('published'))

togglePostToSIS: (e) =>
c = @model.postToSIS()
@model.postToSIS(!c)
e.preventDefault()
$t = $(e.currentTarget)
@model.save({}, { type: 'POST', url: @model.togglePostToSISUrl(),
success: =>
if c
$t.removeClass('post-to-sis-status enabled')
$t.addClass('post-to-sis-status disabled')
$t.find('.icon-post-to-sis').prop('title', I18n.t("Post grade to SIS disabled. Click to toggle."))
$t.find('.screenreader-only').text(I18n.t("The grade for this assignment will not sync to the student information system. Click here to toggle this setting."))
else
$t.removeClass('post-to-sis-status disabled')
$t.addClass('post-to-sis-status enabled')
$t.find('.icon-post-to-sis').prop('title', I18n.t("Post grade to SIS enabled. Click to toggle."))
$t.find('.screenreader-only').text(I18n.t("The grade for this assignment will sync to the student information system. Click here to toggle this setting."))
})

canManage: ->
ENV.PERMISSIONS.manage

Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,7 @@ def set_js_assignment_data
:context_modules_url => api_v1_course_context_modules_path(@context),
:course_student_submissions_url => api_v1_course_student_submissions_url(@context)
},
:POST_TO_SIS => Assignment.sis_grade_export_enabled?(@context),
:PERMISSIONS => permissions,
:DIFFERENTIATED_ASSIGNMENTS_ENABLED => @context.feature_enabled?(:differentiated_assignments),
:VALID_DATE_RANGE => CourseDateRange.new(@context),
Expand Down
17 changes: 15 additions & 2 deletions app/controllers/quizzes/quizzes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Quizzes::QuizzesController < ApplicationController
:read_only,
:managed_quiz_data,
:submission_versions,
:submission_html
:submission_html,
:toggle_post_to_sis
]
before_filter :set_download_submission_dialog_title , only: [:show,:statistics]
after_filter :lock_results, only: [ :show, :submission_html ]
Expand Down Expand Up @@ -121,7 +122,8 @@ def index
read_question_banks: can_manage || can_do(@context, @current_user, :read_question_banks)
},
:FLAGS => {
question_banks: feature_enabled?(:question_banks)
question_banks: feature_enabled?(:question_banks),
post_to_sis_enabled: Assignment.sis_grade_export_enabled?(@context)
},
:quiz_menu_tools => external_tools_display_hashes(:quiz_menu)
})
Expand Down Expand Up @@ -484,6 +486,17 @@ def unpublish
end
end

def toggle_post_to_sis
if authorized_action(@quiz, @current_user, :update)
@quiz.post_to_sis = params[:post_to_sis]
@quiz.save!
respond_to do |format|
format.html { redirect_to named_context_url(@context, :context_quizzes_url) }
format.json { render :json => {}, :status => :ok }
end
end
end

# student_analysis report
def statistics
if @context.feature_enabled?(:quiz_stats)
Expand Down
9 changes: 9 additions & 0 deletions app/models/quizzes/quiz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,15 @@ def statistics_csv(report_type, options = {})
end
end

def post_to_sis=(post_to_sis)
return unless assignment
assignment.post_to_sis = post_to_sis
end

def post_to_sis?
assignment && assignment.post_to_sis
end

def unpublished_changes?
self.last_edited_at && self.published_at && self.last_edited_at > self.published_at
end
Expand Down
6 changes: 5 additions & 1 deletion app/serializers/quizzes/quiz_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class QuizSerializer < Canvas::APISerializer
:quiz_submissions_zip_url, :preview_url, :quiz_submission_versions_html_url,
:assignment_id, :one_time_results, :only_visible_to_overrides,
:assignment_group_id, :show_correct_answers_last_attempt, :version_number,
:question_types, :has_access_code
:question_types, :has_access_code, :post_to_sis

def_delegators :@controller,
# :api_v1_course_assignment_group_url,
Expand Down Expand Up @@ -351,5 +351,9 @@ def user_finder
def has_file_uploads?
quiz.has_file_upload_question?
end

def post_to_sis
quiz.post_to_sis?
end
end
end
7 changes: 4 additions & 3 deletions app/stylesheets/components/_canvas-icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ Either use `<a>` with icon desired icon class added or insert `<i>` inside `<but
<span class="span3"><i class="icon-equation"></i> icon-equation</span>
<span class="span3"><i class="icon-commons"></i> icon-commons</span>
</div>
<div class="row-fluid">
<span class="span3"><i class="icon-post-to-sis"></i> icon-post-to-sis</span>
</div>
*/


Expand Down Expand Up @@ -519,6 +522,7 @@ h1, h2, h3, h4, .h1, .h2, .h3, .h4, p {
.icon-pin:before { content: "\f173"; }
.icon-pinterest:before { content: "\f174"; }
.icon-plus:before { content: "\f175"; }
.icon-post-to-sis:before { content: "\f1b8"; }
.icon-prerequisite:before { content: "\f176"; }
.icon-printer:before { content: "\f177"; }
.icon-publish:before { content: "\f178"; }
Expand Down Expand Up @@ -588,6 +592,3 @@ span.screen-reader-text {
left: -9999px;
font-size: 4px;
}



1 change: 1 addition & 0 deletions app/stylesheets/components/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@import "item-groups";
@import "item-groups-condensed";
@import "publish-state";
@import "post-to-sis-state";
@import "pill";
@import "alerts";
@import "tour-popovers";
Expand Down
19 changes: 19 additions & 0 deletions app/stylesheets/components/_post-to-sis-state.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.post-to-sis-status {
transition: none;
padding-left: 9px;
margin-right: 18px;
vertical-align: text-top;
line-height: 17px;
cursor: pointer;

&.enabled {
font-weight: bold;
@if $use_high_contrast { color: darken($ic-color-success, 4%); }
@else { color: $ic-color-success; }
}

&.disabled {
font-weight: normal;
color: $ic-color-icon-disabled;
}
}
2 changes: 1 addition & 1 deletion app/stylesheets/pages/quizzes/_quizzes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $answersSprite: url(/images/answers_sprite.png);
// quiz index
li.quiz {
cursor: pointer;
.ellipses, i[class^=icon-]:not(.icon-publish):not(.icon-quiz) {
.ellipses, i[class^=icon-]:not(.icon-publish):not(.icon-quiz):not(.icon-post-to-sis) {
color: darken($ic-color-neutral, 40);
}
.ig-title {
Expand Down
14 changes: 14 additions & 0 deletions app/views/jst/assignments/AssignmentListItem.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@

{{#if canManage}}
<div class="ig-admin">
{{#if postToSISEnabled}}
{{#if postToSIS}}
<span class="post-to-sis-status enabled">
<i class="icon-post-to-sis" title='{{#t}}Post grade to SIS enabled. Click to toggle.{{/t}}' data-tooltip></i>
<span class="screenreader-only">{{#t}}The grade for this assignment will sync to the student information system. Click to here to toggle this setting.{{/t}}</span>
</span>
{{else}}
<span class="post-to-sis-status disabled">
<i class="icon-post-to-sis" title='{{#t}}Post grade to SIS disabled. Click to toggle.{{/t}}' data-tooltip></i>
<span class="screenreader-only">{{#t}}The grade for this assignment will not sync to the student information system. Click here to toggle this setting.{{/t}}</span>
</span>
{{/if}}
{{/if}}

<span class="publish-icon" data-view="publish-icon"></span>

<div class="inline-block">
Expand Down
14 changes: 14 additions & 0 deletions app/views/jst/quizzes/QuizItemView.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@

{{#if can_update}}
<div class="ig-admin">

{{#if post_to_sis_enabled}}
{{#if post_to_sis}}
<span class="post-to-sis-status enabled">
<i class="icon-post-to-sis" title='{{#t}}Post grade to SIS enabled. Click to toggle.{{/t}}' data-tooltip></i>
<span class="screenreader-only">{{#t}}The grade for this assignment will sync to the student information system. Click here to toggle this setting.{{/t}}</span>
</span>
{{else}}
<span class="post-to-sis-status disabled">
<i class="icon-post-to-sis" title='{{#t}}Post grade to SIS disabled. Click to toggle.{{/t}}' data-tooltip></i>
<span class="screenreader-only">{{#t}}The grade for this assignment will not sync to the student information system. Click here to toggle this setting.{{/t}}</span>
</span>
{{/if}}
{{/if}}
<span data-view="publish-icon" class="publish-icon"></span>

<div class="inline-block">
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@

post 'quizzes/publish' => 'quizzes/quizzes#publish'
post 'quizzes/unpublish' => 'quizzes/quizzes#unpublish'
post 'quizzes/:id/toggle_post_to_sis' => "quizzes/quizzes#toggle_post_to_sis"

resources :quizzes, controller: 'quizzes/quizzes' do
get :managed_quiz_data
Expand Down
Binary file modified public/fonts/canvas/canvas-icons.eot
Binary file not shown.
12 changes: 7 additions & 5 deletions public/fonts/canvas/canvas-icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/fonts/canvas/canvas-icons.ttf
Binary file not shown.
Binary file modified public/fonts/canvas/canvas-icons.woff
Binary file not shown.
Loading

0 comments on commit df114f4

Please sign in to comment.