create fabulous quiz entry point

closes CNVS-9394

test plan:
  - visit quiz index
  - verify current quiz system displayed
  - enable fabulous quizzes
  - visit quiz index
  - verify ember / fabulous quizzes skeleton displays

Change-Id: Ie0737328b9aaa7bb2f97dc78647107b4ff9a7be2
Reviewed-on: https://gerrit.instructure.com/26204
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Stanley Stuart <stanley@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Jason Madsen <jmadsen@instructure.com>
This commit is contained in:
Jason Madsen 2013-11-11 12:28:30 -07:00
parent 16cc93d2f7
commit 69a8460879
4 changed files with 73 additions and 0 deletions

View File

@ -33,6 +33,9 @@ class QuizzesController < ApplicationController
def index
if authorized_action(@context, @current_user, :read)
if @context.root_account.enable_fabulous_quizzes?
redirect_to fabulous_quizzes_course_quizzes_path
end
return unless tab_enabled?(@context.class::TAB_QUIZZES)
@quizzes = @context.quizzes.active.include_assignment.sort_by{|q| [(q.assignment ? q.assignment.due_at : q.lock_at) || SortLast, Canvas::ICU.collation_key(q.title || SortFirst)]}
@ -82,6 +85,12 @@ class QuizzesController < ApplicationController
end
end
def fabulous_quizzes
if !@context.root_account.enable_fabulous_quizzes? || !authorized_action(@context, @current_user, :read)
redirect_to course_quizzes_path
end
end
def show
if @quiz.deleted?
flash[:error] = t('errors.quiz_deleted', "That quiz has been deleted")

View File

@ -0,0 +1 @@
<h2>Fabulous Ember Quizzes</h2>

View File

@ -317,6 +317,9 @@ FakeRails3Routes.draw do
match 'statistics' => 'quizzes#statistics', :as => :statistics
match 'read_only' => 'quizzes#read_only', :as => :read_only
match 'filters' => 'quizzes#filters', :as => :filters
collection do
get :fabulous_quizzes
end
resources :quiz_submissions, :path => :submissions do
collection do
put :backup

View File

@ -129,6 +129,66 @@ describe QuizzesController do
end
end
describe "GET 'index' without fabulous quizzes enabled" do
before :each do
a = Account.default
a.disable_fabulous_quizzes!
a.save!
end
after :each do
a = Account.default
a.enable_fabulous_quizzes!
a.save!
end
it "should not redirect" do
course_with_teacher_logged_in(:active_all => true)
course_quiz(active = true)
a = Account.default
a.enable_fabulous_quizzes?.should eql false
get 'index', :course_id => @course.id
assert_response(:success)
end
end
describe "GET 'index' with fabulous quizzes enabled" do
before :each do
a = Account.default
a.enable_fabulous_quizzes!
a.save!
end
after :each do
a = Account.default
a.disable_fabulous_quizzes!
a.save!
end
it "should redirect to fabulous quizzes app" do
course_with_teacher_logged_in(:active_all => true)
course_quiz(active = true)
a = Account.default
a.enable_fabulous_quizzes?.should eql true
get 'index', :course_id => @course.id
assert_redirected_to(:controller => "quizzes", :action => "fabulous_quizzes")
end
end
describe "GET 'fabulous_quizzes' without fabulous quizzes enabled" do
it "should redirect to index" do
a = Account.default
a.disable_fabulous_quizzes!
a.save!
course_with_teacher_logged_in(:active_all => true)
course_quiz(active = true)
a = Account.default
a.enable_fabulous_quizzes?.should eql false
get 'fabulous_quizzes', :course_id => @course.id
assert_redirected_to(:controller => "quizzes", :action => "index")
end
end
describe "GET 'new'" do
it "should require authorization" do
course_with_teacher(:active_all => true)