Skip to content

Commit e454590

Browse files
committed
Improvements to assignment navigation
1 parent b16a1f2 commit e454590

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

bases/rsptx/interactives/runestone/activecode/js/activecode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export class ActiveCode extends RunestoneBase {
226226
}.bind(this),
227227
1000
228228
);
229+
this.decorateStatus();
229230
if (this.autorun) {
230231
// Simulate pressing the run button, since this will also prevent the user from clicking it until the initial run is complete, and also help the user understand why they're waiting.
231232
$(this.runButtonHandler.bind(this));

bases/rsptx/interactives/runestone/common/js/bookfuncs.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ This page is not part of that assignment. Select a page to return to it:
4444
[Select input]
4545
*/
4646
function addReadingList() {
47-
let assignment_info_string = localStorage.getItem("currentAssignmentInfo")
47+
let assignment_info_string = localStorage.getItem(`currentAssignmentInfo_${eBookConfig.course}`)
4848

4949
if (assignment_info_string && eBookConfig.readings) {
5050
var top,bottom,active,page_name,exit_link,fst,snd, new_pos, path_parts, new_pos_link;
51-
let assignment_info = JSON.parse(assignment_info_string);
51+
var assignment_info = JSON.parse(assignment_info_string);
5252
let assignment_id = assignment_info.id;
5353
let assignment_name = assignment_info.name;
5454
let reading_names = assignment_info.readingNames;
@@ -63,11 +63,11 @@ function addReadingList() {
6363
active.append(page_name);
6464

6565
exit_link = document.createElement("a");
66-
exit_link.textContent = "Exit Assignment";
66+
exit_link.textContent = " Exit Assignment";
6767
exit_link.href=window.location.pathname;
6868

6969
exit_link.addEventListener('click',function(event) {
70-
localStorage.removeItem("currentAssignmentInfo");
70+
localStorage.removeItem(`currentAssignmentInfo_${eBookConfig.course}`);
7171
});
7272

7373
//active.append(exit_link)
@@ -114,13 +114,33 @@ function addReadingList() {
114114
txt.textContent = `Page 1 of ${num_readings}.`;
115115
fst.append(txt);
116116
} else {
117+
// this isn't a reading page in the assignment, check to see if any
118+
// activities on this page are assigned to the current assignment
119+
let exerciseOnPage = false;
120+
let pageExercises = Object.keys(componentMap);
121+
if (pageExercises.length == 0) {
122+
pageExercises = document.querySelectorAll("[data-component]");
123+
pageExercises = Array.from(pageExercises).map(function(el) {
124+
return el.id;
125+
})
126+
}
127+
for (let ex of pageExercises) {
128+
if (assignment_info.questions.includes(ex)) {
129+
exerciseOnPage = true;
130+
break;
131+
}
132+
}
117133
new_pos = eBookConfig.readings[0];
118134
path_parts = cur_path_parts.slice(0, cur_path_parts.length - endLop);
119135
path_parts.push(new_pos);
120136
new_pos_link = path_parts.join("/");
121137
fst = active.cloneNode(true);
122138
let txt = document.createElement("p");
123-
txt.textContent = "Notice: this page is not part of the assignment. To remove this warning click ";
139+
if (exerciseOnPage) {
140+
txt.textContent = "This page has activities assigned to the current assignment.";
141+
} else {
142+
txt.textContent = "Notice: this page is not part of the assignment.";
143+
}
124144
txt.append(exit_link);
125145
fst.append(txt);
126146
}
@@ -154,7 +174,7 @@ function addReadingList() {
154174
let exit_clone = exit_link.cloneNode(true);
155175

156176
exit_clone.addEventListener('click',function(event) {
157-
localStorage.removeItem("currentAssignmentInfo");
177+
localStorage.removeItem(`currentAssignmentInfo_${eBookConfig.course}`);
158178
});
159179
txt.append(exit_clone);
160180
snd.append(txt);

bases/rsptx/interactives/runestone/common/js/runestonebase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ export default class RunestoneBase {
610610
rsDiv.classList.remove("notAnswered");
611611
rsDiv.classList.remove("isInCorrect");
612612
rsDiv.classList.remove("isCorrect");
613-
let assignmentInfo = localStorage.getItem("currentAssignmentInfo");
613+
let assignmentInfo = localStorage.getItem(`currentAssignmentInfo_${eBookConfig.course}`);
614614
let questions = [];
615615
if (assignmentInfo) {
616616
questions = JSON.parse(assignmentInfo).questions

components/rsptx/templates/assignment/student/doAssignment.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ <h3>Questions</h3>
258258
'readingNames': subchapNames,
259259
'questions': qlist
260260
};
261-
localStorage.setItem("currentAssignmentInfo", JSON.stringify(assignmentInfo));
261+
localStorage.setItem(`currentAssignmentInfo_${eBookConfig.course}`, JSON.stringify(assignmentInfo));
262262

263263
//console.log(document.getElementsByClassName('nav nav-tabs'))
264264
// This script renders the html into elements in the DOM

0 commit comments

Comments
 (0)