Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mossutils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
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
import
csv
import
jinja2
import
argparse
import
datetime
import
pandas
as
pd
from
dataclasses
import
dataclass
from
.utils
import
logging
as
logutils
...
...
@@ -41,7 +42,7 @@ def aggregate(
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
relevant_course_columns
=
[
"Legi"
,
"Lastname"
,
"Firstname"
,
"Email"
,
"Gender"
,
"TotalScore"
]
relevant_course_columns
=
[
"Legi"
,
"Lastname"
,
"Firstname"
,
"Email"
,
"G
roupname"
,
"G
ender"
,
"TotalScore"
]
course_csv
:
pd
.
DataFrame
=
pd
.
read_csv
(
cx_course_students_csv_file
)
course_csv
=
course_csv
[
relevant_course_columns
]
course_csv
[
"TotalScore"
]
=
course_csv
[
"TotalScore"
].
round
(
0
)
...
...
@@ -222,8 +223,30 @@ def aggregate(
# 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
(
title
=
"Clusters"
,
timestamp
=
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d %H:%M"
),
clusters
=
jinja2_rows
,
edoz_count
=
edoz_csv
.
shape
[
0
],
course_count
=
course_csv
.
shape
[
0
],
...
...
mossutils/data/clusters.html.jinja
View file @
3a4a7e77
...
...
@@ -4,21 +4,75 @@
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"x-ua-compatible"
content=
"ie=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<title>
{{ title }}
</title>
{#
<link
rel=
"stylesheet"
href=
"css/main.css"
/>
<link
rel=
"icon"
href=
"images/favicon.png"
/>
#}
<style>
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>
<body
style=
"padding: 1em"
>
No. of eDoz students: {{ edoz_count }}
<br>
No. of CX students: {{ course_count }}
<span
style=
"color: #999999"
>
(may include staff)
</span><br>
No. of plagiarists: {{ plagiarist_count }}
<br>
{% for data in datapoints %}
{{ data.name }}: {{ data.percentage }}% ({{ data.part }}/{{ data.base }})
<br>
{% endfor %}
<table
style=
"border-spacing: 1em 2em"
>
<body>
<header>
<span
class=
"ident"
>
Generated
</span>
: {{ timestamp }}
<br>
<span
class=
"ident"
>
No. of eDoz students
</span>
: {{ edoz_count }}
<br>
<span
class=
"ident"
>
No. of CX students
</span>
: {{ course_count }}
<span
style=
"color: #999999"
>
(may include staff)
</span><br>
<span
class=
"ident"
>
No. of plagiarists
</span>
: {{ plagiarist_count }}
<br>
{% for data in datapoints %}
<span
class=
"ident"
>
{{ data.name }}
</span>
: {{ data.percentage }}% ({{ data.part }}/{{ data.base }})
<br>
{% endfor %}
</header>
<table
id=
"all-clusters"
>
<thead>
<tr>
<th
scope=
"col"
></th>
...
...
@@ -29,19 +83,8 @@
{% for (cluster_id, cluster_size, cluster, cluster_rows) in clusters %}
<tr>
<td>
Id: {{cluster_id}} | Size: {{ cluster_size }}
{{ cluster_rows.to_html(classes="cluster", header=False, index_names=False) }}
{#
<table>
{% for row in cluster_rows %}
<tr>
<td>
{{ row }}
</td>
{ #
<td></td>
<td></td>
# }
</tr>
{% endfor %}
</table>
#}
<div
class=
"cluster-header"
>
CID: {{cluster_id}} | Size: {{ cluster_size }}
</div>
{{ cluster_rows.to_html(classes="cluster", index_names=False, border=0, justify="left") }}
</td>
<td>
<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