fix the quiz submission preview inception issue in ember quizzes

fixes CNVS-13390

- test plan
  - enable draft state and quiz stats features
  - as a teacher
    - create a quiz with multiple attempts

  - as a student
    - take the quiz

  - as a teacher
    - go to speedgrader for this student's submission and add a note in the
      sidebar

  - as a student
    - go to your dashboard, the teacher's note should be in the sidebar
      under "Recent Feedback"
    - click on the note
    - it should bring you to the submission details page.
    - the ember version of the page should display in the frame
    - clicking on 'take the quiz again' should not cause inception

Change-Id: I1eb7d467ec08f8d3a1510602b4720483c1b1167c
Reviewed-on: https://gerrit.instructure.com/35871
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
This commit is contained in:
Derek DeVries 2014-06-03 23:43:09 -06:00
parent 03c1106a80
commit a8ad819043
6 changed files with 27 additions and 3 deletions

View File

@ -46,6 +46,10 @@ class Quizzes::QuizzesController < ApplicationController
:quiz_statistics => true,
:quiz_moderate => @context.feature_enabled?(:quiz_moderate)
})
# headless prevents inception in submission preview
setup_headless if params[:headless]
render action: "fabulous_quizzes"
else
@ -99,7 +103,7 @@ class Quizzes::QuizzesController < ApplicationController
if @context.feature_enabled?(:quiz_stats) &&
@context.feature_enabled?(:draft_state) &&
!params.key?(:take)
redirect_to ember_urls.course_quiz_url(@quiz.id)
redirect_to ember_urls.course_quiz_url(@quiz.id, headless: params[:headless])
return
end

View File

@ -1,5 +1,6 @@
#quiz-show {
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
background-color: #fff;
.edit-header {
padding-right: 20px;

View File

@ -1,3 +1,6 @@
<% jammit_css :quizzes_ember %>
<% js_bundle :quizzes %>
<% content_for :page_title, t(:page_titles, "Quizzes") %>
<% content_for :head do %>
<base target="_top" />
<% end %>

View File

@ -9,8 +9,9 @@ module CanvasEmberUrl
@mappings[:course_quizzes]
end
def course_quiz_url(id)
"#{course_quizzes_url}#/#{id}"
def course_quiz_url(id, options={})
headless = '?headless=1' if options[:headless]
"#{course_quizzes_url}#{headless}#/#{id}"
end
def course_quiz_moderate_url(id)

View File

@ -36,6 +36,14 @@ describe CanvasEmberUrl::UrlMappings do
it "should build the base url passed in" do
mappings.course_quiz_url(1).should == "#{course_quizzes}#/1"
end
it "should build the base url with headless param present" do
mappings.course_quiz_url(1, headless: 1).should == "#{course_quizzes}?headless=1#/1"
end
it "should build the base url with headless param empty" do
mappings.course_quiz_url(1, headless: nil).should == "#{course_quizzes}#/1"
end
end
describe "#course_quiz_moderate_url" do

View File

@ -375,6 +375,13 @@ describe Quizzes::QuizzesController do
get 'show', :course_id => @course.id, :id => @quiz.id
assert_redirected_to ember_urls.course_quiz_url(@quiz.id)
end
it "should redirect to ember quiz stats app with headless if given" do
a = Account.default
a.feature_enabled?(:quiz_stats).should eql true
get 'show', :course_id => @course.id, :id => @quiz.id, :headless => 1
assert_redirected_to ember_urls.course_quiz_url(@quiz.id, headless: 1)
end
end
describe "GET 'managed_quiz_data'" do