custom gradebook columns: teacher_notes support

refs CNVS-5856, CNVS-6906, CNVS-6475

Test plan:
  This commit lets you mark columns as teacher_notes columns.  The UI
  only supports one teacher_notes column, but this isn't enforced by
  the API.  Create a teacher_notes column using the API.

Change-Id: I1c15082e95ac08b092148f32f3c6906ec2dcef11
Reviewed-on: https://gerrit.instructure.com/28097
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
Cameron Matheson 2014-01-03 15:26:59 -07:00
parent d4e99d505b
commit 9af963c357
5 changed files with 20 additions and 3 deletions

View File

@ -69,6 +69,9 @@ class CustomGradebookColumnsApiController < ApplicationController
# The position of the column relative to other custom columns # The position of the column relative to other custom columns
# @argument column[hidden] [Optional, Boolean] # @argument column[hidden] [Optional, Boolean]
# Hidden columns are not displayed in the gradebook # Hidden columns are not displayed in the gradebook
# @argument column[teacher_notes] [Optional, Boolean]
# Set this if the column is created by a teacher. The gradebook only
# supports one teacher_notes column.
# #
# @returns Custom Column # @returns Custom Column
def create def create

View File

@ -23,7 +23,7 @@ class CustomGradebookColumn < ActiveRecord::Base
belongs_to :course belongs_to :course
has_many :custom_gradebook_column_data has_many :custom_gradebook_column_data
attr_accessible :title, :position, :hidden attr_accessible :title, :position, :teacher_notes, :hidden
validates_presence_of :title validates_presence_of :title
validates_length_of :title, :maximum => maximum_string_length validates_length_of :title, :maximum => maximum_string_length

View File

@ -0,0 +1,13 @@
class AddTeacherNotesToCustomColumns < ActiveRecord::Migration
tag :predeploy
def self.up
add_column :custom_gradebook_columns, :teacher_notes, :boolean,
:default => false,
:after => :workflow_state
end
def self.down
remove_column :custom_gradebook_columns, :teacher_notes
end
end

View File

@ -20,7 +20,8 @@ module Api::V1::CustomGradebookColumn
include Api::V1::Json include Api::V1::Json
def custom_gradebook_column_json(column, user, session) def custom_gradebook_column_json(column, user, session)
json = api_json column, user, session, :only => %w(id title position) json = api_json column, user, session, :only => %w(id title position
teacher_notes)
json[:hidden] = column.hidden? json[:hidden] = column.hidden?
json json
end end

View File

@ -14,7 +14,7 @@ describe "Api::V1::CustomGradebookColumn" do
describe "custom_gradebook_column_json" do describe "custom_gradebook_column_json" do
it "works" do it "works" do
json = @col.attributes.slice(*%w(id title position)) json = @col.attributes.slice(*%w(id title position teacher_notes))
json["hidden"] = false json["hidden"] = false
controller.custom_gradebook_column_json(@col, @teacher, nil).should == json controller.custom_gradebook_column_json(@col, @teacher, nil).should == json
end end