Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from concord-consortium/poll-student-status
Poll and update portal student status on homepage [#91186646]
- Loading branch information
Showing
11 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/assets/javascripts/poll_to_update_student_data_percentages.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
DEFAULT_POLL_INTERVAL_IN_SECONDS = 10 | ||
|
||
window.poll_to_update_student_data_percentages = (options) -> | ||
|
||
# done if no poll url | ||
if not options.poll_url | ||
console.error "Missing poll_url option in poll_to_update_student_data_percentages() call" if console?.error | ||
return | ||
|
||
# get the poll interval or its default and then convert it to milliseconds if not already converted | ||
poll_interval = parseInt(options.poll_interval) | ||
poll_interval = DEFAULT_POLL_INTERVAL_IN_SECONDS if isNaN(poll_interval) or poll_interval < 1 | ||
poll_interval *= 1000 if poll_interval < 1000 | ||
|
||
update_percentages = (status) -> | ||
for report_learner in status?.report_learners | ||
$offering = jQuery(".offering_for_student[data-offering_id='#{report_learner.offering_id}']") | ||
if $offering and report_learner.last_run | ||
$offering.find('.last_run').html(report_learner.last_run) | ||
$offering.find('.status_graphs .not_run').hide() | ||
$offering.find('.status_graphs .progress').css({width: "#{report_learner.percentage}%"}) | ||
$offering.find('.status_graphs .run_graph').show() | ||
|
||
# poll for percentage updates | ||
poll = -> | ||
jQuery.ajax options.poll_url, | ||
success: (status) -> | ||
update_percentages status | ||
setTimeout poll, poll_interval | ||
|
||
# wait for the initial poll | ||
setTimeout poll, poll_interval | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters