-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: added banner message for survey report #33633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
felipemontoya
merged 26 commits into
openedx:master
from
eduNEXT:ase/survey-report-message
Dec 18, 2023
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
21ddede
feat: added banner message for survey report
Asespinel d02d5f1
refactor: changed variable names
Asespinel 4530e02
fix: fixed styles on admin templates
Asespinel c42c3c3
refactor: changed script location to survey report block
Asespinel 9778c83
chore: removed whitespaces and renamed the context processor files
Asespinel 79effe9
feat: added banner message for survey report
Asespinel 415bcee
refactor: changed variable names
Asespinel a2c98dc
fix: fixed styles on admin templates
Asespinel 9a6ef63
refactor: changed script location to survey report block
Asespinel 2b65458
chore: removed whitespaces and renamed the context processor files
Asespinel 789d631
chore: added docstring for admin_extra_context method
Asespinel aab11ce
chore: fix merge conflict
Asespinel 519e4da
fix: fixed docstring position
Asespinel a47b175
chore: increased query count for unit test
Asespinel ba47acc
fix: add a send_report_to_external_api mock
MaferMazu a8cdee5
fix: increase query counts
MaferMazu 237515a
Merge branch 'master' into ase/survey-report-message
MaferMazu 1087363
refactor: separated survey report template from admin and deleted bas…
Asespinel 28e3fb5
chore: check if the request is inside an admin page to reduce query c…
Asespinel c4f65ec
fix: fixed query Count in override performance test
Asespinel 8c56953
fix: fixed query counts on other test files
Asespinel a32f3e4
fix: fixed query number in test_views
Asespinel 5d6c531
chore: updated query number
Asespinel c129b80
revert: reverted query count
Asespinel 718b6f5
refactor: changed months variable into a configurable setting
Asespinel 4cc231c
chore: added blank line on context processors file
Asespinel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| """ | ||
| This is the survey report contex_processor modules | ||
|
|
||
| This is meant to determine the visibility of the survey report banner | ||
| across all admin pages in case a survey report has not been generated | ||
|
|
||
| """ | ||
|
|
||
| from datetime import datetime | ||
| from dateutil.relativedelta import relativedelta # for months test | ||
| from .models import SurveyReport | ||
| from django.urls import reverse | ||
| from django.conf import settings | ||
|
|
||
|
|
||
| def admin_extra_context(request): | ||
| """ | ||
| This function sends extra context to every admin site | ||
|
|
||
| The current treshhold to show the banner is one month but this can be redefined in the future | ||
|
|
||
| """ | ||
| months = settings.SURVEY_REPORT_CHECK_THRESHOLD | ||
| if not request.path.startswith(reverse('admin:index')): | ||
| return {'show_survey_report_banner': False, } | ||
|
|
||
| try: | ||
| latest_report = SurveyReport.objects.latest('created_at') | ||
| months_treshhold = datetime.today().date() - relativedelta(months=months) # Calculate date one month ago | ||
| show_survey_report_banner = latest_report.created_at.date() <= months_treshhold | ||
| except SurveyReport.DoesNotExist: | ||
| show_survey_report_banner = True | ||
|
|
||
| return {'show_survey_report_banner': show_survey_report_banner, } | ||
This file contains hidden or 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
74 changes: 74 additions & 0 deletions
74
openedx/features/survey_report/templates/survey_report/admin_banner.html
This file contains hidden or 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,74 @@ | ||
| {% block survey_report_banner %} | ||
| {% if show_survey_report_banner %} | ||
| <div id="originalContent" style="border: 3px solid #06405d; margin-bottom: 50px; rgb(0 0 0 / 18%) 0px 3px 5px;"> | ||
| <div style="background-color: #06405d;padding: 17px 37px;"> | ||
| <h1 style="margin: 0; color: #FFFF; font-weight: 600;">Join the Open edX Data Sharing Initiative and shape the future of learning</h1> | ||
| </div> | ||
| <div style="padding: 17px 37px;"> | ||
| <p>The Open edX Project relies on the collective strength of its community to be a thriving platform for online education.</p> | ||
| <p>Open edX is a dynamic ecosystem and it is used in diverse learning environments. By sharing anonymized reports of aggregated data, you can contribute to the collective knowledge of the community. This data can help us all understand the reach of our project, make better decisions and ultimately support innovation in lifelong learning and advance next generation learning experience platforms.</p> | ||
| <p>We invite you to join the Open edX Data Sharing Initiative by sharing an anonymized reports of aggregated data from your institution's usage of the platform. The report data will be sent to Axim Collaborative, the non-profit behind the Open edX project.</p> | ||
| <p>If you agree and want to send a report you can click the button below. You can always send reports and see the status of reports you have sent in the past at <a href="/admin/survey_report/surveyreport/">admin/survey_report/surveyreport/</a> .</p> | ||
| </div> | ||
| <div style="display: flex; justify-content: flex-end; padding: 0 37px 17px;"> | ||
| <button id="dismissButton" type="button" style="background-color:var(--close-button-bg); color: var(--button-fg); border: none; border-radius: 4px; padding: 10px 20px; margin-right: 10px; cursor: pointer;">Dismiss</button> | ||
| <form id='survey_report_form' method="POST" action="/survey_report/generate_report" style="margin: 0; padding: 0;"> | ||
| {% csrf_token %} | ||
| <button type="submit" style="background-color: #377D4D; color: var(--button-fg); border: none; border-radius: 4px; padding: 10px 20px; cursor: pointer;">Send Report</button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| <div id="thankYouMessage" style="display: none; background-color: var(--darkened-bg); padding: 20px 40px; margin-bottom: 30px;box-shadow: rgb(0 0 0 / 18%) 0px 3px 5px;"> | ||
| <div style="display: flex; align-items: center;"> | ||
| <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24"> | ||
| <g fill="#377D4D"><path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12S6.477 2 12 2s10 4.477 10 10Z"></path> | ||
| <path d="M16.03 8.97a.75.75 0 0 1 0 1.06l-5 5a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 1 1 1.06-1.06l1.47 1.47l2.235-2.236L14.97 8.97a.75.75 0 0 1 1.06 0Z" fill="#FFF"></path> | ||
| </g> | ||
| </svg> | ||
| <span style="font-size: 16px; margin-left: 15px;">Thank you for your collaboration and support! Your contribution is greatly appreciated and will help us continue to improve.</span> | ||
| </div> | ||
| </div> | ||
| {% endif %} | ||
|
|
||
| <!-- The original content of the block --> | ||
| <script> | ||
| $(document).ready(function(){ | ||
| $('#dismissButton').click(function() { | ||
| $('#originalContent').slideUp('slow', function() { | ||
| // If you want to do something after the slide-up, do it here. | ||
| // For example, you can hide the entire div: | ||
| // $(this).hide(); | ||
| }); | ||
| }); | ||
| // When the form is submitted | ||
| $("#survey_report_form").submit(function(event){ | ||
| event.preventDefault(); // Prevent the form from submitting traditionally | ||
|
|
||
| // Make the AJAX request | ||
| $.ajax({ | ||
| url: $(this).attr("action"), | ||
| type: $(this).attr("method"), | ||
| data: $(this).serialize(), | ||
| success: function(response){ | ||
| // Hide the original content block | ||
| $("#originalContent").slideUp(400, function() { | ||
| //$(this).css('display', 'none'); | ||
| // Show the thank-you message block with slide down effect | ||
| $("#thankYouMessage").slideDown(400, function() { | ||
| // Wait for 3 seconds (3000 milliseconds) and then slide up the thank-you message | ||
| setTimeout(function() { | ||
| $("#thankYouMessage").slideUp(400); | ||
| }, 3000); | ||
| }); | ||
| }); | ||
| }, | ||
| error: function(error){ | ||
| // Handle any errors | ||
| console.error("Error sending report:", error); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| </script> | ||
|
|
||
| {% endblock %} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random thought (completely optional): Is it easy to check if this request is for an admin view and return
{'show_survey_report_banner': False}if it's not an admin view (without having to check the database)? In that case, you might be able to remove the changes that require bumping the number of queries in the other tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the change requested with this change we should revert back the query counts by 1 in all the tests? Or just on particular ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will know for sure once the tests run completely but my guess is that for all of them.