Skip to content

Commit

Permalink
Merge pull request #547 from edly-io/sdaia-certificate
Browse files Browse the repository at this point in the history
certificate-ui-design
  • Loading branch information
Ali-Salman29 authored Jun 11, 2024
2 parents 0fc2c3d + 133eb47 commit 458a138
Show file tree
Hide file tree
Showing 19 changed files with 376 additions and 264 deletions.
3 changes: 2 additions & 1 deletion cms/djangoapps/contentstore/views/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def serialize_certificate(certificate):
"description": certificate_data['description'],
"is_active": certificate_data['is_active'],
"version": CERTIFICATE_SCHEMA_VERSION,
"signatories": certificate_data['signatories']
"signatories": certificate_data['signatories'],
"arabic_course_title": certificate_data['arabic_course_title']
}

# Some keys are not required, such as the title override...
Expand Down
8 changes: 8 additions & 0 deletions cms/static/js/certificates/models/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function(_, Backbone, BackboneRelational, BackboneAssociations, gettext, CoffeeS
// Metadata fields currently displayed in web forms
course_title: '',

arabic_course_title: '',

// Metadata fields not currently displayed in web forms
name: 'Name of the certificate',
description: 'Description of the certificate',
Expand Down Expand Up @@ -78,6 +80,12 @@ function(_, Backbone, BackboneRelational, BackboneAssociations, gettext, CoffeeS
attributes: {name: true}
};
}
if (!attrs.arabic_course_title.trim()) {
return {
message: gettext('Arabic name is require for generating Certificate'),
attributes: {name: true}
};
}
var allSignatoriesValid = _.every(attrs.signatories.models, function(signatory) {
return signatory.isValid();
});
Expand Down
13 changes: 13 additions & 0 deletions cms/static/js/certificates/views/certificate_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function($, _, Backbone, gettext,
'change .collection-name-input': 'setName',
'change .certificate-description-input': 'setDescription',
'change .certificate-course-title-input': 'setCourseTitle',
'change .certificate-arabic-course-title-input': 'setArabicCourseTitle',
'focus .input-text': 'onFocus',
'blur .input-text': 'onBlur',
submit: 'setAndClose',
Expand Down Expand Up @@ -103,6 +104,7 @@ function($, _, Backbone, gettext,
name: this.model.get('name'),
description: this.model.get('description'),
course_title: this.model.get('course_title'),
arabic_course_title: this.model.get('arabic_course_title'),
org_logo_path: this.model.get('org_logo_path'),
is_active: this.model.get('is_active'),
isNew: this.model.isNew()
Expand Down Expand Up @@ -143,11 +145,22 @@ function($, _, Backbone, gettext,
);
},

setArabicCourseTitle: function(event) {
// Updates the indicated model field (still requires persistence on server)
if (event && event.preventDefault) { event.preventDefault(); }
this.model.set(
'arabic_course_title',
this.$('.certificate-arabic-course-title-input').val(),
{silent: true}
);
},

setValues: function() {
// Update the specified values in the local model instance
this.setName();
this.setDescription();
this.setCourseTitle();
this.setArabicCourseTitle();
return this;
}
});
Expand Down
15 changes: 6 additions & 9 deletions cms/templates/js/certificate-details.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<span class="certificate-value"><%- course_title %></span>
</p>
<% } %>
<% if (arabic_course_title) { %>
<p class="course-title-override">
<span class="certificate-label"><b><%- gettext('Arabic Course Title') %>: </b></span>
<span class="certificate-value"><%- arabic_course_title %></span>
</p>
<% } %>
</div>

<div class='course-number-section pull-left'>
Expand All @@ -46,15 +52,6 @@
</div>
</div>
</section>


<section class="certificate-settings signatories">
<header>
<h2 class="title title-2"><%- gettext("Certificate Signatories") %></h2>
</header>
<p class="instructions"><%- gettext("It is strongly recommended that you include four or fewer signatories. If you include additional signatories, preview the certificate in Print View to ensure the certificate will print correctly on one page.") %></p>
<div class="signatory-details-list"></div>
</section>
<% } %>
</ol>

Expand Down
14 changes: 5 additions & 9 deletions cms/templates/js/certificate-editor.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@
<input id="certificate-course-title-<%- uniqueId %>" class="certificate-course-title-input input-text" name="certificate-course-title" type="text" placeholder="<%- gettext("Course title") %>" value="<%- course_title %>" aria-describedby="certificate-course-title-<%-uniqueId %>-tip" />
<span id="certificate-course-title-<%- uniqueId %>-tip" class="tip tip-stacked"><%- gettext("Specify an alternative to the official course title to display on certificates. Leave blank to use the official course title.") %></span>
</div>
<div class="input-wrap field text add-certificate-arabic-course-title">
<label for="certificate-arabic-course-title-<%- uniqueId %>"><%- gettext("Arabic Course Title") %></label>
<input id="certificate-arabic-course-title-<%- uniqueId %>" class="certificate-arabic-course-title-input input-text" name="certificate-arabic-course-title" type="text" placeholder="<%- gettext("Arabic Course title") %>" value="<%- arabic_course_title %>" aria-describedby="certificate-arabic-course-title-<%-uniqueId %>-tip" />
<span id="certificate-arabic-course-title-<%- uniqueId %>-tip" class="tip tip-stacked"><%- gettext("Specify the title in the Arabic for the certificate") %></span>
</div>
</fieldset>
<header>
<h2 class="title title-2"><%- gettext("Certificate Signatories") %></h2>
</header>
<p class="instructions"><%- gettext("It is strongly recommended that you include four or fewer signatories. If you include additional signatories, preview the certificate in Print View to ensure the certificate will print correctly on one page.") %></p>
<div class="signatory-edit-list"> </div>
<span>
<button class="action action-add-signatory" type="button"><%- gettext("Add Additional Signatory") %></button>
<span class="tip tip-stacked"><%- gettext("(Add signatories for a certificate)") %></span>
</span>
</div>
<div class="actions">
<button class="action action-primary" type="submit"><% if (isNew) { print(gettext("Create")) } else { print(gettext("Save")) } %></button>
Expand Down
20 changes: 16 additions & 4 deletions lms/djangoapps/certificates/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def _update_certificate_context(context, course, course_overview, user_certifica
uuid=user_certificate.verify_uuid,
suffix=context.get('certificate_verify_url_suffix')
)

# We prefer a CourseOverview for this function because it validates and corrects certificate_available_date
# and certificates_display_behavior values. However, not all certificates are guaranteed to have a CourseOverview
# associated with them, so we fall back on the course in that case. This shouldn't cause a problem because courses
Expand All @@ -125,7 +124,9 @@ def _update_certificate_context(context, course, course_overview, user_certifica
date = display_date_for_certificate(course, user_certificate)
# Translators: The format of the date includes the full name of the month
date = strftime_localized(date, "%B %-d, %Y")
context['certificate_date_issued'] = convert_date_to_arabic(date)
context['certificate_date_issued'] = date
# SDAIA: Adding Date in Arabic
context['arabic_certificate_date_issued'] = convert_date_to_arabic(date)

# Translators: This text represents the verification of the certificate
context['document_meta_description'] = _('This is a valid {platform_name} certificate for {user_name}, '
Expand Down Expand Up @@ -249,11 +250,18 @@ def _update_course_context(request, context, course, platform_name, course_overv
Updates context dictionary with course info.
"""
effort = course_overview and course_overview.effort or '8'
context['course_duration'] = convert_date_to_arabic(effort)
context['course_duration'] = effort
context['full_course_image_url'] = request.build_absolute_uri(course_image_url(course))
course_title_from_cert = context['certificate_data'].get('course_title', '')
accomplishment_copy_course_name = course_title_from_cert if course_title_from_cert else course.display_name
context['accomplishment_copy_course_name'] = accomplishment_copy_course_name

# SDAIA: Adding Arabic name in the certificate context
context['arabic_course_duration'] = convert_date_to_arabic(effort)
arabic_course_title_from_cert = context['certificate_data'].get('arabic_course_title', '')
accomplishment_copy_arabic_course_name = arabic_course_title_from_cert if arabic_course_title_from_cert else course.display_name
context['accomplishment_copy_arabic_course_name'] = accomplishment_copy_arabic_course_name

course_number = course.display_coursenumber if course.display_coursenumber else course.number
context['course_number'] = course_number
context['idv_enabled_for_certificates'] = settings.FEATURES.get('ENABLE_CERTIFICATES_IDV_REQUIREMENT')
Expand Down Expand Up @@ -326,6 +334,7 @@ def _update_context_with_user_info(context, user, user_certificate):
context['accomplishment_user_id'] = user.id
context['accomplishment_copy_name'] = user_fullname
context['accomplishment_copy_username'] = user.username
context['accomplishment_copy_name_arabic'] = user.profile.arabic_name if user.profile.arabic_name else user_fullname

context['accomplishment_more_title'] = _("More Information About {user_name}'s Certificate:").format(
user_name=user_fullname
Expand Down Expand Up @@ -603,7 +612,8 @@ def render_html_view(request, course_id, certificate=None): # pylint: disable=t
certificate_language,
course_key
)

# import pdb; pdb.set_trace();

# Generate the certificate context in the correct language, then render the template.
with translation.override(certificate_language):
context = {'user_language': user_language}
Expand Down Expand Up @@ -643,6 +653,8 @@ def render_html_view(request, course_id, certificate=None): # pylint: disable=t
# Append/Override the existing view context values with any course-specific static values from Advanced Settings
context.update(course.cert_html_view_overrides)

# import pdb; pdb.set_trace();

# Track certificate view events
_track_certificate_events(request, course, user, user_certificate)

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified lms/static/certificates/images/certificate-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 458a138

Please sign in to comment.