Skip to content
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

Merge temporary ceibal into mango.master #748

Open
wants to merge 5 commits into
base: ednx-release/mango.master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lms/djangoapps/certificates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,12 @@ def save(self, *args, **kwargs): # pylint: disable=signature-differs
Credentials IDA.
"""
super().save(*args, **kwargs)
if self._meta.proxy:
sending_class = self._meta.proxy_for_model
else:
sending_class = self.__class__
COURSE_CERT_CHANGED.send_robust(
sender=self.__class__,
sender=sending_class,
user=self.user,
course_key=self.course_id,
mode=self.mode,
Expand Down Expand Up @@ -498,7 +502,7 @@ def save(self, *args, **kwargs): # pylint: disable=signature-differs

if CertificateStatuses.is_passing_status(self.status):
COURSE_CERT_AWARDED.send_robust(
sender=self.__class__,
sender=sending_class,
user=self.user,
course_key=self.course_id,
mode=self.mode,
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/grades/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def score_published_handler(sender, block, user, raw_earned, raw_possible, only_
if previous_score is not None:
prev_raw_earned, prev_raw_possible = (previous_score.grade, previous_score.max_grade)

if not is_score_higher_or_equal(prev_raw_earned, prev_raw_possible, raw_earned, raw_possible):
if not is_score_higher_or_equal(prev_raw_earned, prev_raw_possible, raw_earned, raw_possible, True):
update_score = False
log.warning(
"Grades: Rescore is not higher than previous: "
Expand Down
1 change: 1 addition & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@ def _make_mako_template_dirs(settings):
GOOGLE_SITE_VERIFICATION_ID = ''
GOOGLE_ANALYTICS_LINKEDIN = 'GOOGLE_ANALYTICS_LINKEDIN_DUMMY'
GOOGLE_ANALYTICS_TRACKING_ID = None
GOOGLE_ANALYTICS_4_ID = None

######################## BRANCH.IO ###########################
BRANCH_IO_KEY = ''
Expand Down
1 change: 1 addition & 0 deletions lms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ def get_env_setting(setting):
GOOGLE_ANALYTICS_TRACKING_ID = AUTH_TOKENS.get('GOOGLE_ANALYTICS_TRACKING_ID')
GOOGLE_ANALYTICS_LINKEDIN = AUTH_TOKENS.get('GOOGLE_ANALYTICS_LINKEDIN')
GOOGLE_SITE_VERIFICATION_ID = ENV_TOKENS.get('GOOGLE_SITE_VERIFICATION_ID')
GOOGLE_ANALYTICS_4_ID = AUTH_TOKENS.get('GOOGLE_ANALYTICS_4_ID')

##### BRANCH.IO KEY #####
BRANCH_IO_KEY = AUTH_TOKENS.get('BRANCH_IO_KEY')
Expand Down
13 changes: 13 additions & 0 deletions lms/templates/certificates/accomplishment-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
<title>${document_title}</title>

<%static:css group='style-certificates'/>


<% ga_4_id = static.get_value("GOOGLE_ANALYTICS_4_ID", settings.GOOGLE_ANALYTICS_4_ID) %>
% if ga_4_id:
<script async src="https://www.googletagmanager.com/gtag/js?id=${ga_4_id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '${ga_4_id | n, js_escaped_string}');
</script>
% endif
</head>

<body class="layout-accomplishment view-valid-accomplishment ${dir_rtl} certificate certificate-${course_mode_class}" data-view="valid-accomplishment">
Expand Down
12 changes: 12 additions & 0 deletions lms/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@
</script>
% endif

<% ga_4_id = static.get_value("GOOGLE_ANALYTICS_4_ID", settings.GOOGLE_ANALYTICS_4_ID) %>
% if ga_4_id:
<script async src="https://www.googletagmanager.com/gtag/js?id=${ga_4_id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '${ga_4_id | n, js_escaped_string}');
</script>
% endif

<% branch_key = static.get_value("BRANCH_IO_KEY", settings.BRANCH_IO_KEY) %>
% if branch_key and not is_from_mobile_app:
<script type="text/javascript">
Expand Down
12 changes: 12 additions & 0 deletions lms/templates/main_django.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@

{% optional_include "head-extra.html"|microsite_template_path %}

{% google_analytics_4_id as ga_4_id %}
{% if ga_4_id %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ ga_4_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ ga_4_id }}');
</script>
{% endif %}

<meta name="path_prefix" content="{{EDX_ROOT_URL}}">
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ def microsite_template_path(template_name):
"""
template_name = theming_helpers.get_template_path(template_name)
return template_name[1:] if template_name[0] == '/' else template_name


@register.simple_tag
def google_analytics_4_id():
"""
Django template tag that outputs the GOOGLE_ANALYTICS_4_ID:
{% google_analytics_4_id %}
"""
return configuration_helpers.get_value("GOOGLE_ANALYTICS_4_ID", settings.GOOGLE_ANALYTICS_4_ID)
4 changes: 2 additions & 2 deletions openedx/core/lib/grade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def compare_scores(earned1, possible1, earned2, possible2, treat_undefined_as_ze
"""
try:
percentage1 = float(earned1) / float(possible1)
except ZeroDivisionError:
except (ZeroDivisionError, TypeError):
if not treat_undefined_as_zero:
raise
percentage1 = 0.0

try:
percentage2 = float(earned2) / float(possible2)
except ZeroDivisionError:
except (ZeroDivisionError, TypeError):
if not treat_undefined_as_zero:
raise
percentage2 = 0.0
Expand Down
Loading