Skip to content

Commit 06f8480

Browse files
authored
Merge pull request #1185 from ascholerChemeketa/no-work-before-term-start
No work before term start
2 parents fd5cb65 + 6fe58f5 commit 06f8480

File tree

20 files changed

+176
-30
lines changed

20 files changed

+176
-30
lines changed

bases/rsptx/book_server_api/routers/books.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ async def serve_page(
402402
context = dict(
403403
request=request,
404404
course_name=course_name,
405+
term_start_date=course_row.term_start_date.isoformat(),
405406
base_course=course_row.base_course,
406407
user_id=user.username if user else "",
407408
# _`root_path`: The server is mounted in a different location depending on how it's run (directly from gunicorn/uvicorn or under the ``/ns`` prefix using nginx). Tell the JS what prefix to use for Ajax requests. See also `setting root_path <setting root_path>` and the `FastAPI docs <https://fastapi.tiangolo.com/advanced/behind-a-proxy/>`_. This is then used in the ``eBookConfig`` of :doc:`runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html`.

bases/rsptx/book_server_api/routers/course.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def sort_key(assignment):
151151
"assignment_list": assignments,
152152
"stats": stats,
153153
"course": course,
154+
"is_old_course": course.term_start_date
155+
< (datetime.datetime.now() - datetime.timedelta(weeks=52)).date(),
154156
"user": user,
155157
"request": request,
156158
"institution": course.institution,

bases/rsptx/interactives/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bases/rsptx/interactives/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"handsontable": "7.2.2",
4444
"jexcel": "^3.9.1",
4545
"jquery-ui": "1.10.4",
46-
"micro-parsons": "https://github.com/RunestoneInteractive/micro-parsons-element/releases/download/v0.1.7/micro-parsons-0.1.7.tgz",
46+
"micro-parsons": "https://github.com/RunestoneInteractive/micro-parsons-element/releases/download/v0.2.0/micro-parsons-0.2.0.tgz",
4747
"select2": "^4.1.0-rc.0",
4848
"sql.js": "1.5.0",
4949
"vega-embed": "3.14.0",

bases/rsptx/interactives/runestone/clickableArea/js/clickable.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,21 @@ export default class ClickableArea extends RunestoneBase {
152152
var ex = localStorage.getItem(this.localStorageKey());
153153
if (ex !== null) {
154154
this.hasStoredAnswers = true;
155+
let error = false;
155156
try {
156157
storageObj = JSON.parse(ex);
157-
this.clickedIndexArray = storageObj.answer.split(";");
158158
} catch (err) {
159159
// error while parsing; likely due to bad value stored in storage
160-
console.log(err.message);
160+
console.log(`Error parsing stored ClickableArea data for ${this.divid}: ${err.message}`);
161+
error = true;
162+
}
163+
if (error || storageObj.timestamp < eBookConfig.termStartDate) {
161164
localStorage.removeItem(this.localStorageKey());
162165
this.hasStoredAnswers = false;
163166
this.restoreAnswers({});
164167
return;
165168
}
169+
this.clickedIndexArray = storageObj.answer.split(";");
166170
if (this.useRunestoneServices) {
167171
// log answer to server
168172
this.givenIndexArray = [];

bases/rsptx/interactives/runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
eBookConfig.host = '';
291291
eBookConfig.app = eBookConfig.host + '/runestone';
292292
eBookConfig.course = '{{ course_name }}';
293+
eBookConfig.termStartDate = '{{ term_start_date }}';
293294
eBookConfig.basecourse = '{{ base_course }}';
294295
eBookConfig.isLoggedIn = {{ is_logged_in}};
295296
eBookConfig.email = '{{ user_email }}';
@@ -309,6 +310,7 @@
309310
eBookConfig.host = '{{course_url}}' || 'http://127.0.0.1:8000';
310311
eBookConfig.app = eBookConfig.host+'/{{appname}}';
311312
eBookConfig.course = '{{course_id}}';
313+
eBookConfig.termStartDate = '{{ term_start_date }}';
312314
eBookConfig.basecourse = '{{ basecourse }}';
313315
eBookConfig.isLoggedIn = false;
314316
eBookConfig.enableCompareMe = eBookConfig.useRunestoneServices;

bases/rsptx/interactives/runestone/dragndrop/js/dragndrop.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,19 +700,24 @@ export default class DragNDrop extends RunestoneBase {
700700
var ex = localStorage.getItem(this.localStorageKey());
701701
if (ex !== null) {
702702
this.hasStoredDropzones = true;
703+
let error = false;
703704
try {
704705
storedObj = JSON.parse(ex);
705706
this.minheight = storedObj.min_height;
706707
this.dragwidth = storedObj.drag_width;
707708
this.dropwidth = storedObj.drop_width;
708709
} catch (err) {
709710
// error while parsing; likely due to bad value stored in storage
710-
console.log(err.message);
711+
console.log(`Error parsing stored DragNDrop data for ${this.divid}: ${err}`);
712+
error = true;
713+
}
714+
if (error || storedObj.timestamp < eBookConfig.termStartDate) {
711715
localStorage.removeItem(this.localStorageKey());
712716
this.hasStoredDropzones = false;
713717
this.finishSettingUp();
714718
return;
715719
}
720+
localStorage.removeItem(this.localStorageKey());
716721
this.answerState = storedObj.answer;
717722
if (this.useRunestoneServices) {
718723
// store answer in database

bases/rsptx/interactives/runestone/fitb/js/fitb.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,15 @@ export default class FITB extends RunestoneBase {
442442
if (len > 0) {
443443
var ex = localStorage.getItem(this.localStorageKey());
444444
if (ex !== null) {
445+
let error = false;
445446
try {
446447
storedData = JSON.parse(ex);
447448
} catch (err) {
448449
// error while parsing; likely due to bad value stored in storage
449-
console.assert(false, err.message);
450+
console.log(`Error parsing stored FITB data for ${this.divid}: ${err.message}`);
451+
error = true;
452+
}
453+
if (error || storedData.timestamp < eBookConfig.termStartDate) {
450454
localStorage.removeItem(this.localStorageKey());
451455
return;
452456
}

bases/rsptx/interactives/runestone/hparsons/js/hparsons.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ export default class HParsons extends RunestoneBase {
278278
return;
279279
}
280280
let localData = this.localData();
281+
// Guard against no timestamp as it was only added 3/24/2026
282+
if (localData.timestamp && localData.timestamp < eBookConfig.termStartDate) {
283+
localStorage.removeItem(this.storageId);
284+
return;
285+
}
281286
if (localData.answerIndices && this.hparsonsInput.restoreAnswerByIndices) {
282287
this.hparsonsInput.restoreAnswerByIndices(localData.answerIndices.map(Number));
283288
} else if (localData.answer) {
@@ -299,7 +304,6 @@ export default class HParsons extends RunestoneBase {
299304
setLocalStorage(data) {
300305
let currentState = {};
301306
if (data == undefined) {
302-
303307
if (this.isBlockGrading) {
304308
const answerIndices = this.hparsonsInput.getBlockIndices();
305309
currentState = { answerIndices: answerIndices };
@@ -308,7 +312,7 @@ export default class HParsons extends RunestoneBase {
308312
const userAnswer = this.hparsonsInput.getParsonsTextArray();
309313
currentState = { answer: userAnswer };
310314
}
311-
315+
currentState.timestamp = new Date();
312316
} else {
313317
currentState = data;
314318
}

bases/rsptx/interactives/runestone/lp/js/lp.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,15 @@ class LP extends RunestoneBase {
253253
var key = this.localStorageKey();
254254
var ex = localStorage.getItem(key);
255255
if (ex !== null) {
256+
let error = false;
256257
try {
257258
storedData = JSON.parse(ex);
258259
} catch (err) {
259260
// error while parsing; likely due to bad value stored in storage
260-
console.log(err.message);
261+
console.log(`Error parsing stored LP data for ${this.divid}: ${err.message}`);
262+
error = true;
263+
}
264+
if (error || storedData.timestamp < eBookConfig.termStartDate) {
261265
localStorage.removeItem(key);
262266
return;
263267
}

0 commit comments

Comments
 (0)