Skip to content

Commit f6e949c

Browse files
author
Anirudh Pai
committed
Added aws-lti-middleware directory containing code for AWS LTI middleware
1 parent 82e9f39 commit f6e949c

5,800 files changed

Lines changed: 1066289 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const { SESSION_SYSTEM } = require('@common/global-config')
2+
3+
const calculateSemester = (ms) => {
4+
const date = new Date(ms)
5+
const semesters = [
6+
{
7+
name: "Fall",
8+
start: 70,
9+
end: 100
10+
},
11+
{
12+
name: "Spring",
13+
start: 0,
14+
end: 45
15+
},
16+
{
17+
name: "Summer",
18+
start: 45,
19+
end: 70
20+
}
21+
]
22+
const quarters = [
23+
{
24+
name: "Fall",
25+
start: 75,
26+
end: 100
27+
},
28+
{
29+
name: "Winter",
30+
start: 0,
31+
end: 30
32+
},
33+
{
34+
name: "Spring",
35+
start: 30,
36+
end: 55
37+
},
38+
{
39+
name: "Summer",
40+
start: 55,
41+
end: 75
42+
}
43+
]
44+
45+
const currentYear = date.getUTCFullYear()
46+
const nextYear = date.getUTCFullYear() + 1
47+
48+
const _baseline = new Date(0)
49+
_baseline.setUTCFullYear(currentYear)
50+
const baseline = _baseline.getTime()
51+
52+
const _eoy = new Date(0)
53+
_eoy.setUTCFullYear(nextYear)
54+
const eoy = _eoy.getTime()
55+
56+
const progress = (ms - baseline) / (eoy - baseline) * 100
57+
58+
const session = (SESSION_SYSTEM === "SEMESTER" ? semesters : quarters)
59+
.find(({ start, end }) => progress >= start && progress < end);
60+
61+
return `${session.name} ${currentYear}`
62+
}
63+
64+
module.exports = {
65+
calculateSemester
66+
}

0 commit comments

Comments
 (0)