Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit a8dc787

Browse files
committed
Add an endpoint to enroll a user in a course from the library page
1 parent 676ae9b commit a8dc787

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

controllers/default.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,22 @@ def delete():
659659
auth.logout() # logout user and redirect to home page
660660
else:
661661
redirect(URL("default", "user/profile"))
662+
663+
664+
@auth.requires_login()
665+
def enroll():
666+
logger.debug(f"Request to login for {request.vars.course_name}")
667+
course = db(db.courses.course_name == request.vars.course_name).select().first()
668+
# is the user already registered for this course?
669+
res = db(db.user_courses.course_id == course.id).select().first()
670+
if res:
671+
session.flash = f"You are already registered for {request.vars.course_name}"
672+
redirect(URL("default", "courses"))
673+
674+
db.user_courses.insert(user_id=auth.user.id, course_id=course.id)
675+
db(db.auth_user.id == auth.user.id).update(course_id=course.id, active="T")
676+
db(db.auth_user.id == auth.user.id).update(course_name=request.vars.course_name)
677+
auth.user.update(course_name=request.course_name)
678+
auth.user.update(course_id=course.id)
679+
680+
redirect(URL("default", "donate"))

views/default/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<h1>About Runestone</h1>
77

8-
<p>The mission of Runestone Academy is to <i>democratize textbooks for the 21st century.</i> Do accomplish that mission we make high quality interactive textbooks available for free to all students. In the 21st century it is silly to think of textbooks statically, so we make great interactive textbooks that engage students in their learning. It would also be silly to ignore the rich data that an online textbook can provide to students, teachers, authors and researchers. To support these different stakeholders we have created a Learning Engineering and Analytics Portal (LEAP). That is quite a lot to digest so let us unpack that to see what it means in practical terms.</p>
8+
<p>The mission of Runestone Academy is to <i>democratize textbooks for the 21st century.</i> To accomplish that mission we make high quality interactive textbooks available for free to all students. In the 21st century it is silly to think of textbooks statically, so we make great interactive textbooks that engage students in their learning. It would also be silly to ignore the rich data that an online textbook can provide to students, teachers, authors and researchers. To support these different stakeholders we have created a Learning Engineering and Analytics Portal (LEAP). That is quite a lot to digest so let us unpack that to see what it means in practical terms.</p>
99

1010
<ul class="simple">
1111
<li><p><strong>Learning Engineering</strong> is the systematic application of evidence-based principles and methods from educational technology and the learning sciences to create engaging and effective learning experiences, support the difficulties and challenges of learners as they learn, and come to better understand learners and learning. Everything we do on Runestone Academy takes this engineering approach to continuous improvement.</p></li>

0 commit comments

Comments
 (0)