Skip to content

Commit

Permalink
Merge branch 'master' into rpenido/fal-3610-download-course-tag-sprea…
Browse files Browse the repository at this point in the history
…dsheet
  • Loading branch information
rpenido authored Feb 15, 2024
2 parents 779cc98 + 008467c commit 4a3d092
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 15 deletions.
1 change: 1 addition & 0 deletions lms/djangoapps/course_api/blocks/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
SupportedFieldType('has_scheduled_content'),
SupportedFieldType('weight'),
SupportedFieldType('show_correctness'),
SupportedFieldType('hide_from_toc'),
# 'student_view_data'
SupportedFieldType(StudentViewTransformer.STUDENT_VIEW_DATA, StudentViewTransformer),
# 'student_view_multi_device'
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/course_home_api/outline/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring
'resume_block': block.get('resume_block', False),
'type': block_type,
'has_scheduled_content': block.get('has_scheduled_content'),
'hide_from_toc': block.get('hide_from_toc'),
},
}
for child in children:
Expand Down
10 changes: 10 additions & 0 deletions lms/djangoapps/course_home_api/outline/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ def test_user_has_passing_grade(self):
assert response.status_code == 200
assert response.data['user_has_passing_grade'] is True

def test_hide_from_toc_field(self):
"""
Test that the hide_from_toc field is returned in the response.
"""
CourseEnrollment.enroll(self.user, self.course.id)
response = self.client.get(self.url)
assert response.status_code == 200
for block in response.data["course_blocks"]["blocks"].values():
assert "hide_from_toc" in block

def assert_can_enroll(self, can_enroll):
response = self.client.get(self.url)
assert response.status_code == 200
Expand Down
8 changes: 5 additions & 3 deletions lms/djangoapps/discussion/rest_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,24 @@ def get_author(self, obj):

def _get_user_label(self, user_id):
"""
Returns the role label (i.e. "Staff" or "Community TA") for the user
Returns the role label (i.e. "Staff", "Moderator" or "Community TA") for the user
with the given id.
"""
is_staff = user_id in self.context["course_staff_user_ids"] or user_id in self.context["moderator_user_ids"]
is_staff = user_id in self.context["course_staff_user_ids"]
is_moderator = user_id in self.context["moderator_user_ids"]
is_ta = user_id in self.context["ta_user_ids"]

return (
"Staff" if is_staff else
"Moderator" if is_moderator else
"Community TA" if is_ta else
None
)

def _get_user_label_from_username(self, username):
"""
Returns role label of user from username
Possible Role Labels: Staff, Community TA or None
Possible Role Labels: Staff, Moderator, Community TA or None
"""
try:
user = User.objects.get(username=username)
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/discussion/rest_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ def test_basic_in_blackout_period_with_user_access(self, mock_emit):
with self.assert_signal_sent(api, 'thread_created', sender=None, user=self.user, exclude_args=('post',)):
actual = create_thread(self.request, self.minimal_data)
expected = self.expected_thread_data({
"author_label": "Staff",
"author_label": "Moderator",
"id": "test_id",
"course_id": str(self.course.id),
"comment_list_url": "http://testserver/api/discussion/v1/comments/?thread_id=test_id",
Expand Down Expand Up @@ -2339,7 +2339,7 @@ def test_success_in_black_out_with_user_access(self, parent_id, mock_emit):
"thread_id": "test_thread",
"parent_id": parent_id,
"author": self.user.username,
"author_label": "Staff",
"author_label": "Moderator",
"created_at": "2015-05-27T00:00:00Z",
"updated_at": "2015-05-27T00:00:00Z",
"raw_body": "Test body",
Expand Down
16 changes: 8 additions & 8 deletions lms/djangoapps/discussion/rest_api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def test_anonymity(self, role_name, anonymous, anonymous_to_peers, expected_seri
assert actual_serialized_anonymous == expected_serialized_anonymous

@ddt.data(
(FORUM_ROLE_ADMINISTRATOR, False, "Staff"),
(FORUM_ROLE_ADMINISTRATOR, False, "Moderator"),
(FORUM_ROLE_ADMINISTRATOR, True, None),
(FORUM_ROLE_MODERATOR, False, "Staff"),
(FORUM_ROLE_MODERATOR, False, "Moderator"),
(FORUM_ROLE_MODERATOR, True, None),
(FORUM_ROLE_COMMUNITY_TA, False, "Community TA"),
(FORUM_ROLE_COMMUNITY_TA, True, None),
Expand All @@ -116,7 +116,7 @@ def test_author_labels(self, role_name, anonymous, expected_label):
"""
Test correctness of the author_label field.
The label should be "Staff", "Staff", or "Community TA" for the
The label should be "Staff", "Moderator", or "Community TA" for the
Administrator, Moderator, and Community TA roles, respectively, but
the label should not be present if the content is anonymous.
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_closed_by_label_field(self, role, visible):
"unread_comments_count": 3,
"closed_by": moderator
})
closed_by_label = "Staff" if visible else None
closed_by_label = "Moderator" if visible else None
closed_by = moderator if visible else None
can_delete = role != FORUM_ROLE_STUDENT
editable_fields = ["abuse_flagged", "copy_link", "following", "read", "voted"]
Expand Down Expand Up @@ -329,7 +329,7 @@ def test_edit_by_label_field(self, role, visible):
"unread_comments_count": 3,
"closed_by": None
})
edit_by_label = "Staff" if visible else None
edit_by_label = "Moderator" if visible else None
can_delete = role != FORUM_ROLE_STUDENT
last_edit = None if role == FORUM_ROLE_STUDENT else {"editor_username": moderator}
editable_fields = ["abuse_flagged", "copy_link", "following", "read", "voted"]
Expand Down Expand Up @@ -491,8 +491,8 @@ def test_endorsed_by(self, endorser_role_name, thread_anonymous):
assert actual_endorser_anonymous == expected_endorser_anonymous

@ddt.data(
(FORUM_ROLE_ADMINISTRATOR, "Staff"),
(FORUM_ROLE_MODERATOR, "Staff"),
(FORUM_ROLE_ADMINISTRATOR, "Moderator"),
(FORUM_ROLE_MODERATOR, "Moderator"),
(FORUM_ROLE_COMMUNITY_TA, "Community TA"),
(FORUM_ROLE_STUDENT, None),
)
Expand All @@ -501,7 +501,7 @@ def test_endorsed_by_labels(self, role_name, expected_label):
"""
Test correctness of the endorsed_by_label field.
The label should be "Staff", "Staff", or "Community TA" for the
The label should be "Staff", "Moderator", or "Community TA" for the
Administrator, Moderator, and Community TA roles, respectively.
role_name is the name of the author's role.
Expand Down
6 changes: 5 additions & 1 deletion lms/templates/admin/base_site.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/base.html" %}
{% load i18n admin_urls %}
{% load i18n admin_urls static %}
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
Expand All @@ -21,6 +21,10 @@ <h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('D

{% endblock %}

{% block extrahead %}
<script src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
{% endblock %}

{% block messages %}{{ block.super }}
{% include "survey_report/admin_banner.html" %}
{% endblock %}
1 change: 1 addition & 0 deletions openedx/core/djangoapps/notifications/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ def test_patch_user_notification_preference(
non_editable_channels = expected_app_prefs['non_editable'].get(notification_type_name, [])
if notification_channel not in non_editable_channels:
expected_app_prefs['notification_types'][notification_type_name][notification_channel] = value
expected_data = remove_notifications_with_visibility_settings(expected_data)
self.assertEqual(response.data, expected_data)
event_name, event_data = mock_emit.call_args[0]
self.assertEqual(event_name, 'edx.notifications.preferences.updated')
Expand Down
1 change: 1 addition & 0 deletions openedx/features/course_experience/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def recurse_mark_auth_denial(block):
'completion',
'complete',
'resume_block',
'hide_from_toc',
],
allow_start_dates_in_future=allow_start_dates_in_future,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
$(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);
}
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% block survey_report_banner %}
{% load static %}
{% 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;">
Expand All @@ -11,11 +12,25 @@ <h1 style="margin: 0; color: #FFFF; font-weight: 600;">Join the Open edX Data Sh
<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;">
<form id='survey_report_form' method="POST" action="/survey_report/generate_report" style="margin: 0; padding: 0;">
<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 %}

<script src="{% static 'survey_report/js/admin_banner.js' %}"></script>

{% endblock %}

0 comments on commit 4a3d092

Please sign in to comment.