Skip to content

Commit

Permalink
Fix UI in lesson statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
adityacp committed Dec 22, 2020
1 parent 6945328 commit a29473b
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 80 deletions.
110 changes: 58 additions & 52 deletions stats/templates/view_lesson_tracking.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,59 +31,65 @@ <h3>Statistics for {% with trackings|first as entry %} {{entry.lesson}} {% endwi
<i class="fa fa-arrow-left"></i>&nbsp;Back
</a>
<br><br>
{% include "yaksh/paginator.html" %}
<br>
<div class="row">
<div class="col" id='barDiv1'></div>
<div class="col" id="barDiv2"></div>
<div class="col" id="barDiv3"></div>
<div class="row">
<div class="card" style="margin: 1%">
<div class="col" id='barDiv1'></div>
</div>
<div class="card" style="margin: 1%">
<div class="col" id="barDiv2"></div>
</div>
<script type="text/javascript">
var config = {responsive: true, displayModeBar: false}
var data = [
{
x: ["Completed", "Not Completed"],
y: ["{{completion.0}}", "{{completion.1}}"],
type: 'bar'
}
];
var layout = {
title: "Number of completions (Out of {{visits.2}})",
xaxis: {title: 'Completion status'},
yaxis: {title: 'Count'},
width: 400,
height: 400,
};
Plotly.newPlot('barDiv1', data, layout, config);
var data = [
{
x: ["Visited", "Not Visited"],
y: ["{{visits.0}}", "{{visits.1}}"],
type: 'bar'
}
];
var layout = {
title: "Number of visits (Out of {{visits.2}})",
xaxis: {title: 'Visit status'},
yaxis: {title: 'Count'},
width: 400,
height: 400,
};
Plotly.newPlot('barDiv2', data, layout, config);
var x_data = ["0-25", "25-50", "50-75", "75-100"], y_data = [];
{% for i, j in percentage_data.items %}
y_data.push("{{j}}")
{% endfor %}
var data = [{x: x_data, y: y_data, type: 'bar'}];
var layout = {
title: "Range wise completion (Out of {{total}})",
xaxis: {title: 'Percentage Range'},
yaxis: {title: 'Count'},
width: 400,
height: 400,
};
Plotly.newPlot('barDiv3', data, layout, config);
</script>
<div class="card" style="margin: 1%">
<div class="col" id="barDiv3"></div>
</div>
</div>
<script type="text/javascript">
var config = {responsive: true, displayModeBar: false}
var data = [
{
x: ["Completed", "Not Completed"],
y: ["{{completion.0}}", "{{completion.1}}"],
type: 'bar'
}
];
var layout = {
title: "Number of completions (Out of {{visits.2}})",
xaxis: {title: 'Completion status'},
yaxis: {title: 'Count'},
width: 400,
height: 400,
};
Plotly.newPlot('barDiv1', data, layout, config);
var data = [
{
x: ["Visited", "Not Visited"],
y: ["{{visits.0}}", "{{visits.1}}"],
type: 'bar'
}
];
var layout = {
title: "Number of visits (Out of {{visits.2}})",
xaxis: {title: 'Visit status'},
yaxis: {title: 'Count'},
width: 400,
height: 400,
};
Plotly.newPlot('barDiv2', data, layout, config);
var x_data = ["0-25", "25-50", "50-75", "75-100"], y_data = [];
{% for i, j in percentage_data.items %}
y_data.push("{{j}}")
{% endfor %}
var data = [{x: x_data, y: y_data, type: 'bar'}];
var layout = {
title: "Range wise completion (Out of {{total}})",
xaxis: {title: 'Percentage Range'},
yaxis: {title: 'Count'},
width: 400,
height: 400,
};
Plotly.newPlot('barDiv3', data, layout, config);
</script>
<br>
{% include "yaksh/paginator.html" %}
<br>
<div class="table-responsive">
<table class="table table-dark table-responsive-sm" id="stats-table">
Expand Down
2 changes: 1 addition & 1 deletion yaksh/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,7 @@ def get_question_stats(self, toc_id):
if answers.exists():
answers = answers.values(
"student__first_name", "student__last_name", "student__email",
"student_id", "toc_id"
"student_id", "student__profile__roll_number", "toc_id"
)
df = pd.DataFrame(answers)
answers = df.drop_duplicates().to_dict(orient='records')
Expand Down
71 changes: 44 additions & 27 deletions yaksh/templates/yaksh/show_lesson_statistics.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
{% else %}
<div class="card">
<div class="card-header">
{{question.summary}}
<div>
<b>{{question.summary}}</b>
<div style="font-size: 20px">
{% if question.language == "other" %}
<small class="text text-muted"><strong>Topic:</strong> <span class="badge badge-primary">{{question.topic}}</small></span>
{% else %}
Expand Down Expand Up @@ -132,15 +132,21 @@
{{tc.options}}
{% if per_tc_ans %}
{% get_tc_percent tc.id per_tc_ans as percent %}
<div class="progress" style="width: 30%">
{% if percent %}
<div class="progress-bar bg-success" role="progressbar" aria-valuenow="{{percent}}"
aria-valuemin="0" aria-valuemax="100" style="width:{{percent|floatformat}}%">
<b style="color: white;">{{percent|floatformat}}%</b>
<div class="progress-wrapper col-md-4">
<div class="progress-info">
<div class="progress-percentage">
<span>
{% if percent %} {{percent|floatformat}} {% else %} 0 {% endif %}%
</span>
</div>
</div>
<div class="progress">
{% if percent %}
<div class="progress-bar bg-success" role="progressbar" aria-valuenow="{{percent}}"
aria-valuemin="0" aria-valuemax="100" style="width:{{percent|floatformat}}%">
</div>
{% endif %}
</div>
{% else %}
<b style="color: black;">0%</b>
{% endif %}
</div>
{% endif %}
{% elif question.type == "integer" %}
Expand Down Expand Up @@ -180,25 +186,36 @@
<br><br>
{% endif %}
{% include "yaksh/paginator.html" %}
<table class="table table-responsive" id="stats-table">
<thead>
<tr>
<th>Sr No.</th>
<th>Student Name&nbsp;<i class="fa fa-sort"></i></th>
<th>Email&nbsp;<i class="fa fa-sort"></i></th>
<th>Latest Submission&nbsp;<i class="fa fa-sort"></i></th>
</tr>
</thead>
{% for data in objects.object_list %}
{% if objects.object_list|length > 10 %}
<div class="table-responsive" style="height: 700px">
{% else %}
<div class="table-responsive">
{% endif %}
<table class="table table-dark table-responsive" id="stats-table">
<thead class="thead-dark">
<tr>
<td>{{ forloop.counter }}</td>
<td>{{data.student__first_name}} {{data.student__last_name}}</td>
<td>{{data.student__email}}</td>
{% get_answers data.toc_id data.student_id as user_answer %}
<td>{{ user_answer.0 }}</td>
<th>Sr No.</th>
<th>Student Name&nbsp;<i class="fa fa-sort"></i></th>
<th>Roll No&nbsp;<i class="fa fa-sort"></i></th>
<th>Email&nbsp;<i class="fa fa-sort"></i></th>
<th>Latest Submission&nbsp;<i class="fa fa-sort"></i></th>
</tr>
{% endfor %}
</table>
</thead>
<tbody class="list">
{% for data in objects.object_list %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{data.student__first_name}} {{data.student__last_name}}</td>
<td>{{data.student__profile__roll_number}}</td>
<td>{{data.student__email}}</td>
{% get_answers data.toc_id data.student_id as user_answer %}
<td>{{ user_answer.0 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<br>
{% include "yaksh/paginator.html" %}
{% endif %}
</div>
Expand Down

0 comments on commit a29473b

Please sign in to comment.