OQAAT QLA events are captured successfully

Adds a on page load submission feature for all quiz taking/showing
pages.  Also ensures that session_started events are only returned once
for a OQAAT event.

Closes CNVS-15665

Test Plan:
  Approach #1:
    - Take a quiz with the "?debug_js=1" flag to see that events are being
      queued.
    - Rapidly register events then submit (attempting to leave some
      events in the buffer)
    - Confirm that the pending events were actually recorded.
  Approach #2:
    - Generate a bunch of events by quickly scrolling the page, and
      switching to and from the window, then leave the page
      ASAP. Answering events are higher priority and probably won't be
      stuck.
    - Confirm some events are missing.
    - Visit the quiz show page, then confirm that the events are now
      known.

Change-Id: If0a95eda6fd6dd90590996dcf55fa2b680c41b21
Reviewed-on: https://gerrit.instructure.com/45733
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Ryan Taylor <rtaylor@instructure.com>
This commit is contained in:
Ryan Taylor 2014-12-12 14:25:02 -07:00
parent 794f66b5b2
commit c5d28d2006
7 changed files with 37 additions and 9 deletions

View File

@ -0,0 +1,9 @@
define (require) ->
eventManager = require('compiled/quizzes/log_auditing')
(unregister) ->
if unregister
eventManager.unregisterAllTrackers()
if !eventManager.isRunning()
eventManager.start()
if eventManager.isDirty()
eventManager.deliver()

View File

@ -40,6 +40,10 @@ define (require) ->
#
# EventTracker instances will be provided with a deliveryCallback that
# enqueues events for delivery via this module.
unregisterAllTrackers: ->
this._trackerFactories = []
start: ->
state = this._state
state.buffer = new EventBuffer()

View File

@ -13,6 +13,7 @@ define (require) ->
debugConsole.log """
I've been loaded by #{userAgent}.
"""
deliver({
'user_agent': userAgent
})
if location.href.indexOf("question") == -1 && location.href.indexOf("take") > 0
deliver({
'user_agent': userAgent
})

View File

@ -192,6 +192,8 @@ class Quizzes::QuizzesController < ApplicationController
upload_url = api_v1_quiz_submission_files_path(:course_id => @context.id, :quiz_id => @quiz.id)
js_env :UPLOAD_URL => upload_url
js_env :SUBMISSION_VERSIONS_URL => course_quiz_submission_versions_url(@context, @quiz) unless @quiz.muted?
events_url = api_v1_course_quiz_submission_events_url(@context, @quiz, @submission)
js_env QUIZ_SUBMISSION_EVENTS_URL: events_url unless @js_env[:QUIZ_SUBMISSION_EVENTS_URL]
end
setup_attachments
@ -837,9 +839,8 @@ class Quizzes::QuizzesController < ApplicationController
redirect_to course_quiz_url(@context, @quiz) and return
end
js_env({
:QUIZ_SUBMISSION_EVENTS_URL => api_v1_course_quiz_submission_events_url(@context, @quiz, @submission)
})
events_url = api_v1_course_quiz_submission_events_url(@context, @quiz, @submission)
js_env QUIZ_SUBMISSION_EVENTS_URL: events_url unless @js_env[:QUIZ_SUBMISSION_EVENTS_URL]
@quiz_presenter = Quizzes::TakeQuizPresenter.new(@quiz, @submission, params)
render :action => 'take_quiz'

View File

@ -24,6 +24,7 @@ define([
'quiz_inputs',
'compiled/models/Quiz',
'compiled/views/PublishButtonView',
'compiled/quizzes/dump_events',
'jquery.instructure_date_and_time' /* dateString, time_field, datetime_field */,
'jqueryui/dialog',
'compiled/jquery/fixDialogButtons',
@ -32,10 +33,11 @@ define([
'jquery.instructure_misc_plugins' /* ifExists, confirmDelete */,
'jquery.disableWhileLoading',
'message_students' /* messageStudents */
], function(I18n, $, MessageStudentsDialog, showAnswerArrows, inputMethods, Quiz, PublishButtonView) {
], function(I18n, $, MessageStudentsDialog, showAnswerArrows, inputMethods, Quiz, PublishButtonView, QuizLogAuditingEventDumper) {
$(document).ready(function () {
QuizLogAuditingEventDumper(true);
function ensureStudentsLoaded(callback) {
if ($('#quiz_details').length) {

View File

@ -25,6 +25,7 @@ define([
'compiled/views/quizzes/LDBLoginPopup',
'worker!compiled/workers/quizzes/quiz_taking_police',
'compiled/quizzes/log_auditing',
'compiled/quizzes/dump_events',
'jquery.ajaxJSON' /* ajaxJSON */,
'jquery.toJSON',
'jquery.instructure_date_and_time' /* friendlyDatetime, friendlyDate */,
@ -36,7 +37,7 @@ define([
'tinymce.editor_box' /* editorBox */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'compiled/behaviors/quiz_selectmenu'
], function(FileUploadQuestionView, File, I18n, $, autoBlurActiveInput, _, LDBLoginPopup, QuizTakingPolice, QuizLogAuditing) {
], function(FileUploadQuestionView, File, I18n, $, autoBlurActiveInput, _, LDBLoginPopup, QuizTakingPolice, QuizLogAuditing, QuizLogAuditingEventDumper) {
var lastAnswerSelected = null;
var lastSuccessfulSubmissionData = null;
var showDeauthorizedDialog;
@ -750,7 +751,7 @@ define([
$timer.text($timeRunningTimeRemaining.text());
}
});
QuizLogAuditing.start();
QuizLogAuditingEventDumper(false);
});
});

View File

@ -73,3 +73,13 @@ define [
ok !evtManager.isDirty(),
"it flushes its buffer when sync is complete"
test "it should drop trackers", ->
evtManager = new EventManager({
autoDeliver: false,
deliveryUrl: '/events'
})
evtManager.registerTracker(TestEventTracker)
evtManager.unregisterAllTrackers()
testEventFactory.trigger("change")
ok !evtManager.isDirty(), "it doesn't have any active trackers"