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

Add institution name and instructor_name #1828

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions controllers/books.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def _route_book(is_published=True):
response.cookies["last_course"]["path"] = "/"

# Get `course info <courses table>`.

course = (
db(db.courses.id == auth.user.course_id)
.select(
db.courses.institution,
db.courses.instructor_name,
db.courses.id,
db.courses.course_name,
db.courses.base_course,
Expand Down Expand Up @@ -289,6 +292,8 @@ def dummy():
questions = _exercises(base_course, chapter)
logger.debug("QUESTIONS = {} {}".format(subchapter, questions))
return dict(
instructor_name=course.instructor_name,
institution=course.institution,
course_name=course.course_name,
base_course=base_course,
is_logged_in=is_logged_in,
Expand Down
11 changes: 9 additions & 2 deletions controllers/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def index():
)
# return dict(message=T('Welcome to CourseWare Manager'))
return basicvalues


@auth.requires_login()
def build():
Expand Down Expand Up @@ -79,6 +79,12 @@ def build():
else:
institution = request.vars.institution

if not request.vars.instructor_name:
instructor_name = "Not Provided"
else:
instructor_name = request.vars.instructor_name


if not request.vars.courselevel:
courselevel = "unknown"
else:
Expand All @@ -94,7 +100,8 @@ def build():
cid = db.courses.update_or_insert(
course_name=request.vars.projectname,
term_start_date=request.vars.startdate,
institution=institution,
institution=request.vars.institution,
instructor_name=request.vars.instructor_name,
base_course=base_course,
login_required=login_required,
python3=python3,
Expand Down
14 changes: 12 additions & 2 deletions models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,14 @@
# ``courses`` table
# =================
## create all tables needed by auth if not custom tables


db.define_table(
"courses",
Field("course_name", "string", unique=True),
Field("term_start_date", "date"),
Field("institution", "string"),
Field("institution", "string"), # field for institution name
Field("instructor_name", "string"), # field for instructor name
Field("base_course", "string"),
Field("python3", type="boolean", default=True),
Field("login_required", type="boolean", default=True),
Expand All @@ -173,7 +176,7 @@
# Provide a common query. Pass ``db.courses.ALL`` to retrieve all fields; otherwise, only the ``course_name`` and ``base_course`` are selected.
def get_course_row(*args, **kwargs):
if not args:
args = db.courses.course_name, db.courses.base_course
args = db.courses.institution, db.courses.institution_logo, db.courses.instructor_name, db.courses.course_name, db.courses.base_course,
return db(db.courses.id == auth.user.course_id).select(*args).first()


Expand Down Expand Up @@ -207,13 +210,20 @@ def getCourseNameFromId(courseid):
q = db.courses.id == courseid
row = db(q).select().first()
return row.course_name if row else ""

def getCourseNameFromId(coursec):
""" used to compute auth.user.course_name field """
q = db.courses.institution == coursec
row = db(q).select().first()
return row.institution if row else ""


def getCourseOrigin(base_course):
res = (
db(
(db.course_attributes.course_id == db.courses.id)
& (db.courses.course_name == base_course)

& (db.course_attributes.attr == "markup_system")
)
.select(db.course_attributes.value, **SELECT_CACHE)
Expand Down
5 changes: 4 additions & 1 deletion views/designer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ <h3>{{=message}}</h3>
name="projectdescription" id="projectdescription" />
</div>
</div>

<div class="form-group row">
<div class="col-md-6">


<label for="institution">Institution</label>
<input type="text" class='form-control' placeholder="Your school" name="institution" id="institution" />
<label for="instructor_name">Instructor Name</label>
<input type="text" class='form-control' placeholder="Instructor" name="instructor_name" id="instructor_name" />
<label for="courselevel">Course Level</label>
<select id="courselevel" class="form-control" name="courselevel">
<option value="unknown" disabled selected>Please Select</option>
Expand Down