From a9749f38dfdfbb2187009d33c31cdf715b59af94 Mon Sep 17 00:00:00 2001 From: Miles Steele Date: Thu, 18 Jul 2013 16:21:40 -0400 Subject: [PATCH] add reset attempts all button click handler, increase polling interval, add slick grid refresh --- .../src/instructor_dashboard/analytics.coffee | 13 ++++++++++++- .../instructor_dashboard/student_admin.coffee | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lms/static/coffee/src/instructor_dashboard/analytics.coffee b/lms/static/coffee/src/instructor_dashboard/analytics.coffee index ca9b9e46b4..d6e1ffdd3e 100644 --- a/lms/static/coffee/src/instructor_dashboard/analytics.coffee +++ b/lms/static/coffee/src/instructor_dashboard/analytics.coffee @@ -9,6 +9,8 @@ std_ajax_err = -> window.InstructorDashboard.util.std_ajax_err.apply this, argum # Analytics Section class Analytics constructor: (@$section) -> + @$section.data 'wrapper', @ + # gather elements @$display = @$section.find '.distribution-display' @$display_text = @$display.find '.distribution-display-text' @@ -99,7 +101,6 @@ class Analytics console.warn("unable to show distribution #{feature_res.type}") @$display_text.text 'Unavailable Metric Display\n' + JSON.stringify(feature_res) - # fetch distribution data from server. # `handler` can be either a callback for success # or a mapping e.g. {success: ->, error: ->, complete: ->} @@ -116,6 +117,16 @@ class Analytics $.ajax settings + # slickgrid's layout collapses when rendered + # in an invisible div. use this method to reload + # the AuthList widget + refresh: -> + @on_selector_change() + + # handler for when the section title is clicked. + onClickTitle: -> + @refresh() + # export for use # create parent namespaces if they do not already exist. diff --git a/lms/static/coffee/src/instructor_dashboard/student_admin.coffee b/lms/static/coffee/src/instructor_dashboard/student_admin.coffee index 1c1e42cdfa..a79f834b7e 100644 --- a/lms/static/coffee/src/instructor_dashboard/student_admin.coffee +++ b/lms/static/coffee/src/instructor_dashboard/student_admin.coffee @@ -214,6 +214,19 @@ class StudentAdmin success: @clear_errors_then -> console.log 'started reset attempts task' error: std_ajax_err => @$request_response_error_all.text "Error starting a task to reset attempts for all students on this problem." + # start task to rescore problem for all students + @$btn_reset_attempts_all.click => + send_data = + all_students: true + problem_to_reset: @$field_problem_select_all.val() + + $.ajax + dataType: 'json' + url: @$btn_reset_attempts_all.data 'endpoint' + data: send_data + success: @clear_errors_then -> console.log 'started reset attempts task' + error: std_ajax_err => @$request_response_error_all.text "Error starting a task to reset attempts on this problem for all students." + # start task to rescore problem for all students @$btn_rescore_problem_all.click => send_data = @@ -255,7 +268,8 @@ class StudentAdmin start_refresh_running_task_poll_loop: -> @reload_running_tasks_list() if @$section.hasClass 'active-section' - plantTimeout 5000, => @start_refresh_running_task_poll_loop() + # poll every 20 seconds + plantTimeout 20000, => @start_refresh_running_task_poll_loop() # wraps a function, but first clear the error displays clear_errors_then: (cb) ->