Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
a854a0d8
Commit
a854a0d8
authored
Mar 25, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Downloadable HTML report
parent
40d6e56c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
mentoring/dashboard.py
+21
-2
mentoring/templates/html/dashboard.html
+5
-0
mentoring/templates/html/dashboard_report.html
+17
-0
No files found.
mentoring/dashboard.py
View file @
a854a0d8
...
...
@@ -32,6 +32,7 @@ import logging
from
.dashboard_visual
import
DashboardVisualData
from
.mcq
import
MCQBlock
from
.sub_api
import
sub_api
from
webob
import
Response
from
xblock.core
import
XBlock
from
xblock.exceptions
import
XBlockNotFoundError
from
xblock.fields
import
Scope
,
Dict
,
List
,
String
...
...
@@ -92,6 +93,7 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
)
editable_fields
=
(
'display_name'
,
'mentoring_ids'
,
'color_codes'
,
'visual_rules'
)
css_path
=
'public/css/dashboard.css'
def
get_mentoring_blocks
(
self
):
"""
...
...
@@ -118,7 +120,7 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
item_type
=
usage_key
.
block_type
,
)
def
generate_content
(
self
):
def
generate_content
(
self
,
include_report_link
=
True
):
"""
Create the HTML for this block, by getting the data and inserting it into a template.
"""
...
...
@@ -164,6 +166,7 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
'blocks'
:
blocks
,
'display_name'
:
self
.
display_name
,
'visual_repr'
:
visual_repr
,
'report_url'
:
self
.
runtime
.
handler_url
(
self
,
"download_report"
)
if
include_report_link
else
None
,
})
def
student_view
(
self
,
context
=
None
):
# pylint: disable=unused-argument
...
...
@@ -174,9 +177,25 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
return
Fragment
(
u"<h1>{}</h1><p>{}</p>"
.
format
(
self
.
display_name
,
_
(
"Not configured."
)))
fragment
=
Fragment
(
self
.
generate_content
())
fragment
.
add_css_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/css/dashboard.css'
))
fragment
.
add_css_url
(
self
.
runtime
.
local_resource_url
(
self
,
self
.
css_path
))
return
fragment
@XBlock.handler
def
download_report
(
self
,
request
=
None
,
suffix
=
None
):
# pylint: disable=unused-argument
if
not
self
.
mentoring_ids
:
return
Response
(
"Not generating report - it would be empty."
,
status
=
400
)
report_html
=
loader
.
render_template
(
'templates/html/dashboard_report.html'
,
{
'title'
:
self
.
display_name
,
'body'
:
self
.
generate_content
(
include_report_link
=
False
),
'css'
:
loader
.
load_unicode
(
self
.
css_path
),
})
return
Response
(
report_html
,
content_type
=
'text/html'
,
charset
=
'utf8'
,
content_disposition
=
'attachment; filename=report.html'
,
)
def
validate_field_data
(
self
,
validation
,
data
):
"""
Validate this block's field data.
...
...
mentoring/templates/html/dashboard.html
View file @
a854a0d8
...
...
@@ -47,4 +47,9 @@
</tbody>
{% endfor %}
</table>
{% if report_url %}
<br>
<p><a
href=
"{{ report_url }}"
>
{% trans "Download report" %}
</a></p>
{% endif %}
</div>
mentoring/templates/html/dashboard_report.html
0 → 100644
View file @
a854a0d8
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
{{ title }}
</title>
<style>
body
{
font-family
:
'Open Sans'
,
'Helvetica Neue'
,
Helvetica
,
Arial
,
sans-serif
;
}
{
{css
}
}
</style>
</head>
<body>
{{body}}
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment