assignment index add assignment dialog
closes CNVS-5682 test plan: - the 'Add Assignment' button at the top should go to the full assignment new page - the '+' button in each assignment group should pop up the assignment quick add dialog. - it should work Change-Id: Ic912ace112ca8f92461ef96bba2f9ef7d839f376 Reviewed-on: https://gerrit.instructure.com/21902 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cameron Sutter <csutter@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
bb4c489d1d
commit
3b75fd2f13
|
@ -2,14 +2,17 @@ define [
|
|||
'jquery'
|
||||
'underscore'
|
||||
'Backbone'
|
||||
'compiled/backbone-ext/DefaultUrlMixin'
|
||||
'compiled/models/TurnitinSettings'
|
||||
'compiled/collections/AssignmentOverrideCollection'
|
||||
], ($, _, {Model}, TurnitinSettings, AssignmentOverrideCollection ) ->
|
||||
], ($, _, {Model}, DefaultUrlMixin, TurnitinSettings, AssignmentOverrideCollection ) ->
|
||||
|
||||
class Assignment extends Model
|
||||
|
||||
@mixin DefaultUrlMixin
|
||||
resourceName: 'assignments'
|
||||
|
||||
urlRoot: -> @_defaultUrl()
|
||||
|
||||
initialize: ->
|
||||
overrides = @get('assignment_overrides')
|
||||
@set 'assignment_overrides',
|
||||
|
@ -57,7 +60,7 @@ define [
|
|||
@set 'points_possible', points
|
||||
|
||||
assignmentGroupId: (assignment_group_id) =>
|
||||
return @get 'assignment_group_id' unless assignment_group_id
|
||||
return @get 'assignment_group_id' unless arguments.length > 0
|
||||
@set 'assignment_group_id', assignment_group_id
|
||||
|
||||
canFreeze: =>
|
||||
|
|
|
@ -70,6 +70,7 @@ define [
|
|||
# @api public
|
||||
close: ->
|
||||
@dialog.close()
|
||||
@$trigger?.focus()
|
||||
|
||||
##
|
||||
# @api public
|
||||
|
|
|
@ -4,9 +4,10 @@ define [
|
|||
'compiled/collections/AssignmentCollection'
|
||||
'compiled/views/CollectionView'
|
||||
'compiled/views/assignments/AssignmentListItemView'
|
||||
'compiled/views/assignments/CreateAssignmentView'
|
||||
'compiled/views/assignments/CreateGroupView'
|
||||
'jst/assignments/teacher_index/AssignmentGroupListItem'
|
||||
], (I18n, _, AssignmentCollection, CollectionView, AssignmentListItemView, CreateGroupView, template) ->
|
||||
], (I18n, _, AssignmentCollection, CollectionView, AssignmentListItemView, CreateAssignmentView, CreateGroupView, template) ->
|
||||
|
||||
class AssignmentGroupListItemView extends CollectionView
|
||||
|
||||
|
@ -14,16 +15,20 @@ define [
|
|||
itemView: AssignmentListItemView
|
||||
template: template
|
||||
|
||||
@child 'createAssignmentView', '[data-view=createAssignment]'
|
||||
@child 'editGroupView', '[data-view=editAssignmentGroup]'
|
||||
|
||||
els: _.extend({}, @::els, {
|
||||
'.add_assignment': '$addAssignmentButton'
|
||||
'.edit_group': '$editGroupButton'
|
||||
})
|
||||
|
||||
afterRender: ->
|
||||
# child views so they get rendered automatically, need to stop it
|
||||
@createAssignmentView.hide()
|
||||
@editGroupView.hide()
|
||||
# its trigger would not be rendered yet, set it manually
|
||||
@createAssignmentView.setTrigger @$addAssignmentButton
|
||||
@editGroupView.setTrigger @$editGroupButton
|
||||
|
||||
initialize: ->
|
||||
|
@ -33,6 +38,9 @@ define [
|
|||
@editGroupView = new CreateGroupView
|
||||
assignmentGroup: @model
|
||||
assignments: @collection.models
|
||||
@createAssignmentView = new CreateAssignmentView
|
||||
assignmentGroup: @model
|
||||
collection: @collection
|
||||
|
||||
toJSON: ->
|
||||
count = @countRules()
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
define [
|
||||
'underscore'
|
||||
'compiled/views/DialogFormView'
|
||||
'compiled/models/Assignment'
|
||||
'jst/assignments/teacher_index/CreateAssignment'
|
||||
'jst/EmptyDialogFormWrapper'
|
||||
'jquery.instructure_date_and_time'
|
||||
], (_, DialogFormView, Assignment, template, wrapper) ->
|
||||
|
||||
class CreateAssignmentView extends DialogFormView
|
||||
defaults:
|
||||
width: 500
|
||||
height: 330
|
||||
|
||||
events: _.extend({}, @::events,
|
||||
'click .dialog_closer': 'close'
|
||||
'click .more_options': 'moreOptions'
|
||||
)
|
||||
|
||||
template: template
|
||||
wrapperTemplate: wrapper
|
||||
|
||||
@optionProperty 'assignmentGroup'
|
||||
@optionProperty 'collection'
|
||||
|
||||
initialize: ->
|
||||
super
|
||||
@generateNewModel()
|
||||
|
||||
onSaveSuccess: ->
|
||||
super
|
||||
@collection.add(@model)
|
||||
|
||||
@generateNewModel()
|
||||
@render()
|
||||
|
||||
moreOptions: ->
|
||||
data = @getFormData()
|
||||
params = ''
|
||||
separator = '?'
|
||||
_.each ['submission_types', 'name', 'due_at', 'points_possible'], (field) ->
|
||||
if data[field] && data[field] != ''
|
||||
params += "#{separator}#{field}=#{data[field]}"
|
||||
separator = '&' if separator == '?'
|
||||
|
||||
window.location = "#{ENV.NEW_ASSIGNMENT_URL}#{params}"
|
||||
|
||||
generateNewModel: ->
|
||||
@model = new Assignment
|
||||
@model.assignmentGroupId(@assignmentGroup.id) if @assignmentGroup
|
||||
|
||||
toJSON: ->
|
||||
json = @model.toJSON()
|
||||
_.extend(json, {
|
||||
label_id: @assignmentGroup.get('id')
|
||||
})
|
||||
|
||||
openAgain: ->
|
||||
super
|
||||
if !@$el.find(".datetime_field").hasClass("datetime_field_enabled")
|
||||
@$el.find(".datetime_field").datetime_field()
|
||||
|
|
@ -28,6 +28,7 @@ class AssignmentsController < ApplicationController
|
|||
before_filter :require_context
|
||||
add_crumb(proc { t '#crumbs.assignments', "Assignments" }, :except => [:destroy, :syllabus, :index]) { |c| c.send :course_assignments_path, c.instance_variable_get("@context") }
|
||||
before_filter { |c| c.active_tab = "assignments" }
|
||||
before_filter :normalize_title_param, :only => [:new, :edit]
|
||||
|
||||
def index
|
||||
if @context == @current_user || authorized_action(@context, @current_user, :read)
|
||||
|
@ -418,6 +419,12 @@ class AssignmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def normalize_title_param
|
||||
if title = params.delete(:name)
|
||||
params[:title] = title
|
||||
end
|
||||
end
|
||||
|
||||
def index_edit_params
|
||||
params.slice(*[:title, :due_at, :points_possible, :assignment_group_id])
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<a
|
||||
href="{{addAssignmentUrl}}"
|
||||
class="btn btn-primary"
|
||||
class="new_assignment btn btn-primary"
|
||||
role="button"
|
||||
title='{{#t "title_add_assignment"}}Add Assignment{{/t}}'
|
||||
>{{#t "add_assignment"}}Add Assignment{{/t}}</a>
|
||||
|
@ -40,6 +40,4 @@
|
|||
|
||||
<form data-view="createGroup" class="form-dialog"></form>
|
||||
|
||||
<form data-view="createAssignment" class="form-dialog"></form>
|
||||
|
||||
<form data-view="assignmentSettings" class="form-dialog"></form>
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
{{/ifAny}}
|
||||
|
||||
<a
|
||||
href="#"
|
||||
class="btn add_assignment"
|
||||
title='{{#t "add_assignment_to"}}Add Assignment to {{name}}{{/t}}'
|
||||
>
|
||||
{{! icon is separate from <a> tag because it is the only visible content in the button }}
|
||||
<span class="screenreader-only">{{#t "add_assignment_to"}}Add Assignment to {{name}}{{/t}}</span>
|
||||
<i class="icon-plus"></i>
|
||||
</a>
|
||||
|
||||
|
@ -52,5 +54,6 @@
|
|||
</div>
|
||||
|
||||
<ul class="collectionViewItems ig-list"></ul>
|
||||
<form data-view="createAssignment" class="form-dialog"></form>
|
||||
<form data-view="editAssignmentGroup" class="form-dialog"></form>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<div class="form-dialog-content">
|
||||
<div class="form-horizontal">
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="ag_{{label_id}}_assignment_type">
|
||||
{{#t "assignment_type"}}Type:{{/t}}
|
||||
</label>
|
||||
<div class="controls">
|
||||
<select type="text" id="ag_{{label_id}}_assignment_type" name="submission_types">
|
||||
<option value>{{#t "assignment"}}Assignment{{/t}}</option>
|
||||
<option value="discussion_topic">{{#t "discussion_type"}}Discussion{{/t}}</option>
|
||||
<option value="online_quiz">{{#t "quiz_type"}}Quiz{{/t}}</option>
|
||||
<option value="external_tool">{{#t "external_tool_type"}}External Tool{{/t}}</option>
|
||||
<option value="not_graded">{{#t "not_graded_type"}}Not Graded{{/t}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="ag_{{label_id}}_assignment_name">
|
||||
{{#t "assignment_name"}}Name:{{/t}}
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="ag_{{label_id}}_assignment_name" name="name" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="ag_{{label_id}}_assignment_due_at">
|
||||
{{#t "assignment_due_at"}}Due:{{/t}}
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input
|
||||
type="text"
|
||||
id="ag_{{label_id}}_assignment_due_at"
|
||||
class="datetime_field input-medium"
|
||||
name="due_at" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="ag_{{label_id}}_assignment_points">
|
||||
{{#t "assignment_points"}}Points:{{/t}}
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input
|
||||
type="text"
|
||||
id="ag_{{label_id}}_assignment_points"
|
||||
class="input-small"
|
||||
name="points_possible" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-controls">
|
||||
<button
|
||||
class="more_options btn pull-left"
|
||||
type="button"
|
||||
>{{#t "more"}}More Options{{/t}}</button>
|
||||
<button
|
||||
class="cancel_button btn dialog_closer"
|
||||
type="button"
|
||||
>{{#t "cancel"}}Cancel{{/t}}</button>
|
||||
<button
|
||||
class="create_assignment btn btn-primary"
|
||||
data-text-while-loading='{{#t "saving"}}Saving...{{/t}}'
|
||||
type="submit"
|
||||
>{{#t "save"}}Save{{/t}}</button>
|
||||
</div>
|
|
@ -87,7 +87,7 @@
|
|||
>{{#t "cancel"}}Cancel{{/t}}</button>
|
||||
<button
|
||||
class="create_group btn btn-primary"
|
||||
data-text-while-loading='{{#t "validating"}}Creating...{{/t}}'
|
||||
data-text-while-loading='{{#t "saving"}}Saving...{{/t}}'
|
||||
type="submit"
|
||||
>{{#t "save"}}Save{{/t}}</button>
|
||||
</div>
|
||||
|
|
|
@ -470,5 +470,59 @@ describe "assignments" do
|
|||
fj("#assignment_#{@asmnt.id} .delete_assignment_link").should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "draft state" do
|
||||
before do
|
||||
@course.root_account.tap{ |a| a.settings[:enable_draft] = true }.save!
|
||||
@course.require_assignment_group
|
||||
end
|
||||
|
||||
it "should go to the new assignment page from 'Add Assignment'" do
|
||||
get "/courses/#{@course.id}/assignments"
|
||||
wait_for_ajaximations
|
||||
|
||||
expect_new_page_load { f('.new_assignment').click }
|
||||
end
|
||||
|
||||
it "should allow quick-adding an assignment to a group" do
|
||||
ag = @course.assignment_groups.first
|
||||
|
||||
get "/courses/#{@course.id}/assignments"
|
||||
wait_for_ajaximations
|
||||
|
||||
|
||||
f("#assignment_group_#{ag.id} .add_assignment").click
|
||||
wait_for_ajaximations
|
||||
|
||||
replace_content(f("#ag_#{ag.id}_assignment_name"), "Do this")
|
||||
replace_content(f("#ag_#{ag.id}_assignment_points"), "13")
|
||||
fj('.create_assignment:visible').click
|
||||
wait_for_ajaximations
|
||||
|
||||
a = ag.reload.assignments.first
|
||||
a.name.should == "Do this"
|
||||
a.points_possible.should == 13
|
||||
|
||||
f("#assignment_group_#{ag.id} .ig-title").text.should match "Do this"
|
||||
end
|
||||
|
||||
it "should rembmer entered settings when 'more options' is pressed" do
|
||||
ag = @course.assignment_groups.first
|
||||
|
||||
get "/courses/#{@course.id}/assignments"
|
||||
wait_for_ajaximations
|
||||
|
||||
|
||||
f("#assignment_group_#{ag.id} .add_assignment").click
|
||||
wait_for_ajaximations
|
||||
|
||||
replace_content(f("#ag_#{ag.id}_assignment_name"), "Do this")
|
||||
replace_content(f("#ag_#{ag.id}_assignment_points"), "13")
|
||||
expect_new_page_load { fj('.more_options:visible').click }
|
||||
|
||||
get_value("#assignment_name").should == "Do this"
|
||||
get_value("#assignment_points_possible").should == "13"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue