Skip to content
This repository has been archived by the owner on Oct 11, 2018. It is now read-only.

Commit

Permalink
Version 1.8.6 (#70)
Browse files Browse the repository at this point in the history
• Better styles for assessment's results page.
• Fix a rendering bug of submenus under certain conditions.
• Code refactoring (Assessment) and documentation.
  • Loading branch information
natolh authored Apr 21, 2018
1 parent 89546b5 commit 8295f0f
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
Résumé
</a>
</li>
<li>
<a href="#" disabled>
Statistiques
</a>
</li>
<li>
<a href="{{ url_for('assessments.results', identifier=assessment.identifier) }}">
Résultats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@ <h1>{{ assessment.title }}</h1>
{% include 'assessments/assessment/menu.html' %}
</div>

<table>
<thead>
<tr>
<th>Identifiant</th>
<th>Note brute</th>
<th>Note ajustée</th>
</tr>
</thead>
<tbody>
{% for result in assessment.results %}
<tr>
<td>
{{ result.student.identifier }}
</td>
<td>
{{ result.score }}
</td>
<td>
{{ result.value|default(result.score) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div role="table" class="flex">
{% for result in assessment.results %}
<ul role="row">
<li role="cell">
<span class="heading">
Identifiant
</span>
{{ result.student.identifier }}
</li>
<li role="cell">
<span class="heading">
Note brute
</span>
{{ result.score|round(assessment.precision) }}
/ {{ result.scale }}
</li>
<li role="cell">
<span class="heading">
Note ajustée
</span>
{{ result.value|round(assessment.precision) }}
/ {{ result.scale }}
</li>
</ul>
{% endfor %}
</div>
{% endblock %}
40 changes: 34 additions & 6 deletions linnote/client/ressources/public/site/css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ main {
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
}

[role="navigation"].secondary > li {
display: flex;
margin: 0.15rem;
}

[role="navigation"].secondary a {
Expand All @@ -70,10 +72,6 @@ main {
background-color: rgba(209, 209, 209, 0.671);
}

[role="navigation"].secondary li:not(:last-child) {
margin-right: 0.3rem;
}

[role="navigation"].secondary a:hover {
color: white;
background-color: rgb(180, 180, 180);
Expand Down Expand Up @@ -102,13 +100,21 @@ main > * {
text-align: left;
}

.topping > :not(:first-child) {
margin-top: 0;
}

[role="navigation"].secondary {
grid-column: 2 / 3;
justify-content: flex-end;
}

.topping > :not(:first-child) {
margin-top: 0;
[role="navigation"].secondary > li {
margin: 0;
}

[role="navigation"].secondary li:not(:last-child) {
margin-right: 0.3rem;
}
}

Expand Down Expand Up @@ -160,3 +166,25 @@ a, button {
-moz-appearance: none;
vertical-align: middle;
}

/* Flex tables */

[role="table"].flex [role="row"] {
display: flex;
flex-flow: row nowrap;
width: 100%;
justify-content: space-between;
border-radius: 3px;
background-color: rgb(240, 240, 240);
margin-bottom: 0.3rem;
padding: 1rem;
}

[role="table"].flex > [role="row"] > [role="cell"]:not(:last-child) {
margin-right: 0.5rem;
}

[role="table"].flex [role="row"] [role="cell"] .heading {
display: block;
font-weight: bold;
}
39 changes: 21 additions & 18 deletions linnote/core/assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,32 @@ def __init__(self, title, coefficient, **kwargs):
if isinstance(kwargs.get('results'), FileStorage):
self.load(kwargs.get('results'), scale=kwargs.get('scale'))

if isinstance(kwargs.get('results'), list):
self.results = kwargs.get('results')

def __repr__(self):
return '<Assessment #{}: {}>'.format(self.identifier, self.title)

def __add__(self, other):

def merge_results(*args):
"""
Merge students results of multiple assessments.
- args: <Assessment> objects. Assessments to merge.
Return: List of <Mark> objects. Merged marks for each student.
"""
by_student = attrgetter('student.identifier')
results = [i for assessment in args for i in assessment.results]
results.sort(key=by_student)
return [sum(marks) for _, marks in groupby(results, by_student)]

if isinstance(other, Assessment):
assessments = [self, other]
assessment = Assessment(
title='[{} {}]'.format(self.title, other.title),
coefficient=self.coefficient + other.coefficient,
precision=min([self.precision, other.precision]))
assessment.results = list(self._aggregate(assessments))
return assessment
return Assessment(title='[{} {}]'.format(self.title, other.title),
coefficient=self.coefficient + other.coefficient,
precision=min([self.precision, other.precision]),
results=merge_results(self, other))

return NotImplemented

Expand All @@ -199,17 +213,6 @@ def __radd__(self, other):

return NotImplemented

@staticmethod
def _aggregate(assessments):
"""Aggregate students results of multiple assessments."""
by_student = attrgetter('student.identifier')
results = [mark for a in assessments for mark in a.results]
results.sort(key=by_student)

for _, marks in groupby(results, by_student):
marks = list(marks)
yield sum(marks)

def load(self, path, scale):
"""
Load assessment's results from a tabular file.
Expand Down
8 changes: 4 additions & 4 deletions linnote/core/ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def sequential(position, size):
return position, 1


class Ranking(object):
class Ranking:
"""A ranked sequence of things."""

def __init__(self, items, key=None, **kwargs):
Expand All @@ -108,7 +108,7 @@ def __init__(self, items, key=None, **kwargs):
Return: None.
"""
super(Ranking, self).__init__()
super().__init__()
self.ranks = [Rank(item, key(item)) for item in items]
self.key = attrgetter('score')
self.start = kwargs.get('start', 1)
Expand All @@ -135,7 +135,7 @@ def rank(self):
yield from zip(ranks, group)


class Rank(object):
class Rank:
"""Ranking item."""

def __init__(self, item, score, position=None):
Expand All @@ -149,7 +149,7 @@ def __init__(self, item, score, position=None):
Return: None.
"""
super(Rank, self).__init__()
super().__init__()
self.item = item
self.score = score
self.position = position
Expand Down

0 comments on commit 8295f0f

Please sign in to comment.