Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ def web_index(conferences)
@render_alternatives = WebConference.conference_types(@context).all? { |ct| ct[:replace_with_alternatives] }
case @context
when Course
@sections = @context.course_sections
@groups = @context.active_groups

@group_user_ids_map = @groups.to_a.reduce({}) do |acc, group|
acc[group.id] = group.participating_users_in_context.map{|u| u.id.to_s}
acc
end

@section_user_ids_map = @sections.to_a.reduce({}) do |acc, section|
acc[section.id] = section.participants.map{|u| u.id.to_s}
acc
end
@users = User.where(:id => @context.current_enrollments.not_fake.active_by_date.where.not(:user_id => @current_user).select(:user_id)).
order(User.sortable_name_order_by_clause).to_a
@render_alternatives ||= @context.settings[:show_conference_alternatives].present?
Expand All @@ -288,6 +300,8 @@ def web_index(conferences)
@users = @context.users.where("users.id<>?", @current_user).order(User.sortable_name_order_by_clause).to_a.uniq
end
end
@groups ||= []
@sections ||= []

# exposing the initial data as json embedded on page.
js_env(
Expand All @@ -296,6 +310,10 @@ def web_index(conferences)
default_conference: default_conference_json(@context, @current_user, session),
conference_type_details: conference_types_json(WebConference.conference_types(@context)),
users: @users.map { |u| {:id => u.id, :name => u.last_name_first} },
groups: @groups.map { |g| {:id => g.id, :name => g.full_name} },
sections: @sections.map { |s| {:id => s.id, :name => s.display_name} },
group_user_ids_map: @group_user_ids_map,
section_user_ids_map: @section_user_ids_map,
can_create_conferences: @context.grants_right?(@current_user, session, :create_conferences),
render_alternatives: @render_alternatives
)
Expand Down
272 changes: 271 additions & 1 deletion spec/javascripts/jsx/conferences/EditConferenceViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ QUnit.module('EditConferenceView', {
this.datepickerSetting = {field: 'datepickerSetting', type: 'date_picker'}
fakeENV.setup({
conference_type_details: [{settings: [this.datepickerSetting]}],
users: [{id: 1, name: 'Owlswick Clamp'}]
users: [
{id: 1, name: 'Owlswick Clamp'},
{id: 2, name: 'Abby Zollinger'},
{id: 3, name: 'Bruce Young'}
],
sections: [
{id: 1, name: 'Section 1'},
{id: 2, name: 'Section 2'}
],
groups: [
{id: 1, name: 'Study Group 1'},
{id: 2, name: 'Study Group 2'}
],
section_user_ids_map: {1: [1, 2], 2: [3]},
group_user_ids_map: {1: [1], 2: [1, 2]}
})
},
teardown() {
Expand Down Expand Up @@ -129,3 +143,259 @@ test('"remove observers" modifies "invite all course members"', function() {
ok(this.view.$('#members_list').is(':visible'))
ok(this.view.$('#observers_remove').is(':disabled'))
})

test('sections should appear in member list if course has more than one section', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
ok(this.view.$('#section_1').is(':visible'))
ok(this.view.$('#section_2').is(':visible'))
})

test('sections should not appear in member list if course has only section', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

window.ENV.sections = [{name: 'Section 1', id: 1}]

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
ok(!this.view.$('#section_1').is(':visible'))
})

test('groups should appear in member list if course has one or more groups', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
ok(this.view.$('#group_1').is(':visible'))
})

test('checking/unchecking a section also checks/unchecks the members that are in that section', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
this.view.$('#section_2').click()
ok(!this.view.$('#user_1').is(':checked'))
this.view.$('#section_1').click()
ok(this.view.$('#user_1').is(':checked'))
this.view.$('#section_1').click()
ok(!this.view.$('#user_1').is(':checked'))
})

test('checking/unchecking a groups also checks/unchecks the members that are in that group', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
ok(!this.view.$('#user_1').is(':checked'))
this.view.$('#group_1').click()
ok(this.view.$('#user_1').is(':checked'))
this.view.$('#group_1').click()
ok(!this.view.$('#user_1').is(':checked'))
})

test('unchecking a group only unchecks members that have not been selected by section also', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
ok(!this.view.$('#user_1').is(':checked'))
this.view.$('#group_1').click()
this.view.$('#section_1').click()

ok(this.view.$('#user_1').is(':checked'))
ok(this.view.$('#user_2').is(':checked'))
this.view.$('#group_1').click()
ok(this.view.$('#user_1').is(':checked'))
})

test('unchecking a section only unchecks members that have not been selected by group also', function() {
const attributes = {
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}

const conference = new Conference(attributes)
this.view.show(conference)
this.view.$('#user_all').click()
ok(!this.view.$('#user_1').is(':checked'))
this.view.$('#group_1').click()
this.view.$('#section_1').click()

ok(this.view.$('#user_1').is(':checked'))
ok(this.view.$('#user_2').is(':checked'))
this.view.$('#section_1').click()
ok(this.view.$('#user_1').is(':checked'))
ok(!this.view.$('#user_2').is(':checked'))
})

test('While editing a conference the box for a group should be checked and disabled if everyone in the group is a participant', function() {
const attributes = {
title: 'Making Money',
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
},
user_ids: [1]
}
const conference = new Conference(attributes)
this.view.show(conference, {isEditing: true})

ok(this.view.$('#group_1').is(':checked'))
ok(this.view.$('#group_1').is(':disabled'))
})

test('While editing a conference the box for a section should be checked and disabled if everyone in the section is a participant', function() {
const attributes = {
title: 'Making Money',
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
},
user_ids: [3]
}
const conference = new Conference(attributes)
this.view.show(conference, {isEditing: true})

ok(this.view.$('#section_2').is(':checked'))
ok(this.view.$('#section_2').is(':disabled'))
})

test('While editing a conference unchecking a group should only uncheck members who are not a part of the existing conference', function() {
const attributes = {
title: 'Making Money',
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
},
user_ids: [1]
}
const conference = new Conference(attributes)
this.view.show(conference, {isEditing: true})
ok(!this.view.$('#group_2').is(':checked'))
ok(!this.view.$('#user_2').is(':checked'))

this.view.$('#group_2').click()
ok(this.view.$('#user_1').is(':checked'))
ok(this.view.$('#user_2').is(':checked'))

this.view.$('#group_2').click()
ok(this.view.$('#user_1').is(':checked'))
ok(!this.view.$('#user_2').is(':checked'))
})

test('While editing a conference unchecking a section should only uncheck member who are not a part of the existing conference', function() {
const attributes = {
title: 'Making Money',
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
},
user_ids: [1]
}
const conference = new Conference(attributes)
this.view.show(conference, {isEditing: true})
ok(!this.view.$('#section_1').is(':checked'))
ok(!this.view.$('#user_2').is(':checked'))

this.view.$('#section_1').click()
ok(this.view.$('#user_1').is(':checked'))
ok(this.view.$('#user_2').is(':checked'))

this.view.$('#section_1').click()
ok(this.view.$('#user_1').is(':checked'))
ok(!this.view.$('#user_2').is(':checked'))
})

test('while context_is_group = true no sections or groups should appear in the member list', function() {
const attributes = {
title: 'Making Money',
recordings: [],
user_settings: {
scheduled_date: new Date()
},
permissions: {
update: true
}
}
window.ENV.context_is_group = true
const conference = new Conference(attributes)
this.view.show(conference)
ok(!this.view.$('#section_1').is(':visible'))
ok(!this.view.$('#section_2').is(':visible'))
ok(!this.view.$('#group_1').is(':visible'))
ok(!this.view.$('#group_2').is(':visible'))
})
Loading