Grade report celery task and direct file push to S3 from the new instructor dashboard.

Hook up display of grade files ready for download to new instructor dashboard.

LMS-58
This commit is contained in:
David Ormsbee
2013-11-14 16:08:53 -05:00
committed by Sarina Canelake
parent 8d01a36e54
commit e0aa8cf78a
15 changed files with 548 additions and 18 deletions

View File

@@ -21,9 +21,12 @@ class DataDownload
@$display_text = @$display.find '.data-display-text'
@$display_table = @$display.find '.data-display-table'
@$request_response_error = @$display.find '.request-response-error'
@$list_studs_btn = @$section.find("input[name='list-profiles']'")
@$list_anon_btn = @$section.find("input[name='list-anon-ids']'")
@$grade_config_btn = @$section.find("input[name='dump-gradeconf']'")
@grade_downloads = new GradeDownloads(@$section)
@instructor_tasks = new (PendingInstructorTasks()) @$section
# attach click handlers
@@ -84,10 +87,14 @@ class DataDownload
@$display_text.html data['grading_config_summary']
# handler for when the section title is clicked.
onClickTitle: -> @instructor_tasks.task_poller.start()
onClickTitle: ->
@instructor_tasks.task_poller.start()
@grade_downloads.downloads_poller.start()
# handler for when the section is closed
onExit: -> @instructor_tasks.task_poller.stop()
onExit: ->
@instructor_tasks.task_poller.stop()
@grade_downloads.downloads_poller.stop()
clear_display: ->
@$display_text.empty()
@@ -95,6 +102,69 @@ class DataDownload
@$request_response_error.empty()
class GradeDownloads
### Grade Downloads -- links expire quickly, so we refresh every 5 mins ####
constructor: (@$section) ->
@$grade_downloads_table = @$section.find ".grade-downloads-table"
@$calculate_grades_csv_btn = @$section.find("input[name='calculate-grades-csv']'")
@$display = @$section.find '.data-display'
@$display_text = @$display.find '.data-display-text'
@$request_response_error = @$display.find '.request-response-error'
POLL_INTERVAL = 1000 * 60 * 5 # 5 minutes in ms
@downloads_poller = new window.InstructorDashboard.util.IntervalManager(
POLL_INTERVAL, => @reload_grade_downloads()
)
@$calculate_grades_csv_btn.click (e) =>
url = @$calculate_grades_csv_btn.data 'endpoint'
$.ajax
dataType: 'json'
url: url
error: std_ajax_err =>
@$request_response_error.text "Error generating grades."
success: (data) =>
@$display_text.html data['status']
reload_grade_downloads: ->
endpoint = @$grade_downloads_table.data 'endpoint'
$.ajax
dataType: 'json'
url: endpoint
success: (data) =>
if data.downloads.length
@create_grade_downloads_table data.downloads
else
console.log "No grade CSVs ready for download"
error: std_ajax_err => console.error "Error finding grade download CSVs"
create_grade_downloads_table: (grade_downloads_data) ->
@$grade_downloads_table.empty()
options =
enableCellNavigation: true
enableColumnReorder: false
autoHeight: true
forceFitColumns: true
columns = [
id: 'link'
field: 'link'
name: 'File'
sortable: false,
minWidth: 200,
formatter: (row, cell, value, columnDef, dataContext) ->
'<a href="' + dataContext['url'] + '">' + dataContext['name'] + '</a>'
]
$table_placeholder = $ '<div/>', class: 'slickgrid'
@$grade_downloads_table.append $table_placeholder
grid = new Slick.Grid($table_placeholder, grade_downloads_data, columns, options)
# export for use
# create parent namespaces if they do not already exist.
_.defaults window, InstructorDashboard: {}