canvas-lms/lib/api/v1/group_category.rb

47 lines
1.7 KiB
Ruby
Raw Normal View History

#
# Copyright (C) 2013 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
module Api::V1::GroupCategory
include Api::V1::Json
include Api::V1::Context
include Api::V1::Progress
API_GROUP_CATEGORY_JSON_OPTS = {
:only => %w(id name role self_signup group_limit)
}
def group_category_json(group_category, user, session, options = {})
hash = api_json(group_category, user, session, API_GROUP_CATEGORY_JSON_OPTS)
hash.merge!(context_data(group_category))
if includes = options[:include]
if includes.include?('progress_url') && group_category.current_progress && group_category.current_progress.pending?
hash['progress'] = progress_json(group_category.current_progress, user, session)
end
if includes.include?('groups_count')
hash['groups_count'] = group_category.groups.active.size
end
if includes.include?('unassigned_users_count')
hash['unassigned_users_count'] = group_category.unassigned_users.count
end
add randomly assign unassigned users functionality to new group ui fixes CNVS-6732 normal test plan: 0) change the "true" on the first line of app/coffeescripts/bundles/manage_groups.coffee to "false" to enable the test bed (feel free to change the GroupCategory ID as well) 1) go to the new group ui test bed (http://localhost:3000/courses/1/groups) 2) ensure that the GroupCategory you pick is not student organized, nor self signup restricted 3) click the cog 4) click "Randomly Assign Students" 5) click "Okay" 6) verify that everything in the #content area is replaced with a progress bar 7) wait for the progress bar to reach 100% 8) verify that the #content area changes back to show the groups, with the previously unassigned students distributed among the available groups api test plan: 1) ensure delayed jobs is not running 2) navigate to the new group ui test bed 3) perform a random assignment, which should result in being stuck in progress 4) open up Postman in another tab 5) perform a GET request to http://localhost:3000/api/v1/group_categories/1 (replace the 1 with your test GroupCategory's ID) 6) verify that the response includes a progress 7) verify that if you refresh the tab you did the random assignment in, you still see a progress bar 8) start delayed jobs and verify that the progress bar completes 9) verify the api documentation for a GroupCategory now includes a progress description (look in the box under "A Group Category object looks like:") Change-Id: Ia8b24d899f428ad8ed50a9790a03802ca60d746d Reviewed-on: https://gerrit.instructure.com/22288 Reviewed-by: Mark Ericksen <marke@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Marc LeGendre <marc@instructure.com> QA-Review: Marc LeGendre <marc@instructure.com>
2013-07-13 04:45:49 +08:00
end
hash['protected'] = group_category.protected?
hash['allows_multiple_memberships'] = group_category.allows_multiple_memberships?
hash
end
end