-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ecb44c
commit 1d124db
Showing
27 changed files
with
324 additions
and
274 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
20 changes: 0 additions & 20 deletions
20
course/migrations/0060_coursemodule_personalized_points_goal.py
This file was deleted.
Oops, something went wrong.
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
17 changes: 0 additions & 17 deletions
17
course/migrations/0061_remove_coursemodule_personalized_points_goal.py
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
course/migrations/0063_alter_studentmodulegoal_personalized_points_goal.py
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
course/migrations/0064_alter_studentmodulegoal_personalized_points_goal.py
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
..._rename_personalized_points_goal_studentmodulegoal_personalized_points_goal_percentage.py
This file was deleted.
Oops, something went wrong.
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
20 changes: 0 additions & 20 deletions
20
exercise/migrations/0051_baseexercise_personalized_points_goal.py
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
exercise/migrations/0052_remove_baseexercise_personalized_points_goal.py
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
$(document).ready(function() { | ||
const $pointsGoalForm = $('#pointsGoalForm'); | ||
$pointsGoalForm.on('submit', function(event) { | ||
event.preventDefault(); | ||
$.ajax({ | ||
type: 'POST', | ||
url: $pointsGoalForm.attr('action'), | ||
data: $pointsGoalForm.serialize(), | ||
success: function(response) { | ||
// Update page dynamically | ||
const $progressElement = $('#progress-' + $pointsGoalForm.data('module-url')); | ||
const $progressDiv = $progressElement.find('.progress'); | ||
let $goalPointsElement = $progressElement.find('.goal-points'); | ||
if ($goalPointsElement.length === 0) { | ||
// Create the goal points bar if it does not exist | ||
$goalPointsElement = $('<div>', { | ||
id: 'goal-points', | ||
class: 'goal-points', | ||
css: { | ||
left: response.personalized_points_goal_percentage + '%' | ||
} | ||
}); | ||
$progressDiv.append($goalPointsElement); | ||
} else { | ||
// Update the existing element | ||
$goalPointsElement.css('left', response.personalized_points_goal_percentage + '%'); | ||
} | ||
|
||
// Update the tooltip | ||
if ($progressDiv.length) { | ||
const tooltipTitle = $progressDiv.attr('data-original-title'); | ||
const $tempDiv = $('<div>').html(tooltipTitle); | ||
Check warning Code scanning / CodeQL DOM text reinterpreted as HTML Medium DOM text Error loading related location Loading |
||
|
||
// In the div find the span with the class personalized-points-text | ||
let $spanElement = $tempDiv.find('span.personalized-points-text'); | ||
|
||
// If the span element does not exist, create it | ||
if ($spanElement.length === 0) { | ||
$tempDiv.append($pointsGoalForm.data('personalized-points-goal-text')); | ||
|
||
$spanElement = $('<span>', { | ||
class: 'personalized-points-text text-nowrap' | ||
}); | ||
$tempDiv.append($spanElement); | ||
} | ||
|
||
// Replace the personalized points goal with the new one | ||
$spanElement.html(response.personalized_points_goal_points); | ||
const newTooltipTitle = $tempDiv.html(); | ||
$progressDiv.attr('data-original-title', newTooltipTitle); | ||
|
||
// Update the progress-bar style | ||
if (response.personalized_points_goal_points <= $pointsGoalForm.data('points')) { | ||
$progressDiv.find('.progress-bar').removeClass('progress-bar-warning'); | ||
$progressDiv.find('.progress-bar').addClass('progress-bar-primary'); | ||
} | ||
else { | ||
$progressDiv.find('.progress-bar').removeClass('progress-bar-primary'); | ||
$progressDiv.find('.progress-bar').addClass('progress-bar-warning'); | ||
} | ||
// Show the success alert | ||
$('#success-alert').show(); | ||
setTimeout(function() { | ||
$('#success-alert').hide(); | ||
}, 5000); | ||
} | ||
}, | ||
error: function(xhr, status, error) { | ||
if (xhr.responseJSON.error === 'less_than_required') { | ||
$('#danger-alert').show(); | ||
setTimeout(function() { | ||
$('#danger-alert').hide(); | ||
}, 5000); | ||
} | ||
else { | ||
$('#warning-alert').show(); | ||
setTimeout(function() { | ||
$('#warning-alert').hide(); | ||
}, 5000); | ||
} | ||
} | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.