Allow Text Entry Online with Plagiarism Tools

closes PLAT-2927

Test Plan:
 - Under an assignment creation, select online
 - Click only the Text Entry box
 - The plagiarism Review section should appear
 - Save the submission
 - As a student, submit the assignment after entering text in the
   field
 - Submission should submit with the body to the TP

Change-Id: Ice010860a8bc89e0ead02c257baaad1bc4e91b23
Reviewed-on: https://gerrit.instructure.com/134430
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
This commit is contained in:
Marc Alan Phillips 2017-12-01 15:15:50 -07:00
parent f10473ee1f
commit 7e33b245a6
4 changed files with 92 additions and 69 deletions

View File

@ -63,6 +63,7 @@ define [
ONLINE_SUBMISSION_TYPES = '#assignment_online_submission_types'
NAME = '[name="name"]'
ALLOW_FILE_UPLOADS = '#assignment_online_upload'
ALLOW_TEXT_ENTRY = '#assignment_text_entry'
RESTRICT_FILE_UPLOADS = '#assignment_restrict_file_extensions'
RESTRICT_FILE_UPLOADS_OPTIONS = '#restrict_file_extensions_container'
ALLOWED_EXTENSIONS = '#allowed_extensions_container'
@ -292,7 +293,8 @@ define [
@handleOnlineSubmissionTypeChange()
handleOnlineSubmissionTypeChange: (env) =>
showConfigTools = @$onlineSubmissionTypes.find(ALLOW_FILE_UPLOADS).attr('checked')
showConfigTools = @$onlineSubmissionTypes.find(ALLOW_FILE_UPLOADS).attr('checked') ||
@$onlineSubmissionTypes.find(ALLOW_TEXT_ENTRY).attr('checked')
@$similarityDetectionTools.toggleAccessibly showConfigTools && ENV.PLAGIARISM_DETECTION_PLATFORM
afterRender: =>

View File

@ -818,7 +818,8 @@ module Api::V1::Assignment
def plagiarism_capable?(assignment_params)
assignment_params['submission_type'] == 'online' &&
assignment_params['submission_types'].present? &&
assignment_params['submission_types'].include?('online_upload')
(assignment_params['submission_types'].include?('online_upload') ||
assignment_params['submission_types'].include?('online_text_entry'))
end
def submissions_download_url(context, assignment)

View File

@ -1398,19 +1398,34 @@ describe AssignmentsApiController, type: :request do
expect(a.lti_context_id).to eq(lti_assignment_id)
end
it "sets the configuration LTI 1 tool if one is provided" do
tool = @course.context_external_tools.create!(name: "a", url: "http://www.google.com", consumer_key: '12345', shared_secret: 'secret')
context 'set the configuration LTI 1 tool if provided' do
let(:tool) { @course.context_external_tools.create!(name: "a", url: "http://www.google.com", consumer_key: '12345', shared_secret: 'secret') }
let(:a) { Assignment.last }
before do
api_create_assignment_in_course(@course, {
'description' => 'description',
'similarityDetectionTool' => tool.id,
'configuration_tool_type' => 'ContextExternalTool',
'submission_type' => 'online',
'submission_types' => ['online_upload']
'submission_types' => submission_types
})
end
a = Assignment.last
context 'with online_upload' do
let(:submission_types) { ['online_upload'] }
it "sets the configuration LTI 1 tool if one is provided" do
expect(a.tool_settings_tool).to eq(tool)
end
end
context 'with online_text_entry' do
let(:submission_types) { ['online_text_entry'] }
it "sets the configuration LTI 1 tool if one is provided" do
expect(a.tool_settings_tool).to eq(tool)
end
end
end
it "does set the visibility settings" do
tool = @course.context_external_tools.create!(name: "a", url: "http://www.google.com", consumer_key: '12345', shared_secret: 'secret')
@ -1489,67 +1504,61 @@ describe AssignmentsApiController, type: :request do
expect(new_assignment.tool_settings_tool).to eq message_handler
end
it "sets the configuration LTI 2 tool in account context" do
account = @course.account
tool_proxy.update_attributes(context: account)
context 'sets the configuration LTI 2 tool' do
shared_examples_for 'sets the tools_settings_tool' do
let(:submission_types) { raise 'Override in spec' }
let(:context) { raise 'Override in spec' }
it 'sets the tool correctly' do
tool_proxy.update_attributes(context: context)
allow_any_instance_of(AssignmentConfigurationToolLookup).to receive(:create_subscription).and_return true
Lti::ToolProxyBinding.create(context: account, tool_proxy: tool_proxy)
api_create_assignment_in_course(@course, {
Lti::ToolProxyBinding.create(context: context, tool_proxy: tool_proxy)
api_create_assignment_in_course(
@course,
{
'description' => 'description',
'similarityDetectionTool' => message_handler.id,
'configuration_tool_type' => 'Lti::MessageHandler',
'submission_type' => 'online',
'submission_types' => ['online_upload']
})
'submission_types' => submission_types
}
)
a = Assignment.last
expect(a.tool_settings_tool).to eq(message_handler)
end
end
it "sets the configuration an LTI 2 tool in course context" do
allow_any_instance_of(AssignmentConfigurationToolLookup).to receive(:create_subscription).and_return true
account = @course.account
product_family = Lti::ProductFamily.create(
vendor_code: '123',
product_code: 'abc',
vendor_name: 'acme',
root_account: account
)
context 'in account context' do
context 'with online_upload' do
it_behaves_like 'sets the tools_settings_tool' do
let(:submission_types) { ['online_upload'] }
let(:context) { @course.account }
end
end
tool_proxy = Lti:: ToolProxy.create(
shared_secret: 'shared_secret',
guid: 'guid',
product_version: '1.0beta',
lti_version: 'LTI-2p0',
product_family: product_family,
context: @course,
workflow_state: 'active',
raw_data: 'some raw data'
)
context 'with online_text_entry' do
it_behaves_like 'sets the tools_settings_tool' do
let(:submission_types) { ['online_text_entry'] }
let(:context) { @course.account }
end
end
end
resource_handler = Lti::ResourceHandler.create(
resource_type_code: 'code',
name: 'resource name',
tool_proxy: tool_proxy
)
context 'in course context' do
context 'with online_upload' do
it_behaves_like 'sets the tools_settings_tool' do
let(:submission_types) { ['online_upload'] }
let(:context) { @course }
end
end
message_handler = Lti::MessageHandler.create(
message_type: 'basic-lti-launch-request',
launch_path: 'https://samplelaunch/blti',
resource_handler: resource_handler
)
Lti::ToolProxyBinding.create(context: @course, tool_proxy: tool_proxy)
api_create_assignment_in_course(@course, {
'description' => 'description',
'similarityDetectionTool' => message_handler.id,
'configuration_tool_type' => 'Lti::MessageHandler',
'submission_type' => 'online',
'submission_types' => ['online_upload']
})
a = Assignment.last
expect(a.tool_settings_tool).to eq(message_handler)
context 'with online_text_entry' do
it_behaves_like 'sets the tools_settings_tool' do
let(:submission_types) { ['online_text_entry'] }
let(:context) { @course }
end
end
end
end
end

View File

@ -723,6 +723,17 @@ define [
view.handleSubmissionTypeChange()
equal view.$('#similarity_detection_tools').css('display'), 'block'
view.$('#assignment_submission_type').val('online')
view.$('#assignment_text_entry').attr('checked', false)
view.$('#assignment_online_upload').attr('checked', false)
view.handleSubmissionTypeChange()
equal view.$('#similarity_detection_tools').css('display'), 'none'
view.$('#assignment_submission_type').val('online')
view.$('#assignment_text_entry').attr('checked', true)
view.handleSubmissionTypeChange()
equal view.$('#similarity_detection_tools').css('display'), 'block'
test 'it is hidden if the plagiarism_detection_platform flag is disabled', ->
ENV.PLAGIARISM_DETECTION_PLATFORM = false
view = @editView()