Skip to content

Commit 77103b4

Browse files
committed
Merge branch 'term-start-date-warnings' of github.com:ascholerChemeketa/rs into ascholerChemeketa-term-start-date-warnings
2 parents 95126ce + ab889db commit 77103b4

11 files changed

Lines changed: 90 additions & 9 deletions

File tree

bases/rsptx/assignment_server_api/routers/student.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def sort_key(assignment):
201201
lti1p1=is_lti1p1_course,
202202
now=now,
203203
visibility_map=visibility_map,
204+
term_start_date=course.term_start_date,
204205
settings=settings,
205206
base_url=construct_course_url(course),
206207
activity_info="{}",
@@ -1020,6 +1021,7 @@ async def doAssignment(
10201021
questions_score=questions_score,
10211022
readings_score=readings_score,
10221023
user=user,
1024+
term_start_date=course.term_start_date,
10231025
user_id=user.username, # _base.html for ptx student pages needs user_id
10241026
base_course=course.base_course,
10251027
# gradeRecordingUrl=URL('assignments', 'record_grade'),

bases/rsptx/interactives/ptxrs-bootstrap.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
border-radius: 5px;
2424
height: 20px;
2525
position: relative;
26+
margin: 10px auto;
2627
}
2728

2829

bases/rsptx/interactives/public/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ <h2>
235235

236236

237237
<div id="scprogresscontainer">
238-
You have attempted <span id="scprogresstotal"></span> of
239-
<span id="scprogressposs"></span> activities on this page
240-
<div id="subchapterprogress"></div>
238+
<div id="scprogress-activity-count">
239+
You have attempted <span id="scprogresstotal"></span> of
240+
<span id="scprogressposs"></span> activities on this page.
241+
</div>
242+
<div id="subchapterprogress" aria-label="Page progress"></div>
241243
</div>
242244

243245

bases/rsptx/interactives/runestone/common/css/runestone.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,4 +1432,11 @@ legend {
14321432

14331433
.autopermalink {
14341434
display: none;
1435+
}
1436+
1437+
1438+
.course-not-started-warning {
1439+
margin-bottom: 20px;
1440+
margin-top: 20px;
1441+
padding: 15px;
14351442
}

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,25 @@ export const NON_CONTENT_PAGES = [
348348
"search.html",
349349
];
350350

351+
export function isCourseStarted() {
352+
let startDate = eBookConfig.termStartDate; // format is "2026-09-22"
353+
if (!startDate) {
354+
return false;
355+
}
356+
let today = new Date();
357+
let start = new Date(startDate);
358+
return today >= start;
359+
}
360+
361+
function courseNotStartedMessage() {
362+
const formattedDate = new Date(eBookConfig.termStartDate).toLocaleDateString(undefined, {
363+
year: 'numeric',
364+
month: 'long',
365+
day: 'numeric'
366+
});
367+
return ("Course has not started yet. Progress will be tracked starting on " + formattedDate);
368+
}
369+
351370
/** True when pathname names one of the NON_CONTENT_PAGES. */
352371
export function isNonContentPage(pathname = window.location.pathname) {
353372
let page = pathname.split("/").pop().toLowerCase();
@@ -440,6 +459,11 @@ export class PageProgressBar {
440459
} catch (e) {
441460
value = 0;
442461
}
462+
let progressText = document.getElementById("scprogress-activity-count");
463+
// Warn if course not started
464+
if(progressText && !isCourseStarted()) {
465+
progressText.appendChild(document.createTextNode(courseNotStartedMessage()));
466+
}
443467
// Replace #subchapterprogress div with a native <progress> element if not already done
444468
let subchapterprogress = document.getElementById("subchapterprogress");
445469
if (subchapterprogress && subchapterprogress.tagName !== "PROGRESS") {
@@ -1080,6 +1104,22 @@ async function handlePageSetup() {
10801104
}
10811105
}
10821106
}
1107+
1108+
// PTX generated pages may have stale HTML. Forcibly re-render the content
1109+
// of the progress container. Any logic that modifies the progress container
1110+
// should be done after this point, or it will be overwritten.
1111+
const scprogresscontainer = document.getElementById(
1112+
"scprogresscontainer",
1113+
);
1114+
if (scprogresscontainer)
1115+
scprogresscontainer.innerHTML = `
1116+
<div id="scprogress-activity-count">
1117+
You have attempted <span id="scprogresstotal"></span> of
1118+
<span id="scprogressposs"></span> activities on this page.
1119+
</div>
1120+
<div id="subchapterprogress" aria-label="Page progress"></div>
1121+
`;
1122+
10831123
console.log(`This page served by ${eBookConfig.served_by}`);
10841124
if (eBookConfig.isLoggedIn) {
10851125
mess = `username: ${eBookConfig.username}`;
@@ -1094,7 +1134,23 @@ async function handlePageSetup() {
10941134
}
10951135
}
10961136
document.dispatchEvent(new Event("runestone:login"));
1137+
10971138
addReadingList();
1139+
1140+
// Warn if the course has not started yet
1141+
if (!isCourseStarted()) {
1142+
const ptxContent = document.getElementById("ptx-content");
1143+
if (ptxContent) {
1144+
const warningContainer = document.createElement("div");
1145+
warningContainer.className = "ptx-runestone-container";
1146+
const warningDiv = document.createElement("div");
1147+
warningDiv.className = "course-not-started-warning alert alert-danger";
1148+
warningDiv.textContent = courseNotStartedMessage();
1149+
warningContainer.appendChild(warningDiv);
1150+
ptxContent.insertBefore(warningContainer, ptxContent.firstChild);
1151+
}
1152+
}
1153+
10981154
// Only show the StudyClues widget for certain base courses and when the path includes "/ns/books/".
10991155
// This is a temporary measure to limit the widget to courses that are known to work well with it and to avoid showing it on non-book pages where it may not be as useful.
11001156
if (shouldShowStudyCluesWidget()) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,11 @@ <h4>Before you keep reading...</h4>
400400
{% endif %}
401401

402402
<div id="scprogresscontainer">
403-
You have attempted <span id="scprogresstotal"></span> of <span id="scprogressposs"></span> activities on this page <div id="subchapterprogress" aria-label="Page progress"></div>
403+
<div id="scprogress-activity-count">
404+
You have attempted <span id="scprogresstotal"></span> of
405+
<span id="scprogressposs"></span> activities on this page.
406+
</div>
407+
<div id="subchapterprogress" aria-label="Page progress"></div>
404408
</div>
405409

406410
{% include "subchapter.html" %}

bases/rsptx/interactives/runestone/common/test/bookfuncs_progress.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ import {
2222
/** The markup a book emits for the progress bar. */
2323
function progressMarkup() {
2424
return `
25-
<div id="scprogresscontainer">You have attempted
26-
<span id="scprogresstotal"></span> of <span id="scprogressposs"></span>
27-
activities on this page.
25+
<div id="scprogresscontainer">
26+
<div id="scprogress-activity-count">
27+
You have attempted <span id="scprogresstotal"></span> of
28+
<span id="scprogressposs"></span> activities on this page.
29+
</div>
2830
<div id="subchapterprogress" aria-label="Page progress"></div>
2931
</div>`;
3032
}

components/rsptx/templates/admin/instructor/course_settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h3>{{ course.course_name }}</h3>
2424
<div class="settingsbox">
2525
<label for="start_date">Term Start Date</label>
2626
<input type="text" id="start_date" value="{{ start_date }}" onchange="updateCourse(this, 'new_date')">
27-
<div class="setting-description">Set the start date for your course term</div>
27+
<div class="setting-description">Set this to the first day students will be able to do work in the course. Student work before this date will not be counted.</div>
2828
</div>
2929

3030
<div class="settingsbox">

components/rsptx/templates/admin/instructor/create_course.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ <h4 class="book-section">{{ section }}</h4>
147147
<label><input type="checkbox" name="allowpairs" value="true" {% if submitted is defined and submitted.allowpairs == 'true' %}checked{% endif %}> Enable <strong>experimental</strong> pair programming features.</label><br>
148148
<label><input type="checkbox" name="instructor" value="yes" {% if submitted is defined and submitted.instructor == 'yes' %}checked{% else %}checked{% endif %}> Make me the Instructor of this course.</label><br>
149149
<label for="startdate">Term start date</label>
150-
<input type="date" name="startdate" id="startdate" class="form-control" required value="{{ submitted.startdate if submitted is defined else current_date }}">
150+
<input type="date" name="startdate" id="startdate" class="form-control" required value="{{ submitted.startdate if submitted is defined else current_date }}" aria-describedby="startdate-hint">
151+
<small class="form-text text-muted" id="startdate-hint">Set this to the first day students will be able to do work in the course. Student work before this date will not be counted.</small>
151152
</div>
152153
<div class="form-section">
153154
<div class="step-title">Step 6: (Optional !!): Support Runestone Academy</div>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
{% endblock %}
1717

1818
{% block content %}
19+
20+
{% if using_ptx_base != "true" %}
21+
{% include 'common/ebook_config.html' %}
22+
{% endif %}
23+
1924
<section class="assignment-page">
2025
<h1 class="heading">Choose Assignment</h1>
2126

0 commit comments

Comments
 (0)