diff --git a/app/coffeescripts/ember/quizzes/config/app.coffee b/app/coffeescripts/ember/quizzes/config/app.coffee index 15b1e1188ee..8ae5ddc266e 100644 --- a/app/coffeescripts/ember/quizzes/config/app.coffee +++ b/app/coffeescripts/ember/quizzes/config/app.coffee @@ -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' diff --git a/app/coffeescripts/ember/quizzes/controllers/quiz_controller.coffee b/app/coffeescripts/ember/quizzes/controllers/quiz_controller.coffee index 89ea3e2673f..0c4a44b2b41 100644 --- a/app/coffeescripts/ember/quizzes/controllers/quiz_controller.coffee +++ b/app/coffeescripts/ember/quizzes/controllers/quiz_controller.coffee @@ -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 """ + + """ + ).observes('quizSubmissionHTML.html') diff --git a/app/coffeescripts/ember/quizzes/models/quiz.coffee b/app/coffeescripts/ember/quizzes/models/quiz.coffee index 137af9a845e..f7a214dc1c7 100644 --- a/app/coffeescripts/ember/quizzes/models/quiz.coffee +++ b/app/coffeescripts/ember/quizzes/models/quiz.coffee @@ -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') diff --git a/app/coffeescripts/ember/quizzes/templates/quiz/show.hbs b/app/coffeescripts/ember/quizzes/templates/quiz/show.hbs index ea7982f245f..f097a63ab6f 100644 --- a/app/coffeescripts/ember/quizzes/templates/quiz/show.hbs +++ b/app/coffeescripts/ember/quizzes/templates/quiz/show.hbs @@ -89,4 +89,17 @@ {{/each}} + +{{! 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! }} +
+ {{#if didLoadQuizSubmissionHTML}} + {{{quizSubmissionHTML.html}}} + {{else}} +
+ + {{#t 'loading'}}Loading{{/t}} +
+ {{/if}}
diff --git a/app/coffeescripts/ember/quizzes/tests/integration/quiz_show_integration.spec.coffee b/app/coffeescripts/ember/quizzes/tests/integration/quiz_show_integration.spec.coffee index 615f35e1abd..fbae6475700 100644 --- a/app/coffeescripts/ember/quizzes/tests/integration/quiz_show_integration.spec.coffee +++ b/app/coffeescripts/ember/quizzes/tests/integration/quiz_show_integration.spec.coffee @@ -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!' + diff --git a/app/coffeescripts/ember/quizzes/tests/shared_ajax_fixtures.coffee b/app/coffeescripts/ember/quizzes/tests/shared_ajax_fixtures.coffee index a857bc1e227..987b130708a 100644 --- a/app/coffeescripts/ember/quizzes/tests/shared_ajax_fixtures.coffee +++ b/app/coffeescripts/ember/quizzes/tests/shared_ajax_fixtures.coffee @@ -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' } diff --git a/app/stylesheets/quizzes_ember.scss b/app/stylesheets/quizzes_ember.scss index 0fb819fbc66..e93caefc0b1 100644 --- a/app/stylesheets/quizzes_ember.scss +++ b/app/stylesheets/quizzes_ember.scss @@ -1 +1,3 @@ +// Remove the import on quizzes.sass when the Ember quiz show page ships. +@import "quizzes.sass"; @import "ember_quizzes/main";