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

Release 0.99.0 #2353

Merged
merged 9 commits into from
Aug 20, 2024
Merged
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
11 changes: 11 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Release Notes
=============

Version 0.99.0
--------------

- Revert "Update nginx Docker tag to v1.27" (#2352)
- Add Go To Course button (#2349)
- Add availability to Courses API endpoint (#2308)
- Generate certificates twice a day (#2348)
- Add time_commitment and durations to the courses api (#2334)
- Update dependency django-anymail to v11 (#2341)
- Update redis Docker tag to v6.2.14 (#2346)

Version 0.98.14 (Released August 15, 2024)
---------------

Expand Down
34 changes: 34 additions & 0 deletions courses/serializers/v2/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ProductRelatedField,
)
from courses.serializers.v1.departments import DepartmentSerializer
from courses.utils import get_archived_courseruns
from flexiblepricing.api import is_courseware_flexible_price_approved
from main import features
from openedx.constants import EDX_ENROLLMENT_AUDIT_MODE, EDX_ENROLLMENT_VERIFIED_MODE
Expand All @@ -32,7 +33,10 @@ class CourseSerializer(BaseCourseSerializer):
programs = serializers.SerializerMethodField()
topics = serializers.SerializerMethodField()
certificate_type = serializers.SerializerMethodField()
availability = serializers.SerializerMethodField()
required_prerequisites = serializers.SerializerMethodField()
duration = serializers.SerializerMethodField()
time_commitment = serializers.SerializerMethodField()

def get_required_prerequisites(self, instance):
"""
Expand All @@ -46,6 +50,24 @@ def get_required_prerequisites(self, instance):
and instance.page.prerequisites != ""
)

def get_duration(self, instance):
"""
Get the duration of the course from the course page CMS.
"""
if hasattr(instance, "page") and hasattr(instance.page, "length"):
return instance.page.length

return None

def get_time_commitment(self, instance):
"""
Get the time commitment of the course from the course page CMS.
"""
if hasattr(instance, "page") and hasattr(instance.page, "effort"):
return instance.page.effort

return None

def get_next_run_id(self, instance):
"""Get next run id"""
run = instance.first_unexpired_run
Expand Down Expand Up @@ -75,6 +97,15 @@ def get_certificate_type(self, instance):
return "MicroMasters Credential"
return "Certificate of Completion"

def get_availability(self, instance):
"""Get course availability"""
archived_course_runs = get_archived_courseruns(
instance.courseruns.filter(is_self_paced=False)
)
if archived_course_runs.count() == 0:
return "dated"
return "anytime"

class Meta:
model = models.Course
fields = [
Expand All @@ -88,6 +119,9 @@ class Meta:
"topics",
"certificate_type",
"required_prerequisites",
"duration",
"time_commitment",
"availability",
]


Expand Down
6 changes: 6 additions & 0 deletions courses/serializers/v2/courses_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ def test_serialize_course(
"departments": [{"name": department}],
"page": CoursePageSerializer(course.page).data,
"certificate_type": certificate_type,
"availability": "dated",
"topics": [{"name": topic.name} for topic in topics],
"required_prerequisites": True,
"duration": course.page.length,
"time_commitment": course.page.effort,
"programs": BaseProgramSerializer(course.programs, many=True).data
if all_runs
else None,
Expand Down Expand Up @@ -103,7 +106,10 @@ def test_serialize_course_required_prerequisites(
"page": CoursePageSerializer(course.page).data,
"certificate_type": "Certificate of Completion",
"topics": [],
"availability": "dated",
"required_prerequisites": expected_required_prerequisites,
"duration": course.page.length,
"time_commitment": course.page.effort,
"programs": None,
},
)
18 changes: 18 additions & 0 deletions courses/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,21 @@ def get_unenrollable_courses(queryset):
.filter(courseruns__id__in=courseruns_qs.values_list("id", flat=True))
.distinct()
)


def get_archived_courseruns(queryset):
"""
Returns course runs that are archived. This is defined as:
- The course run end date has passed
- The course run enrollment end date is in the future or None.
This logic is set to match the logic found in frontend/public/src/lib/courseApi.js isRunArchived

Args:
queryset: Queryset of CourseRun objects
"""
now = now_in_utc()
return queryset.filter(
get_enrollable_course_run_filter(now)
& Q(end_date__lt=now)
& (Q(enrollment_end__isnull=True) | Q(enrollment_end__gt=now))
)
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
- db-data:/var/lib/postgresql/data

redis:
image: redis:6.0.5
image: redis:6.2.14
ports:
- "6379"

Expand Down
19 changes: 12 additions & 7 deletions frontend/public/scss/dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $enrolled-passed-fg: #ffffff;

div.row {
margin: 0 !important;
padding: 20px;
padding: 20px 30px;
height: 100%;
}

Expand Down Expand Up @@ -108,6 +108,7 @@ $enrolled-passed-fg: #ffffff;
}

.course-card-text-details {
padding: 0 0 0 20px;

@include media-breakpoint-down(sm) {
padding: 15px 0px 15px 0px;
Expand Down Expand Up @@ -147,8 +148,7 @@ $enrolled-passed-fg: #ffffff;
}

button.dot-menu {
// Setting height so the button element doesn't expand to cover the full height of the row
height: $material-icon-height;
vertical-align: -webkit-baseline-middle;
}

.certificate-container {
Expand Down Expand Up @@ -200,7 +200,7 @@ $enrolled-passed-fg: #ffffff;
.upgrade-item-description {
width: 100%;
flex-direction: row !important;
padding: 25px 30px;
padding: 15px 30px;
border-top: $home-page-border-grey;
background: $home-page-grey-lite;

Expand All @@ -209,6 +209,7 @@ $enrolled-passed-fg: #ffffff;
}

div.certificate-upgrade-message {
padding-left: 30px;
width: 80%;
font-size: 16px;
line-height: 30px;
Expand Down Expand Up @@ -270,9 +271,13 @@ $enrolled-passed-fg: #ffffff;
}
}
}

.get-cert-button-container button, .finaid-link-container {
font-size: 14px !important;
.goto-course-wrapper {
a {
width: fit-content;
}
}
.get-cert-button-container button, .finaid-link-container, a.btn-primary {
font-size: 14px;

@include media-breakpoint-down(sm) {
width: 100%;
Expand Down
80 changes: 49 additions & 31 deletions frontend/public/src/components/EnrolledItemCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* global SETTINGS:false */
import React from "react"
import moment from "moment"
import { parseDateString, formatPrettyDateTimeAmPmTz } from "../lib/util"
import {
parseDateString,
formatPrettyDateTimeAmPmTz,
formatPrettyMonthDate
} from "../lib/util"
import { Formik, Form, Field } from "formik"
import {
Dropdown,
Expand Down Expand Up @@ -402,21 +406,6 @@ export class EnrolledItemCard extends React.Component<

const { menuVisibility } = this.state

const title = isLinkableCourseRun(enrollment.run, currentUser) ? (
<a
href={enrollment.run.courseware_url}
onClick={ev =>
redirectToCourseHomepage(enrollment.run.courseware_url, ev)
}
target="_blank"
rel="noopener noreferrer"
>
{enrollment.run.course.title}
</a>
) : (
enrollment.run.course.title
)

const financialAssistanceLink =
isFinancialAssistanceAvailable(enrollment.run) &&
!enrollment.approved_flexible_price_exists ? (
Expand All @@ -430,30 +419,31 @@ export class EnrolledItemCard extends React.Component<

const certificateLinksStyles = isProgramCard ?
"upgrade-item-description d-md-flex align-items-start justify-content-between flex-column" :
"upgrade-item-description d-md-flex align-items-start justify-content-between"
"upgrade-item-description d-md-flex"
const certificateLinksIntStyles = isProgramCard ?
"d-flex d-md-flex flex-column align-items-start justify-content-center" :
"d-flex d-md-flex flex-column align-items-start justify-content-center"
"d-flex d-md-flex flex-column justify-content-center"

const certificateLinks =
enrollment.run.products.length > 0 &&
enrollment.enrollment_mode === "audit" &&
enrollment.run.is_upgradable ? (
<div className={certificateLinksStyles}>
<div className="certificate-upgrade-message">
<p>
<strong>Upgrade today</strong> and, upon passing, receive your
certificate signed by MIT faculty to highlight the knowledge and
skills you've gained from this MITx course.
</p>
</div>
<div className={certificateLinksIntStyles}>
<div className="get-cert-button-container w-100">
<GetCertificateButton productId={enrollment.run.products[0].id} />
</div>
<div className="finaid-link-container">
{financialAssistanceLink}
</div>
</div>
<div className="certificate-upgrade-message">
<strong>Upgrade today</strong> and, upon passing, receive your
certificate signed by MIT faculty to highlight the knowledge and
skills you've gained from this MITx course.{" "}
<b>
Upgrade expires:{" "}
{formatPrettyDateTimeAmPmTz(
parseDateString(enrollment.run.upgrade_deadline)
)}
</b>
</div>
</div>
) : null
Expand Down Expand Up @@ -492,8 +482,8 @@ export class EnrolledItemCard extends React.Component<
)}

<div className="col-12 col-md course-card-text-details d-grid">
<div className="d-flex justify-content-between align-content-start flex-nowrap w-100">
<div className="d-flex flex-column">
<div className="d-flex justify-content-between flex-nowrap w-100">
<div className="d-flex flex-column flex-grow-1">
<div className="align-content-start d-flex enrollment-mode-container flex-wrap pb-1">
{enrollment.certificate ? (
<span className="badge badge-enrolled-passed mr-2">
Expand All @@ -509,7 +499,35 @@ export class EnrolledItemCard extends React.Component<
) : null}
</div>

<h2>{title}</h2>
<h2>{enrollment.run.course.title}</h2>
</div>
<div className="d-flex flex-column goto-course-wrapper px-4">
{isLinkableCourseRun(enrollment.run, currentUser) ? (
<a
href={enrollment.run.courseware_url}
onClick={ev =>
redirectToCourseHomepage(
enrollment.run.courseware_url,
ev
)
}
className="btn btn-primary btn-gradient-red-to-blue"
target="_blank"
rel="noopener noreferrer"
>
Go to Course
</a>
) : (
<a
className="btn btn-primary btn-gradient-red-to-blue disabled"
rel="noopener noreferrer"
>
Starts{" "}
{formatPrettyMonthDate(
parseDateString(enrollment.run.start_date)
)}
</a>
)}
</div>
<Dropdown
isOpen={menuVisibility}
Expand Down
25 changes: 0 additions & 25 deletions frontend/public/src/components/EnrolledItemCard_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import {
makeLearnerRecordGrade
} from "../factories/course"
import { makeUser } from "../factories/user"
import * as courseApi from "../lib/courseApi"

describe("EnrolledItemCard", () => {
let helper,
renderedCard,
userEnrollment,
currentUser,
enrollmentCardProps,
isFinancialAssistanceAvailableStub,
toggleProgramDrawer,
redirectToCourseHomepage

Expand All @@ -48,10 +46,6 @@ describe("EnrolledItemCard", () => {
.returns(Promise),
addUserNotification: helper.sandbox.stub().returns(Function)
}
isFinancialAssistanceAvailableStub = helper.sandbox.stub(
courseApi,
"isFinancialAssistanceAvailable"
)
toggleProgramDrawer = helper.sandbox.stub().returns(Function)
redirectToCourseHomepage = helper.sandbox.stub().returns(Function)

Expand Down Expand Up @@ -251,25 +245,6 @@ describe("EnrolledItemCard", () => {
assert.isTrue(verifiedUnenrollmodal.exists())
})
})
;[[true], [false]].forEach(([approvedFlexiblePrice]) => {
it("renders the financial assistance link", async () => {
isFinancialAssistanceAvailableStub.returns(true)
userEnrollment = makeCourseRunEnrollmentWithProduct()
userEnrollment["enrollment_mode"] = "audit"
userEnrollment["approved_flexible_price_exists"] = approvedFlexiblePrice
enrollmentCardProps.enrollment = userEnrollment
const inner = await renderedCard()
const extraLinks = inner.find(".finaid-link")
if (approvedFlexiblePrice) {
const text = extraLinks.find("a").at(0)
assert.isFalse(text.exists())
} else {
const text = extraLinks.find("a").at(0).text()
assert.equal(text, "Financial assistance?")
}
})
})

it("renders the program unenrollment verification modal", async () => {
enrollmentCardProps.enrollment = makeProgramEnrollment()

Expand Down
2 changes: 1 addition & 1 deletion frontend/public/src/components/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Loader = (props: LoaderProps) => {
notNil(delayMs) ? delayMs : defaultLoaderDelayMs
)
return () => clearTimeout(timer)
}, [])
}, [isLoading, delayMs])

if (!isLoading) {
return children
Expand Down
Loading
Loading