Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dinfk-lecturers
mossutils
Commits
3a4a7e77
Commit
3a4a7e77
authored
Nov 08, 2020
by
scmalte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aggr.py: improved layout of generated clusters.html
parent
180074ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
25 deletions
+91
-25
mossutils/aggr.py
mossutils/aggr.py
+24
-1
mossutils/data/clusters.html.jinja
mossutils/data/clusters.html.jinja
+67
-24
No files found.
mossutils/aggr.py
View file @
3a4a7e77
...
@@ -3,6 +3,7 @@ import logging
...
@@ -3,6 +3,7 @@ import logging
import
csv
import
csv
import
jinja2
import
jinja2
import
argparse
import
argparse
import
datetime
import
pandas
as
pd
import
pandas
as
pd
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
.utils
import
logging
as
logutils
from
.utils
import
logging
as
logutils
...
@@ -41,7 +42,7 @@ def aggregate(
...
@@ -41,7 +42,7 @@ def aggregate(
clusters_csv
:
pd
.
DataFrame
=
pd
.
read_csv
(
clusters_matches_csv_file
)
clusters_csv
:
pd
.
DataFrame
=
pd
.
read_csv
(
clusters_matches_csv_file
)
# Read CX course data, reduce to relevant columns, truncate TotalScore (which are floats), set index column
# Read CX course data, reduce to relevant columns, truncate TotalScore (which are floats), set index column
relevant_course_columns
=
[
"Legi"
,
"Lastname"
,
"Firstname"
,
"Email"
,
"Gender"
,
"TotalScore"
]
relevant_course_columns
=
[
"Legi"
,
"Lastname"
,
"Firstname"
,
"Email"
,
"Groupname"
,
"Gender"
,
"TotalScore"
]
course_csv
:
pd
.
DataFrame
=
pd
.
read_csv
(
cx_course_students_csv_file
)
course_csv
:
pd
.
DataFrame
=
pd
.
read_csv
(
cx_course_students_csv_file
)
course_csv
=
course_csv
[
relevant_course_columns
]
course_csv
=
course_csv
[
relevant_course_columns
]
course_csv
[
"TotalScore"
]
=
course_csv
[
"TotalScore"
].
round
(
0
)
course_csv
[
"TotalScore"
]
=
course_csv
[
"TotalScore"
].
round
(
0
)
...
@@ -222,8 +223,30 @@ def aggregate(
...
@@ -222,8 +223,30 @@ def aggregate(
# print(datapoints)
# print(datapoints)
# Final preparations before creating the HTML report
for
cluster_id
,
_
,
_
,
cluster_rows
in
jinja2_rows
:
# Convert total scores from floats to integers, to reduce output width.
# Total scores are effectively integers, anyway.
# fillna(0) replaces each NA/NaN with zero; this is done to prevent errors,
# since NA/NaN cannot be converted to int.
cluster_rows
[
"TotalScore"
]
=
\
cluster_rows
[
"TotalScore"
].
fillna
(
0
).
astype
(
int
)
# Rename columns to reduce output width.
cluster_rows
.
rename
(
columns
=
{
"Lastname"
:
"Last"
,
"Firstname"
:
"First"
,
"Groupname"
:
"Group"
,
"Gender"
:
"Gnd."
,
"TotalScore"
:
"Tot. score"
,
"Departement"
:
"Dept."
,
"Cluster-ID"
:
"CID"
},
inplace
=
True
)
template
.
stream
(
template
.
stream
(
title
=
"Clusters"
,
title
=
"Clusters"
,
timestamp
=
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d %H:%M"
),
clusters
=
jinja2_rows
,
clusters
=
jinja2_rows
,
edoz_count
=
edoz_csv
.
shape
[
0
],
edoz_count
=
edoz_csv
.
shape
[
0
],
course_count
=
course_csv
.
shape
[
0
],
course_count
=
course_csv
.
shape
[
0
],
...
...
mossutils/data/clusters.html.jinja
View file @
3a4a7e77
...
@@ -4,21 +4,75 @@
...
@@ -4,21 +4,75 @@
<meta
charset=
"utf-8"
/>
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"x-ua-compatible"
content=
"ie=edge"
/>
<meta
http-equiv=
"x-ua-compatible"
content=
"ie=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<title>
{{ title }}
</title>
<title>
{{ title }}
</title>
{#
<link
rel=
"stylesheet"
href=
"css/main.css"
/>
<style>
<link
rel=
"icon"
href=
"images/favicon.png"
/>
#}
body
{
padding
:
1em
;
font-family
:
Arial
,
x-locale-body
,
sans-serif
;
font-size
:
0.9em
;
}
header
{
font-size
:
1.1em
;
}
header
span
.ident
{
font-weight
:
bold
;
}
#all-clusters
{
border-spacing
:
0em
2em
;
}
#all-clusters
td
:last-of-type
{
padding-left
:
2em
;
}
table
.cluster
{
border-collapse
:
collapse
;
border
:
1px
solid
#ccc
;
font-size
:
0.9em
}
table
.cluster
th
,
table
.cluster
td
{
padding
:
3px
6px
;
}
/*table.cluster tbody tr {
border-bottom: 1px solid #dddddd;
}*/
table
.cluster
tbody
tr
:nth-of-type
(
even
)
{
background-color
:
#f3f3f3
;
}
/* table.cluster tbody tr:last-of-type {
border-bottom: 2px solid #009879;
} */
div
.cluster-header
{
background-color
:
#ccc
;
width
:
max-content
;
padding
:
2px
10px
;
border-radius
:
5px
5px
0
0
;
}
</style>
</head>
</head>
<body
style=
"padding: 1em"
>
<body>
No. of eDoz students: {{ edoz_count }}
<br>
<header>
No. of CX students: {{ course_count }}
<span
style=
"color: #999999"
>
(may include staff)
</span><br>
<span
class=
"ident"
>
Generated
</span>
: {{ timestamp }}
<br>
No. of plagiarists: {{ plagiarist_count }}
<br>
<span
class=
"ident"
>
No. of eDoz students
</span>
: {{ edoz_count }}
<br>
{% for data in datapoints %}
<span
class=
"ident"
>
No. of CX students
</span>
: {{ course_count }}
<span
style=
"color: #999999"
>
(may include staff)
</span><br>
{{ data.name }}: {{ data.percentage }}% ({{ data.part }}/{{ data.base }})
<br>
<span
class=
"ident"
>
No. of plagiarists
</span>
: {{ plagiarist_count }}
<br>
{% endfor %}
{% for data in datapoints %}
<table
style=
"border-spacing: 1em 2em"
>
<span
class=
"ident"
>
{{ data.name }}
</span>
: {{ data.percentage }}% ({{ data.part }}/{{ data.base }})
<br>
{% endfor %}
</header>
<table
id=
"all-clusters"
>
<thead>
<thead>
<tr>
<tr>
<th
scope=
"col"
></th>
<th
scope=
"col"
></th>
...
@@ -29,19 +83,8 @@
...
@@ -29,19 +83,8 @@
{% for (cluster_id, cluster_size, cluster, cluster_rows) in clusters %}
{% for (cluster_id, cluster_size, cluster, cluster_rows) in clusters %}
<tr>
<tr>
<td>
<td>
Id: {{cluster_id}} | Size: {{ cluster_size }}
<div
class=
"cluster-header"
>
CID: {{cluster_id}} | Size: {{ cluster_size }}
</div>
{{ cluster_rows.to_html(classes="cluster", header=False, index_names=False) }}
{{ cluster_rows.to_html(classes="cluster", index_names=False, border=0, justify="left") }}
{#
<table>
{% for row in cluster_rows %}
<tr>
<td>
{{ row }}
</td>
{ #
<td></td>
<td></td>
# }
</tr>
{% endfor %}
</table>
#}
</td>
</td>
<td>
<td>
<object
data=
"{{ cluster['svg_file'].iat[0] }}"
type=
"image/svg+xml"
style=
"transform:scale(60%); max-width: 75em; visibility: hidden"
></object>
<object
data=
"{{ cluster['svg_file'].iat[0] }}"
type=
"image/svg+xml"
style=
"transform:scale(60%); max-width: 75em; visibility: hidden"
></object>
...
...
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