Skip to content

Commit

Permalink
feat: customized oer and license support
Browse files Browse the repository at this point in the history
  • Loading branch information
TinnaLiu committed Feb 28, 2023
1 parent fcc684f commit 3de3dff
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
54 changes: 43 additions & 11 deletions src/ProblemLayout/Problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,40 @@ class Problem extends React.Component {
return this.context.problemIDs[this.context.problemIDs.indexOf(this.state.problem.id) + offset] || "/"
}

getOerLicense = () => {
const { lesson, problem } = this.props;
var oerArray, licenseArray;
var oerLink, oerName;
var licenseLink, licenseName;

if (problem.oer != null && problem.oer.includes(" <")) {
oerArray = problem.oer.split(" <");
} else if (lesson.courseOER != null && lesson.courseOER.includes(" ")) {
oerArray = lesson.courseOER.split(" <");
} else {
oerArray = ["https://OATutor.io", "OATutor>"];
}

oerLink = oerArray[0];
oerName = oerArray[1].substring(0, oerArray[1].length - 1);

if (problem.license != null && problem.license.includes(" ")) {
licenseArray = problem.license.split(" <");
} else if (lesson.courseLicense != null && lesson.courseLicense.includes(" ")) {
licenseArray = lesson.courseLicense.split(" <");
} else {
licenseArray = ["", ""];
}

licenseLink = licenseArray[0];
licenseName = licenseArray[1].substring(0, licenseArray[1].length - 1);
return [oerLink, oerName, licenseLink, licenseName];
}


render() {
const { classes, lesson } = this.props;
const { classes, lesson, problem } = this.props;
const [oerLink, oerName, licenseLink, licenseName] = this.getOerLicense();

if (this.state.problem == null) {
return (<div></div>);
Expand Down Expand Up @@ -356,18 +387,19 @@ class Problem extends React.Component {
<footer>
<div style={{ display: "flex", flexDirection: "row", alignItems: "center" }}>
<div style={{ marginLeft: 20, fontSize: 12 }}>
{this.state.problem.oer && this.state.problem.oer.includes("openstax") && lesson?.courseName.toLowerCase().includes("openstax") ?
{licenseName !== "" && licenseLink !== "" ?
<div>
"{this.state.problem.title}" is a derivative of&nbsp;
<a href="https://openstax.org/" target="_blank" rel="noreferrer">
"{lesson?.courseName.substring((lesson?.courseName || "").indexOf(":") + 1).trim() || ""}"
</a>
&nbsp;by OpenStax, used under&nbsp;
<a href="https://creativecommons.org/licenses/by/4.0" target="_blank"
rel="noreferrer">CC
BY 4.0</a>
"{problem.title}" is a derivative of&nbsp;
<a href={oerLink} target="_blank" rel="noreferrer">"{oerName}"</a>
, used under&nbsp;
<a href={licenseLink} target="_blank" rel="noreferrer">{licenseName}</a>
</div>
: ""}

:<div>
"{problem.title}" is a derivative of&nbsp;
<a href={oerLink} target="_blank" rel="noreferrer">"{oerName}"</a>
</div>
}
</div>
<div style={{ display: "flex", flexGrow: 1, marginRight: 20, justifyContent: "flex-end" }}>
<IconButton aria-label="help" title={`How to use ${SITE_NAME}?`}
Expand Down
4 changes: 3 additions & 1 deletion src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ for (let i = 0; i < coursePlans.length; i++) {
const course = coursePlans[i];
for (let j = 0; j < course.lessons.length; j++) {
course.lessons[j].learningObjectives = cleanObjectKeys(course.lessons[j].learningObjectives)
lessonPlans.push({ ...course.lessons[j], courseName: course.courseName });
lessonPlans.push({ ...course.lessons[j], courseName: course.courseName,
courseOER: course.courseOER != null ? course.courseOER : "",
courseLicense: course.courseLicense != null ? course.courseLicense : ""});
}
}
const _lessonPlansNoEditor = lessonPlans.filter(({ courseName }) => !courseName.startsWith("!!"))
Expand Down

0 comments on commit 3de3dff

Please sign in to comment.