-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper to generate export tokens for campus portal integration (#23)
* Add helper to generate export tokens for campus portal integration * add view for campus export, integrate javascript method to copy link * setup CampusExportForm for link generation for each course level * enhance layout, integrate javascript function to copy link on click * integrate logic for campus grade export * replace dict response with jsonify to create valid json response * dont submit students that did not pass the course to campus * validate parameter formats for campus grade export --------- Co-authored-by: jan <[email protected]> Co-authored-by: Jan Fenker <[email protected]>
- Loading branch information
1 parent
3db16e2
commit 07eeaa4
Showing
10 changed files
with
295 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from datetime import datetime, timedelta | ||
from spz import app, tasks | ||
|
||
import jwt | ||
|
||
def generate_export_token_for_courses(courses): | ||
return jwt.encode({'courses': courses, 'exp': datetime.utcnow() + timedelta(hours=1)}, | ||
key=app.config['SECRET_KEY'], algorithm="HS256") | ||
|
||
def get_courses_from_export_token(export_token): | ||
try: | ||
courses = jwt.decode(export_token, key=app.config['SECRET_KEY'], algorithms="HS256")['courses'] | ||
|
||
if isinstance(courses, list): | ||
return courses | ||
|
||
return False | ||
except Exception as e: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/spz/templates/internal/campusportal/campus_export.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% extends 'internal/internal.html' %} | ||
{% from 'formhelpers.html' import td_sorted, csrf_field, render_option, render_submit %} | ||
|
||
{% block caption %} | ||
Noten-Export für Campus Portal | ||
{% endblock caption %} | ||
|
||
|
||
{% block internal_body %} | ||
<div class="row"> | ||
<form method="post" class="ui form"> | ||
{{ csrf_field() }} | ||
<h3 class="ui dividing header">Auswahl</h3> | ||
{{ render_option(form.courses, required=True, help='Kurslevel für Export auswählen') }} | ||
|
||
|
||
{{ render_submit(submit='Export-Link Generieren') }} | ||
|
||
</form> | ||
</div> | ||
{% if link|length > 0 %} | ||
<div class="row"> | ||
<h3 class="ui dividing header">Export-Link</h3> | ||
<p>Der Export-Link für das Campus Portal wurde generiert. Dieser Link kann in das Campus Portal eingefügt | ||
werden, um die Noten der Kurse mit dem gewählten Level zu importieren.</p> | ||
<div id="notification">Link wurde in die Zwischenablage kopiert.</div> | ||
<div> | ||
<input type="hidden" value="{{ link }}" id="hiddenText"> | ||
<div class="ui button" onclick="copyToClipboard()">Link Kopieren</div> | ||
</div> | ||
<div class="ui message"> | ||
<div class="header">Export-Link</div> | ||
<p>{{ link }}</p> | ||
</div> | ||
</div> | ||
{% endif %} | ||
{% endblock internal_body %} |
28 changes: 28 additions & 0 deletions
28
src/spz/templates/internal/campusportal/campus_export_language.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'internal/internal.html' %} | ||
{% from 'formhelpers.html' import td_sorted %} | ||
|
||
{% block caption %} | ||
Noten-Export für Campus Portal | ||
{% endblock caption %} | ||
|
||
|
||
{% block internal_body %} | ||
<div class="row"> | ||
<table class="ui selectable sortable compact small striped table"> | ||
<thead> | ||
<tr> | ||
<th>Sprache</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for l in language %} | ||
<tr> | ||
<td><a | ||
href="{{ url_for('campus_export_course', id=l.id) }}"><strong>{{ l.name }}</strong></a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
{% endblock internal_body %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.