diff --git a/app/controllers/assignments_api_controller.rb b/app/controllers/assignments_api_controller.rb
index 126c0a1611a..8b77788b71a 100644
--- a/app/controllers/assignments_api_controller.rb
+++ b/app/controllers/assignments_api_controller.rb
@@ -42,6 +42,7 @@ class AssignmentsApiController < ApplicationController
# @response_field rubric [Rubric]
# A list of rows and ratings for each row. TODO: need more discussion of the
# rubric data format and usage for grading.
+ # @response_field group_category_id [Integer] The unique identifier of the assignment's group set (if this is a group assignment)
#
# @example_response
# [
@@ -57,7 +58,7 @@ class AssignmentsApiController < ApplicationController
# "online_text_entry",
# "online_url",
# "media_recording"
- # ]
+ # ],
# "use_rubric_for_grading": true,
# "rubric": [
# {
@@ -99,7 +100,8 @@ class AssignmentsApiController < ApplicationController
# "id": "crit2",
# "description": "Crit2"
# }
- # ]
+ # ],
+ # "group_category_id: 1
# }
# ]
def index
diff --git a/app/controllers/submissions_api_controller.rb b/app/controllers/submissions_api_controller.rb
index 27a8b61867f..651ae74f207 100644
--- a/app/controllers/submissions_api_controller.rb
+++ b/app/controllers/submissions_api_controller.rb
@@ -164,6 +164,8 @@ class SubmissionsApiController < ApplicationController
#
# @argument comment[text_comment] Add a textual comment to the submission.
#
+ # @argument comment[group_comment] [Boolean] Whether or not this comment should be sent to the entire group (defaults to false). Ignored if this is not a group assignment or if no text_comment is provided.
+ #
# @argument submission[posted_grade] Assign a score to the submission,
# updating both the "score" and "grade" fields on the submission record.
# This parameter can be passed in a few different formats:
@@ -254,8 +256,9 @@ class SubmissionsApiController < ApplicationController
# but we need to implement a way to abstract it away from kaltura and
# make it generic. This will probably involve a proxy outside of
# rails.
- comment.slice(:media_comment_id, :media_comment_type))
- @submission.add_comment(comment)
+ comment.slice(:media_comment_id, :media_comment_type, :group_comment)
+ ).with_indifferent_access
+ @assignment.update_submission(@submission.user, comment)
end
# We need to reload because some of this stuff is getting set on the
# submission without going through the model instance -- it'd be nice to
diff --git a/app/models/assignment.rb b/app/models/assignment.rb
index fd9cfe71f3d..aa961764471 100644
--- a/app/models/assignment.rb
+++ b/app/models/assignment.rb
@@ -956,7 +956,7 @@ class Assignment < ActiveRecord::Base
end
students.each do |student|
- if (opts['comment'] && opts['group_comment'] == "1") || student == original_student
+ if (opts['comment'] && Canvas::Plugin.value_to_boolean(opts['group_comment'])) || student == original_student
s = self.find_or_create_submission(student)
s.assignment_id = self.id
s.user_id = student.id
@@ -974,11 +974,12 @@ class Assignment < ActiveRecord::Base
# Only allow a few fields to be submitted. Cannot submit the grade of a
# homework assignment, for instance.
opts.keys.each { |k|
- opts.delete(k) unless [:body, :url, :attachments, :submission_type, :comment, :media_comment_id, :media_comment_type].include?(k.to_sym)
+ opts.delete(k) unless [:body, :url, :attachments, :submission_type, :comment, :media_comment_id, :media_comment_type, :group_comment].include?(k.to_sym)
}
raise "Student Required" unless original_student
raise "User must be enrolled in the course as a student to submit homework" unless context.students.include?(original_student)
- comment = opts.delete :comment
+ comment = opts.delete(:comment)
+ group_comment = opts.delete(:group_comment)
group, students = group_students(original_student)
homeworks = []
primary_homework = nil
@@ -1018,7 +1019,7 @@ class Assignment < ActiveRecord::Base
primary_homework.broadcast_group_submission if group
homeworks.each do |homework|
context_module_action(homework.student, :submitted)
- homework.add_comment({:comment => comment, :author => original_student, :unique_key => ts}) if comment
+ homework.add_comment({:comment => comment, :author => original_student, :unique_key => ts}) if comment && (group_comment || homework == primary_homework)
end
touch_context
return primary_homework
diff --git a/app/models/stream_item.rb b/app/models/stream_item.rb
index 394f7727ec4..0f1cc94fe7e 100644
--- a/app/models/stream_item.rb
+++ b/app/models/stream_item.rb
@@ -152,7 +152,7 @@ class StreamItem < ActiveRecord::Base
when Submission
res = object.attributes
res.delete 'body' # this can be pretty large, and we don't display it
- res['assignment'] = object.assignment.attributes.slice('id', 'title', 'due_at', 'points_possible', 'submission_types')
+ res['assignment'] = object.assignment.attributes.slice('id', 'title', 'due_at', 'points_possible', 'submission_types', 'group_category_id')
res[:submission_comments] = object.submission_comments.map do |comment|
hash = comment.attributes
hash['formatted_body'] = comment.formatted_body(250)
diff --git a/app/stylesheets/submissionDetailsDialog.sass b/app/stylesheets/submissionDetailsDialog.sass
index 199de77a622..3daf28ffd2f 100644
--- a/app/stylesheets/submissionDetailsDialog.sass
+++ b/app/stylesheets/submissionDetailsDialog.sass
@@ -68,6 +68,11 @@
#add_a_comment
width: 99%
display: block
+ #group-comment-container
+ float: left
+ label
+ display: inline
+ font-weight: normal
.button
float: right
\ No newline at end of file
diff --git a/app/views/assignments/_group_comment.html.erb b/app/views/assignments/_group_comment.html.erb
new file mode 100644
index 00000000000..3f65f870cf5
--- /dev/null
+++ b/app/views/assignments/_group_comment.html.erb
@@ -0,0 +1,10 @@
+<% if @assignment.has_group_category? && can_do(@assignment.submissions.build(:user => @current_user), @current_user, :make_group_comment) %>
+