add teacher configuration of student organized group enrollment type
fixes CNVS-9363 test plan: * create a student organized group * log in as a teacher * go to the new group management page * select the "Student Groups" group set * click on the "+ Group" button * verify that you can select a join level ** (either "Members are free to join" or ** "Invitation only") * select "Members are free to join" * enter a group name * hit save * log in as a student * go to /courses/:course_id/groups * verify that the group you created appears ** in the "Available Groups" listing ******************************************* * log in as a teacher * verify that the "Joining" option only appears ** when adding or editing a group in the ** Student Groups group set Change-Id: I42c49869d68bebd6deb0ba9beff1fd0e94871911 Reviewed-on: https://gerrit.instructure.com/26304 Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Marc LeGendre <marc@instructure.com> QA-Review: Marc LeGendre <marc@instructure.com> Reviewed-by: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
1fcd03df66
commit
bbcc385704
|
@ -57,7 +57,7 @@ define [
|
|||
|
||||
addGroup: (e) ->
|
||||
e.preventDefault()
|
||||
@createView ?= new GroupEditView({editing: false, focusReturnsTo: => @$el.find('.add-group')})
|
||||
@createView ?= new GroupEditView({groupCategory: @model, editing: false, focusReturnsTo: => @$el.find('.add-group')})
|
||||
new_group = new Group(group_category_id: @model.id)
|
||||
new_group.on 'sync', _.once =>
|
||||
@collection.add(new_group)
|
||||
|
|
|
@ -8,6 +8,8 @@ define [
|
|||
|
||||
class GroupEditView extends DialogFormView
|
||||
|
||||
@optionProperty 'groupCategory'
|
||||
|
||||
defaults:
|
||||
width: 550
|
||||
title: I18n.t "edit_group", "Edit Group"
|
||||
|
@ -51,3 +53,11 @@ define [
|
|||
|
||||
checkEsc: (e) =>
|
||||
@close() if e.keyCode is 27 # escape
|
||||
|
||||
toJSON: ->
|
||||
json = super
|
||||
if groupCategory = @model.collection?.category
|
||||
json.role = groupCategory.get('role')
|
||||
else
|
||||
json.role = @groupCategory.get('role')
|
||||
json
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label" for="group_category_name">{{#t "group_name"}}Group Name{{/t}}</label>
|
||||
<label class="control-label" for="group_name">{{#t "group_name"}}Group Name{{/t}}</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="group_category_name" name='name' value="{{name}}"
|
||||
<input type="text" id="group_name" name='name' value="{{name}}"
|
||||
placeholder="{{#t "group_name"}}Group Name{{/t}}">
|
||||
</div>
|
||||
</div>
|
||||
{{#ifEqual role "student_organized"}}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="group_join_level">{{#t "group_join_level"}}Joining{{/t}}</label>
|
||||
<div class="controls">
|
||||
<select id="group_join_level" name="join_level">
|
||||
<option value="parent_context_auto_join">{{#t "open"}}Members are free to join{{/t}}</option>
|
||||
<option value="invitation_only" {{selectedIf join_level "invitation_only"}}>{{#t "invitation_only"}}Invitation only{{/t}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{/ifEqual}}
|
||||
|
||||
<div class="form-controls">
|
||||
<button class="btn dialog_closer" type="button"
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
define [
|
||||
'jquery'
|
||||
'compiled/models/GroupCategory'
|
||||
'compiled/models/Group'
|
||||
'compiled/views/groups/manage/GroupEditView'
|
||||
], ($, GroupCategory, Group, GroupEditView) ->
|
||||
|
||||
view = null
|
||||
groupCategory = null
|
||||
group = null
|
||||
|
||||
module 'GroupEditView',
|
||||
setup: ->
|
||||
group = new Group
|
||||
id: 42
|
||||
name: 'Foo Group'
|
||||
members_count: 7
|
||||
groupCategory = new GroupCategory()
|
||||
view = new GroupEditView({groupCategory: groupCategory, editing: false, model: group})
|
||||
view.render()
|
||||
view.$el.appendTo($(document.body))
|
||||
|
||||
teardown: ->
|
||||
view.remove()
|
||||
|
||||
test 'renders join level in add group dialog for student organized group categories', ->
|
||||
view.groupCategory.set('role': 'student_organized')
|
||||
view.render()
|
||||
$group_join_level_select = $('#group_join_level')
|
||||
equal $group_join_level_select.length, 1
|
||||
|
||||
test 'does not render join level in add group dialog for non student organized group categories', ->
|
||||
$group_join_level_select = $('#group_join_level')
|
||||
equal $group_join_level_select.length, 0
|
||||
|
||||
test 'editing group should change name', ->
|
||||
url = "/api/v1/groups/#{view.model.get('id')}"
|
||||
new_name = 'Newly changed name'
|
||||
server = sinon.fakeServer.create()
|
||||
server.respondWith url, [
|
||||
200
|
||||
'Content-Type': 'application/json'
|
||||
JSON.stringify {
|
||||
id: 42
|
||||
name: new_name}
|
||||
]
|
||||
# verify it opens with the current group name displayed
|
||||
equal $('#group_name').val(), group.get('name')
|
||||
# set a new name
|
||||
$('#group_name').val(new_name)
|
||||
$(".group-edit-dialog button[type=submit]").click()
|
||||
server.respond()
|
||||
|
||||
equal group.get('name'), new_name
|
|
@ -74,26 +74,3 @@ define [
|
|||
|
||||
server.restore()
|
||||
confirmStub.restore()
|
||||
|
||||
test 'editing group should change name', ->
|
||||
url = "/api/v1/groups/#{view.model.get('id')}"
|
||||
new_name = 'Newly changed name'
|
||||
server = sinon.fakeServer.create()
|
||||
server.respondWith url, [
|
||||
200
|
||||
'Content-Type': 'application/json'
|
||||
JSON.stringify {
|
||||
id: 42
|
||||
name: new_name}
|
||||
]
|
||||
|
||||
# when
|
||||
view.$('.edit-group').click()
|
||||
# verify it opens with the current group name displayed
|
||||
equal $('#group_category_name').val(), group.get('name')
|
||||
# set a new name
|
||||
$('#group_category_name').val(new_name)
|
||||
$(".group-edit-dialog button[type=submit]").click()
|
||||
server.respond()
|
||||
|
||||
equal group.get('name'), new_name
|
||||
|
|
|
@ -67,7 +67,7 @@ describe "manage groups" do
|
|||
# click the first visible "Add Group" button
|
||||
fj(".add-group:visible:first").click
|
||||
wait_for_animations
|
||||
f("#group_category_name").send_keys("New Test Group A")
|
||||
f("#group_name").send_keys("New Test Group A")
|
||||
f("form.group-edit-dialog").submit
|
||||
wait_for_ajaximations
|
||||
|
||||
|
|
Loading…
Reference in New Issue