diff --git a/controllers/books.py b/controllers/books.py index 0bda6f2fb..1eee7e331 100644 --- a/controllers/books.py +++ b/controllers/books.py @@ -68,9 +68,12 @@ def _route_book(is_published=True): response.cookies["last_course"]["path"] = "/" # Get `course info `. + 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, @@ -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, diff --git a/controllers/designer.py b/controllers/designer.py index d168c2f3a..adac924dc 100644 --- a/controllers/designer.py +++ b/controllers/designer.py @@ -35,7 +35,7 @@ def index(): ) # return dict(message=T('Welcome to CourseWare Manager')) return basicvalues - + @auth.requires_login() def build(): @@ -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: @@ -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, diff --git a/models/db.py b/models/db.py index 376def6a1..3e186be61 100644 --- a/models/db.py +++ b/models/db.py @@ -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), @@ -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() @@ -207,6 +210,12 @@ 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): @@ -214,6 +223,7 @@ def getCourseOrigin(base_course): 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) diff --git a/views/designer/index.html b/views/designer/index.html index 2dff67fe5..b187853ec 100644 --- a/views/designer/index.html +++ b/views/designer/index.html @@ -63,11 +63,14 @@

{{=message}}

name="projectdescription" id="projectdescription" /> -
+ + + +