Skip to content

Commit ffaf919

Browse files
committed
fix activities required for new logic
1 parent 4e0fdb7 commit ffaf919

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ This page is not part of that assignment. Select a page to return to it:
4545
*/
4646
function addReadingList() {
4747
let assignment_info_string = localStorage.getItem(`currentAssignmentInfo_${eBookConfig.course}`)
48-
48+
4949
if (assignment_info_string && eBookConfig.readings) {
50-
var top,bottom,active,page_name,exit_link,fst,snd, new_pos, path_parts, new_pos_link;
50+
var top, bottom, active, page_name, exit_link, fst, snd, new_pos, path_parts, new_pos_link;
5151
var assignment_info = JSON.parse(assignment_info_string);
5252
let assignment_id = assignment_info.id;
5353
let assignment_name = assignment_info.name;
@@ -59,14 +59,14 @@ function addReadingList() {
5959
page_name = document.createElement("a");
6060
page_name.textContent = assignment_name;
6161
page_name.href = `/assignment/student/doAssignment?assignment_id=${assignment_id}`;
62-
62+
6363
active.append(page_name);
6464

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

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

@@ -102,13 +102,12 @@ function addReadingList() {
102102
var fst_lnk = document.createElement("a");
103103
//fst_lnk.className = "btn btn-lg reading-navigation prev-reading";
104104
fst_lnk.href = new_pos_link;
105-
fst_lnk.textContent = `Back to page ${
106-
position
107-
} of ${num_readings}: ${reading_names[position-1]}.`;
105+
fst_lnk.textContent = `Back to page ${position
106+
} of ${num_readings}: ${reading_names[position - 1]}.`;
108107
txt.append(fst_lnk);
109108
fst.append(txt);
110-
111-
} else if (position == 0){
109+
110+
} else if (position == 0) {
112111
fst = active.cloneNode(true);
113112
let txt = document.createElement("p");
114113
txt.textContent = `Page 1 of ${num_readings}.`;
@@ -120,7 +119,7 @@ function addReadingList() {
120119
let pageExercises = Object.keys(componentMap);
121120
if (pageExercises.length == 0) {
122121
pageExercises = document.querySelectorAll("[data-component]");
123-
pageExercises = Array.from(pageExercises).map(function(el) {
122+
pageExercises = Array.from(pageExercises).map(function (el) {
124123
return el.id;
125124
})
126125
}
@@ -160,25 +159,24 @@ function addReadingList() {
160159
var snd_lnk = document.createElement("a");
161160
//snd_lnk.className = "btn btn-lg reading-navigation next-reading";
162161
snd_lnk.href = new_pos_link;
163-
snd_lnk.textContent = `Continue to page ${
164-
position + 2
165-
} of ${num_readings}: ${reading_names[position+1]}`;
162+
snd_lnk.textContent = `Continue to page ${position + 2
163+
} of ${num_readings}: ${reading_names[position + 1]}`;
166164
let txt = document.createElement("p");
167165
txt.append(snd_lnk);
168166
snd.append(txt);
169-
167+
170168
} else {
171169
snd = active.cloneNode(true);
172170
let txt = document.createElement("p");
173171
txt.textContent = "Notice: this page is not part of the assignment. To remove this warning click ";
174172
let exit_clone = exit_link.cloneNode(true);
175173

176-
exit_clone.addEventListener('click',function(event) {
174+
exit_clone.addEventListener('click', function (event) {
177175
localStorage.removeItem(`currentAssignmentInfo_${eBookConfig.course}`);
178176
});
179177
txt.append(exit_clone);
180178
snd.append(txt);
181-
179+
182180

183181
}
184182

@@ -197,7 +195,7 @@ function addReadingList() {
197195
//bottom.style.backgroundColor = "var(--componentBgColor)"
198196
//bottom.style.borderColor = "var(--componentBorderColor)"
199197
//bottom.style.borderWidth = "1px"
200-
198+
201199
//bottom.append(active.cloneNode(true));
202200
//bottom.append(fst.cloneNode(true));
203201
bottom.append(snd);
@@ -219,9 +217,9 @@ function addReadingList() {
219217
}
220218
const mainContent = document.getElementById("main-content");
221219
if (mainContent && snd) {
222-
mainContent.insertBefore(top,mainContent.firstChild)
220+
mainContent.insertBefore(top, mainContent.firstChild)
223221
mainContent.appendChild(bottom);
224-
222+
225223
}
226224
}
227225
}
@@ -336,11 +334,11 @@ class PageProgressBar {
336334
// This handles the case where there are no activities on the page or
337335
// where the user completed activities on the assignment page and now
338336
// is viewing the reading page.
339-
let completeActivities = this.total - 1; // subtract 1 for the page reading which is in total but not an activity
337+
let completeActivities = this.total; // subtract 1 for the page reading which is in total but not an activity
340338
let requiredActivities =
341-
this.assignment_spec.activities_required || 0;
339+
this.assignment_spec.activities_required || 1;
342340
if (this.assignment_spec.activities_required === null) {
343-
this.assignment_spec.activities_required = this.possible - 1; // if activities_required is null, then there are none on the page
341+
this.assignment_spec.activities_required = this.possible; // if activities_required is null, then there are none on the page
344342
}
345343
if (completeActivities >= requiredActivities) {
346344
this.sendCompletedReadingScore().then(() => {

0 commit comments

Comments
 (0)