Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support displaying external resources in flow page #1190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions course/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@ class FlowRulesDesc(Struct):

# {{{ mypy: flow

class ExternalResourcesDesc(Struct):
def __init__(self, title: str, url: str) -> None:
self.title = title
self.url = url

title: str
url: str

class FlowPageDesc(Struct):
id: str
type: str
Expand Down Expand Up @@ -594,13 +602,19 @@ class FlowDesc(Struct):
A list of :ref:`pages <flow-page>`. If you specify this, a single
:class:`FlowPageGroupDesc` will be implicitly created. Exactly one of
:attr:`groups` or :class:`pages` must be given.

.. attribute:: external_resources

A list of :class:`ExternalResourcesDesc`. These are links to external
resources that are displayed on the bottom of the flow page.
"""

title: str
description: str
rules: FlowRulesDesc
pages: list[FlowPageDesc]
groups: list[FlowPageGroupDesc]
external_resources: list[ExternalResourcesDesc]
notify_on_submit: list[str] | None

# }}}
Expand Down
2 changes: 1 addition & 1 deletion course/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
is_expiration_mode_allowed,
participation_permission as pperm,
)
from course.content import FlowPageDesc
from course.content import FlowPageDesc, ExternalResourcesDesc
from course.exam import get_login_exam_ticket
from course.models import (
Course,
Expand Down
21 changes: 21 additions & 0 deletions course/templates/course/flow-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,27 @@

{# }}} #}

{# {{{ external resources #}

{# if flow_desc.external_resources > #}
<p class="d-inline-flex gap-1">
{% for resource_desc in flow_desc.external_resources %}
<button class="btn btn-primary" data-bs-toggle="collapse" role="button" aria-expanded="false"
href="#externalResource{{ forloop.counter }}" aria-controls="externalResource{{ forloop.counter }}">
{{resource_desc.title }}</button>
{% endfor %}
</p>

{% for resource_desc in flow_desc.external_resources %}
<div class="collapse multi-collapse" id="externalResource{{ forloop.counter }}">
<div class="card card-body">
<iframe width="100%" height="1000" src="{{resource_desc.url}}" frameborder="0" allowfullscreen>
</iframe>
</div>
</div>
{% endfor %}

{# }}} #}
{# {{{ feedback #}

{% if show_correctness and feedback %}
Expand Down
1 change: 1 addition & 0 deletions course/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ def validate_flow_desc(vctx, location, flow_desc):
("groups", list),
("pages", list),
("notify_on_submit", list),
("external_resources", list),

# deprecated (moved to grading rule)
("max_points", (int, float)),
Expand Down