Add time answered
This commit is contained in:
@@ -2,101 +2,109 @@
|
|||||||
{% load help_tags %}
|
{% load help_tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container py-4">
|
<div class="container py-4">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-12 col-lg-10">
|
<div class="col-12 col-lg-10">
|
||||||
<div class="card shadow mb-4">
|
<div class="card shadow mb-4">
|
||||||
<div class="card-header bg-dark text-white d-flex justify-content-between align-items-center">
|
<div class="card-header bg-dark text-white d-flex justify-content-between align-items-center">
|
||||||
<h3 class="card-title mb-0">Answer Revision History</h3>
|
<h3 class="card-title mb-0">Answer Revision History</h3>
|
||||||
<span class="badge bg-secondary fs-6">{{ history|length }} version{{ history|pluralize }}</span>
|
<span class="badge bg-secondary fs-6">{{ history|length }} version{{ history|pluralize }}</span>
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row mb-4">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<strong>App/Model:</strong> <span class="text-primary">{{ app_name }}.{{ model_name }}</span><br>
|
|
||||||
<strong>Answer ID:</strong> <span class="text-primary">{{ answer.pk }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 text-md-end">
|
|
||||||
{% if exam %}
|
|
||||||
<strong>Exam:</strong> <span class="text-info">{{ exam }}</span>
|
|
||||||
{% elif collection %}
|
|
||||||
<strong>Case Collection:</strong> <span class="text-info">{{ collection }}</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="row mb-4">
|
||||||
<table class="table table-striped table-hover align-middle">
|
<div class="col-md-6">
|
||||||
<thead class="table-dark">
|
<strong>App/Model:</strong> <span class="text-primary">{{ app_name }}.{{ model_name }}</span><br>
|
||||||
<tr>
|
<strong>Answer ID:</strong> <span class="text-primary">{{ answer.pk }}</span>
|
||||||
<th style="width: 80px;">Rev ID</th>
|
</div>
|
||||||
<th style="width: 180px;">Date / Time</th>
|
<div class="col-md-6 text-md-end">
|
||||||
<th style="width: 150px;">Editor</th>
|
{% if exam %}
|
||||||
<th>Answer Value</th>
|
<strong>Exam:</strong> <span class="text-info">{{ exam }}</span>
|
||||||
<th style="width: 100px;">Score</th>
|
{% elif collection %}
|
||||||
<th>Comment</th>
|
<strong>Case Collection:</strong> <span class="text-info">{{ collection }}</span>
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for rev in history %}
|
|
||||||
<tr>
|
|
||||||
<td><code>#{{ rev.revision_id }}</code></td>
|
|
||||||
<td>{{ rev.date }}</td>
|
|
||||||
<td>
|
|
||||||
{% if rev.user %}
|
|
||||||
<span class="badge bg-light text-dark">{{ rev.user.username }}</span>
|
|
||||||
{% else %}
|
|
||||||
<span class="text-muted italic">System / Anon</span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<pre class="mb-0 bg-light text-dark p-2 rounded" style="white-space: pre-wrap; font-size: 0.85rem;">{{ rev.answer_text }}</pre>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if rev.score is not None and rev.score != "" %}
|
|
||||||
<span class="badge bg-primary">{{ rev.score }}</span>
|
|
||||||
{% else %}
|
|
||||||
<span class="text-muted">-</span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td><small class="text-muted">{{ rev.comment|default:"-" }}</small></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if request.user.is_superuser or request.user.is_staff %}
|
|
||||||
<!-- Compacting tools panel -->
|
|
||||||
<div class="card mt-4 border-warning">
|
|
||||||
<div class="card-header bg-warning-subtle text-warning-emphasis fw-bold">
|
|
||||||
<i class="bi bi-scissors me-1"></i> Compact History Settings
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="text-muted small">
|
|
||||||
Compacting history deletes all older versions and their associated revision logs, retaining only the final answer database state. This is permanent and cannot be undone.
|
|
||||||
</p>
|
|
||||||
<div class="d-flex flex-wrap gap-3">
|
|
||||||
{% if exam or collection %}
|
|
||||||
<form method="post" style="display:inline;">
|
|
||||||
{% csrf_token %}
|
|
||||||
<input type="hidden" name="action" value="compact_bulk">
|
|
||||||
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete all historical revisions for ALL candidate answers in this entire exam/collection?');">
|
|
||||||
Compact Entire {% if exam %}Exam{% else %}Collection{% endif %}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endif %}
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-hover align-middle">
|
||||||
<div class="d-flex justify-content-between mt-4">
|
<thead class="table-dark">
|
||||||
<button type="button" class="btn btn-secondary" onclick="window.history.back();">Back</button>
|
<tr>
|
||||||
|
<th style="width: 80px;">Rev ID</th>
|
||||||
|
<th style="width: 180px;">Date / Time</th>
|
||||||
|
<th style="width: 150px;">Editor</th>
|
||||||
|
<th>Answer Value</th>
|
||||||
|
<th style="width: 100px;">Score</th>
|
||||||
|
<th>Comment</th>
|
||||||
|
<th>Time answered</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for rev in history %}
|
||||||
|
<tr>
|
||||||
|
<td><code>#{{ rev.revision_id }}</code></td>
|
||||||
|
<td>{{ rev.date }}</td>
|
||||||
|
<td>
|
||||||
|
{% if rev.user %}
|
||||||
|
<span class="badge bg-light text-dark">{{ rev.user.username }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted italic">System / Anon</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<pre class="mb-0 bg-light text-dark p-2 rounded" style="white-space: pre-wrap; font-size: 0.85rem;">{{ rev.answer_text }}</pre>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if rev.score is not None and rev.score != "" %}
|
||||||
|
<span class="badge bg-primary">{{ rev.score }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">-</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td><small class="text-muted">{{ rev.comment|default:"-" }}</small></td>
|
||||||
|
<td>
|
||||||
|
{% if rev.time_answered %}
|
||||||
|
{{ rev.time_answered }}
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted
|
||||||
|
">-</span>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if request.user.is_superuser or request.user.is_staff %}
|
||||||
|
<!-- Compacting tools panel -->
|
||||||
|
<div class="card mt-4 border-warning">
|
||||||
|
<div class="card-header bg-warning-subtle text-warning-emphasis fw-bold">
|
||||||
|
<i class="bi bi-scissors me-1"></i> Compact History Settings
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="text-muted small">
|
||||||
|
Compacting history deletes all older versions and their associated revision logs, retaining only the final answer database state. This is permanent and cannot be undone.
|
||||||
|
</p>
|
||||||
|
<div class="d-flex flex-wrap gap-3">
|
||||||
|
{% if exam or collection %}
|
||||||
|
<form method="post" style="display:inline;">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="action" value="compact_bulk">
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete all historical revisions for ALL candidate answers in this entire exam/collection?');">
|
||||||
|
Compact Entire {% if exam %}Exam{% else %}Collection{% endif %}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between mt-4">
|
||||||
|
<button type="button" class="btn btn-secondary" onclick="window.history.back();">Back</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -5346,6 +5346,7 @@ def view_answer_history(request, app_name, model_name, pk):
|
|||||||
)
|
)
|
||||||
elif model_name.lower() == "useranswer" and app_name.lower() == "physics":
|
elif model_name.lower() == "useranswer" and app_name.lower() == "physics":
|
||||||
ans_text = f"A: {fields.get('a')}, B: {fields.get('b')}, C: {fields.get('c')}, D: {fields.get('d')}, E: {fields.get('e')}"
|
ans_text = f"A: {fields.get('a')}, B: {fields.get('b')}, C: {fields.get('c')}, D: {fields.get('d')}, E: {fields.get('e')}"
|
||||||
|
|
||||||
|
|
||||||
history_data.append({
|
history_data.append({
|
||||||
"revision_id": v.revision_id,
|
"revision_id": v.revision_id,
|
||||||
@@ -5354,6 +5355,7 @@ def view_answer_history(request, app_name, model_name, pk):
|
|||||||
"answer_text": ans_text,
|
"answer_text": ans_text,
|
||||||
"score": fields.get("score", ""),
|
"score": fields.get("score", ""),
|
||||||
"comment": v.revision.comment,
|
"comment": v.revision.comment,
|
||||||
|
"time_answered": fields.get("time_answered", ""),
|
||||||
})
|
})
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
|
|||||||
Reference in New Issue
Block a user