Skip to content

Commit 7d48b10

Browse files
committed
gradebook2/outcome gradebook student context cards
refs FALCOR-8 closes FALCOR-32, FALCOR-33 Test plan: * test gradebook student names with the student context feature flags on and off * test outcome gradebook student names with the student context feature flags on and off Change-Id: I29e712a82e0eedf06d0fc90792cbaeac7c53fd6a Reviewed-on: https://gerrit.instructure.com/96293 Reviewed-by: John Corrigan <jcorrigan@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Tested-by: Jenkins Product-Review: Cameron Matheson <cameron@instructure.com>
1 parent c0cf619 commit 7d48b10

8 files changed

Lines changed: 60 additions & 7 deletions

File tree

app/coffeescripts/gradebook2/Gradebook.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ define [
5353
'jqueryui/sortable'
5454
'compiled/jquery.kylemenu'
5555
'compiled/jquery/fixDialogButtons'
56+
'jsx/context_cards/StudentContextCardTrigger'
5657
], (
5758
$, _, Backbone, tz, DataLoader, React, ReactDOM, LongTextEditor, KeyboardNavDialog, KeyboardNavTemplate, Slick,
5859
TotalColumnHeaderView, round, InputFilterView, I18n, GRADEBOOK_TRANSLATIONS, GradeCalculator, UserSettings,
@@ -340,6 +341,8 @@ define [
340341
I18n.t 'inactive'
341342

342343
student.display_name = RowStudentNameTemplate
344+
student_id: student.id
345+
course_id: ENV.GRADEBOOK_OPTIONS.context_id
343346
avatar_url: student.avatar_url
344347
display_name: displayName
345348
enrollment_status: enrollmentStatus

app/coffeescripts/gradebook2/OutcomeGradebookGrid.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ define [
77
'compiled/util/NumberCompare'
88
'jst/gradebook2/outcome_gradebook_cell'
99
'jst/gradebook2/outcome_gradebook_student_cell'
10+
'jsx/context_cards/StudentContextCardTrigger'
1011
], (I18n, $, _, HeaderFilterView, OutcomeColumnView, numberCompare, cellTemplate, studentCellTemplate) ->
1112

1213
###
@@ -346,7 +347,7 @@ define [
346347
cellTemplate(score: Math.round(value * 100.0) / 100.0, className: className, masteryScore: outcome.mastery_points)
347348

348349
studentCell: (row, cell, value, columnDef, dataContext) ->
349-
studentCellTemplate(value)
350+
studentCellTemplate(_.extend value, course_id: ENV.GRADEBOOK_OPTIONS.context_id)
350351

351352
# Public: Create a string class name for the given score.
352353
#

app/controllers/gradebooks_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ def set_js_env
305305
else
306306
Setting.get('gradebook2.many_submissions_chunk_size', '10').to_i
307307
end
308-
js_env :GRADEBOOK_OPTIONS => {
308+
js_env STUDENT_CONTEXT_CARDS_ENABLED: @domain_root_account.feature_enabled?(:student_context_cards)
309+
js_env :GRADEBOOK_OPTIONS => {
309310
:chunk_size => chunk_size,
310311
:assignment_groups_url => api_v1_course_assignment_groups_url(
311312
@context,
@@ -337,7 +338,7 @@ def set_js_env
337338
:context_url => named_context_url(@context, :context_url),
338339
:download_assignment_submissions_url => named_context_url(@context, :context_assignment_submissions_url, "{{ assignment_id }}", :zip => 1),
339340
:re_upload_submissions_url => named_context_url(@context, :submissions_upload_context_gradebook_url, "{{ assignment_id }}"),
340-
:context_id => @context.id,
341+
:context_id => @context.id.to_s,
341342
:context_code => @context.asset_string,
342343
:context_sis_id => @context.sis_source_id,
343344
:group_weighting_scheme => @context.group_weighting_scheme,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
define(["jquery"], ($) => {
2+
$(document).on(
3+
"click",
4+
".student_context_card_trigger",
5+
function(event) {
6+
let {student_id, course_id} = $(event.target).data();
7+
if (ENV.STUDENT_CONTEXT_CARDS_ENABLED && student_id && course_id) {
8+
event.preventDefault();
9+
alert(`Student context tray! student=${student_id} course=${course_id}`);
10+
}
11+
}
12+
);
13+
});
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div class="outcome-student-cell-content">
22
{{>avatar}}
3-
<a class="student-grades-list" href="{{grades_html_url}}">{{display_name}}</a>
3+
<a class="student-grades-list student_context_card_trigger"
4+
data-student_id={{id}} data-course_id={{course_id}}
5+
href="{{grades_html_url}}">{{display_name}}</a>
46
<div class="student-section">{{section_name}}</div>
57
</div>

app/views/jst/gradebook2/row_student_name.handlebars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{{>avatar}}
22
<div class='student-name'>
3-
<a class='student-grades-link' href="{{url}}">{{{display_name}}}</a> {{#if enrollment_status}}<span title={{#t}}"This user is currently not able to access the course"{{/t}} class="label">{{enrollment_status}}</span>{{/if}}
3+
<a class='student-grades-link student_context_card_trigger'
4+
data-student_id="{{student_id}}" data-course_id="{{course_id}}"
5+
href="{{url}}">{{{display_name}}}</a> {{#if enrollment_status}}<span title={{#t}}"This user is currently not able to access the course"{{/t}} class="label">{{enrollment_status}}</span>{{/if}}
46
</div>
57
<div class="student-placeholder">
68
{{#t "student_placeholder"}}Student{{/t}}

spec/controllers/gradebooks_controller_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,27 @@ def check_grades_page(due_at)
504504
get "show", :course_id => @course.id
505505
assert_unauthorized
506506
end
507+
508+
context "includes student context card info in ENV" do
509+
before { user_session(@teacher) }
510+
511+
it "includes context_id" do
512+
get :show, course_id: @course.id
513+
context_id = assigns[:js_env][:GRADEBOOK_OPTIONS][:context_id]
514+
expect(context_id).to eq @course.id.to_param
515+
end
516+
517+
it "doesn't enable context cards when feature is off" do
518+
get :show, course_id: @course.id
519+
expect(assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED]).to eq false
520+
end
521+
522+
it "enables context cards when feature is on" do
523+
@course.root_account.enable_feature! :student_context_cards
524+
get :show, course_id: @course.id
525+
expect(assigns[:js_env][:STUDENT_CONTEXT_CARDS_ENABLED]).to eq true
526+
end
527+
end
507528
end
508529

509530
describe "GET 'change_gradebook_version'" do

spec/javascripts/jsx/gradebook2/gradebook2Spec.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
define(['compiled/gradebook2/Gradebook', "underscore"], (Gradebook, _) => {
2-
module("addRow");
1+
define(['compiled/gradebook2/Gradebook',
2+
"underscore",
3+
"helpers/fakeENV",
4+
], (Gradebook, _, fakeENV) => {
5+
module("addRow", {
6+
setup: function() {
7+
fakeENV.setup({
8+
GRADEBOOK_OPTIONS: { context_id: 1 },
9+
});
10+
},
11+
teardown: () => fakeENV.teardown(),
12+
});
313

414
test("doesn't add filtered out users", () => {
515
const gb = {

0 commit comments

Comments
 (0)