Skip to content

Commit 3de3dff

Browse files
committed
feat: customized oer and license support
1 parent fcc684f commit 3de3dff

2 files changed

Lines changed: 46 additions & 12 deletions

File tree

src/ProblemLayout/Problem.js

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,40 @@ class Problem extends React.Component {
285285
return this.context.problemIDs[this.context.problemIDs.indexOf(this.state.problem.id) + offset] || "/"
286286
}
287287

288+
getOerLicense = () => {
289+
const { lesson, problem } = this.props;
290+
var oerArray, licenseArray;
291+
var oerLink, oerName;
292+
var licenseLink, licenseName;
293+
294+
if (problem.oer != null && problem.oer.includes(" <")) {
295+
oerArray = problem.oer.split(" <");
296+
} else if (lesson.courseOER != null && lesson.courseOER.includes(" ")) {
297+
oerArray = lesson.courseOER.split(" <");
298+
} else {
299+
oerArray = ["https://OATutor.io", "OATutor>"];
300+
}
301+
302+
oerLink = oerArray[0];
303+
oerName = oerArray[1].substring(0, oerArray[1].length - 1);
304+
305+
if (problem.license != null && problem.license.includes(" ")) {
306+
licenseArray = problem.license.split(" <");
307+
} else if (lesson.courseLicense != null && lesson.courseLicense.includes(" ")) {
308+
licenseArray = lesson.courseLicense.split(" <");
309+
} else {
310+
licenseArray = ["", ""];
311+
}
312+
313+
licenseLink = licenseArray[0];
314+
licenseName = licenseArray[1].substring(0, licenseArray[1].length - 1);
315+
return [oerLink, oerName, licenseLink, licenseName];
316+
}
317+
288318

289319
render() {
290-
const { classes, lesson } = this.props;
320+
const { classes, lesson, problem } = this.props;
321+
const [oerLink, oerName, licenseLink, licenseName] = this.getOerLicense();
291322

292323
if (this.state.problem == null) {
293324
return (<div></div>);
@@ -356,18 +387,19 @@ class Problem extends React.Component {
356387
<footer>
357388
<div style={{ display: "flex", flexDirection: "row", alignItems: "center" }}>
358389
<div style={{ marginLeft: 20, fontSize: 12 }}>
359-
{this.state.problem.oer && this.state.problem.oer.includes("openstax") && lesson?.courseName.toLowerCase().includes("openstax") ?
390+
{licenseName !== "" && licenseLink !== "" ?
360391
<div>
361-
"{this.state.problem.title}" is a derivative of&nbsp;
362-
<a href="https://openstax.org/" target="_blank" rel="noreferrer">
363-
"{lesson?.courseName.substring((lesson?.courseName || "").indexOf(":") + 1).trim() || ""}"
364-
</a>
365-
&nbsp;by OpenStax, used under&nbsp;
366-
<a href="https://creativecommons.org/licenses/by/4.0" target="_blank"
367-
rel="noreferrer">CC
368-
BY 4.0</a>
392+
"{problem.title}" is a derivative of&nbsp;
393+
<a href={oerLink} target="_blank" rel="noreferrer">"{oerName}"</a>
394+
, used under&nbsp;
395+
<a href={licenseLink} target="_blank" rel="noreferrer">{licenseName}</a>
369396
</div>
370-
: ""}
397+
398+
:<div>
399+
"{problem.title}" is a derivative of&nbsp;
400+
<a href={oerLink} target="_blank" rel="noreferrer">"{oerName}"</a>
401+
</div>
402+
}
371403
</div>
372404
<div style={{ display: "flex", flexGrow: 1, marginRight: 20, justifyContent: "flex-end" }}>
373405
<IconButton aria-label="help" title={`How to use ${SITE_NAME}?`}

src/config/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ for (let i = 0; i < coursePlans.length; i++) {
8787
const course = coursePlans[i];
8888
for (let j = 0; j < course.lessons.length; j++) {
8989
course.lessons[j].learningObjectives = cleanObjectKeys(course.lessons[j].learningObjectives)
90-
lessonPlans.push({ ...course.lessons[j], courseName: course.courseName });
90+
lessonPlans.push({ ...course.lessons[j], courseName: course.courseName,
91+
courseOER: course.courseOER != null ? course.courseOER : "",
92+
courseLicense: course.courseLicense != null ? course.courseLicense : ""});
9193
}
9294
}
9395
const _lessonPlansNoEditor = lessonPlans.filter(({ courseName }) => !courseName.startsWith("!!"))

0 commit comments

Comments
 (0)