shoehorn old quiz submission HTML into ember quizzes show page

Test plan:
  - As a teacher, the quiz submission results should render
    on the ember quizzes show page

closes CNVS-12453

Change-Id: I61a885509c1506629f5b8e18b3c5475b8052acb3
Reviewed-on: https://gerrit.instructure.com/33529
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
This commit is contained in:
Stanley Stuart 2014-04-17 16:06:15 -05:00
parent 0dd0e95e96
commit 8cc8661ff5
7 changed files with 48 additions and 4 deletions

View File

@ -12,7 +12,7 @@ define [
initialize: (container, application) ->
env.setEnv(window.ENV)
Ember.$.ajaxPrefilter (options, originalOptions, xhr) ->
Ember.$.ajaxPrefilter 'json', (options, originalOptions, xhr) ->
options.dataType = 'json'
options.headers = 'Accept': 'application/vnd.api+json'

View File

@ -12,3 +12,11 @@ define [
unpublish: ->
@set 'published', false
@get('model').save()
# Kind of a gross hack so we can get quiz arrows in...
addLegacyJS: (->
return unless @get('quizSubmissionHTML.html')
Ember.$(document.body).append """
<script src="/javascripts/compiled/bundles/quiz_show.js"></script>
"""
).observes('quizSubmissionHTML.html')

View File

@ -2,10 +2,11 @@ define [
'ember'
'ember-data'
'i18n!quizzes'
], (Em, DS, I18n) ->
'ic-ajax'
], (Em, DS, I18n, ajax) ->
{alias, equal, any} = Em.computed
{belongsTo} = DS
{belongsTo, PromiseObject} = DS
Em.onerror = (error) ->
console.log 'ERR', error, error.stack
@ -71,3 +72,11 @@ define [
when 'graded_survey' then I18n.t 'graded_survey', 'Graded Survey'
when 'practice_quiz' then I18n.t 'practice_quiz', 'Practice Quiz'
).property('quizType')
# temporary until we ship the show page with quiz submission info in ember
quizSubmissionHtmlURL: attr()
quizSubmissionHTML: (->
promise = ajax(@get 'quizSubmissionHtmlURL').then (html) =>
@set 'didLoadQuizSubmissionHTML', true
{ html: html }
PromiseObject.create promise: promise
).property('quizSubmissionHtmlURL')

View File

@ -89,4 +89,17 @@
{{/each}}
</tbody>
</table>
{{! this is only here for legacy styling to pull in
quiz submissions from the server! Confusing id-show above vs
id_show should be removed soon! }}
<div id="quiz_show">
{{#if didLoadQuizSubmissionHTML}}
{{{quizSubmissionHTML.html}}}
{{else}}
<div id='ember-loading'>
<img src='/images/ajax-loader-medium-444.gif' />
{{#t 'loading'}}Loading{{/t}}
</div>
{{/if}}
</div>

View File

@ -3,7 +3,8 @@ define [
'../start_app'
'../shared_ajax_fixtures'
'../environment_setup'
], (Ember, startApp, fixtures) ->
'ic-ajax'
], (Ember, startApp, fixtures, ajax) ->
App = null
QUIZ = fixtures.QUIZZES[0]
@ -35,3 +36,8 @@ define [
testShowPage 'shows assignment group', ->
text = find('#quiz-show').text()
ok text.match ASSIGNMENT_GROUP.name
testShowPage 'show page shows submission html', ->
text = find('#quiz-show').text()
ok text.match 'submission html!'

View File

@ -24,6 +24,7 @@ define [
"hide_correct_answers_at":null,
"hide_results":null,
"id":1,
"quiz_submission_html_url": "/courses/1/quizzes/1/submission_html"
"ip_filter":null,
"due_at":"2013-11-01T06:59:59Z",
"lock_at":"2013-11-01T06:59:59Z",
@ -69,6 +70,7 @@ define [
"shuffle_answers":false,
"time_limit":null,
"title":"Another test",
"quiz_submission_html_url": "/courses/1/quizzes/2/submission_html"
"html_url":"http://localhost:3000/courses/1/quizzes/2",
"mobile_url":"http://localhost:3000/courses/1/quizzes/2?force_user=1&persist_headless=1",
"question_count":0,
@ -100,5 +102,9 @@ define [
response: JSON.parse(JSON.stringify quizIndexResponse),
jqXHR: {}
testStatus: '200'
ajax.defineFixture '/courses/1/quizzes/1/submission_html',
response: 'submission html!'
textStatus: '200'
}

View File

@ -1 +1,3 @@
// Remove the import on quizzes.sass when the Ember quiz show page ships.
@import "quizzes.sass";
@import "ember_quizzes/main";