Skip to content

Commit 3309a3a

Browse files
Improve cadmin UX: direct action buttons, consistent breadcrumbs, sortable columns
- Replace confusing dropdown+Apply action pattern with direct buttons on course admin page - Add POST guards to homework_score, homework_set_correct_answers, project_assign_reviews, project_score views - Move Django Admin link into the top button row - Fix duplicate breadcrumbs on enrollments pages (use block pattern like other pages) - Add search by email/username to enrollments page - Replace sort dropdown+button with clickable column headers showing ▲/▼ arrows on all list pages - Remove redundant "This is the admin panel" alert from course list Closes #161
1 parent 7d53cfd commit 3309a3a

7 files changed

Lines changed: 460 additions & 406 deletions

File tree

cadmin/templates/cadmin/course_admin.html

Lines changed: 26 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ <h2>{{ course.title }} - Admin Panel</h2>
1414
<a href="{% url 'course' course.slug %}" class="btn btn-secondary">View Course Page</a>
1515
<a href="{% url 'dashboard' course.slug %}" class="btn btn-info">Course Dashboard</a>
1616
<a href="{% url 'leaderboard' course.slug %}" class="btn btn-primary">Leaderboard</a>
17-
</div>
18-
19-
<div class="mb-3">
20-
<strong>Django Admin:</strong>
21-
<a href="/admin/courses/course/{{ course.id }}/change/">
22-
<i class="fas fa-edit"></i> Edit Course
17+
<a href="/admin/courses/course/{{ course.id }}/change/" class="btn btn-outline-secondary">
18+
<i class="fas fa-edit"></i> Django Admin
2319
</a>
2420
</div>
2521

@@ -72,18 +68,17 @@ <h3>Homework</h3>
7268
</td>
7369
<td>{{ hw.submissions_count }}</td>
7470
<td>
75-
<form method="post" style="display: inline;">
76-
{% csrf_token %}
77-
<select class="form-control form-control-sm d-inline-block" style="width: auto;" name="action" id="hw-action-{{ hw.id }}">
78-
<option value="">Select action...</option>
79-
{% if hw.state == 'OP' or hw.state == 'CL' %}
80-
<option value="{% url 'cadmin_homework_set_correct_answers' course.slug hw.slug %}">Set Correct Answers</option>
81-
<option value="{% url 'cadmin_homework_score' course.slug hw.slug %}">Score</option>
82-
{% endif %}
83-
<option value="{% url 'homework_statistics' course.slug hw.slug %}">View Statistics</option>
84-
</select>
85-
<button type="button" class="btn btn-sm btn-primary" onclick="applyAction('hw-action-{{ hw.id }}')">Apply</button>
86-
</form>
71+
{% if hw.state == 'OP' or hw.state == 'CL' %}
72+
<form method="post" action="{% url 'cadmin_homework_set_correct_answers' course.slug hw.slug %}" style="display: inline;" onsubmit="return confirm('Set correct answers to most popular for {{ hw.title }}?');">
73+
{% csrf_token %}
74+
<button type="submit" class="btn btn-sm btn-warning">Set Correct Answers</button>
75+
</form>
76+
<form method="post" action="{% url 'cadmin_homework_score' course.slug hw.slug %}" style="display: inline;" onsubmit="return confirm('Score all submissions for {{ hw.title }}?');">
77+
{% csrf_token %}
78+
<button type="submit" class="btn btn-sm btn-success">Score</button>
79+
</form>
80+
{% endif %}
81+
<a href="{% url 'homework_statistics' course.slug hw.slug %}" class="btn btn-sm btn-outline-primary">Statistics</a>
8782
</td>
8883
</tr>
8984
{% endfor %}
@@ -145,20 +140,19 @@ <h3>Projects</h3>
145140
</td>
146141
<td>{{ proj.submissions_count }}</td>
147142
<td>
148-
<form method="post" style="display: inline;">
149-
{% csrf_token %}
150-
<select class="form-control form-control-sm d-inline-block" style="width: auto;" name="action" id="proj-action-{{ proj.id }}">
151-
<option value="">Select action...</option>
152-
{% if proj.state == 'CS' %}
153-
<option value="{% url 'cadmin_project_assign_reviews' course.slug proj.slug %}">Assign Reviews</option>
154-
{% endif %}
155-
{% if proj.state == 'PR' %}
156-
<option value="{% url 'cadmin_project_score' course.slug proj.slug %}">Score</option>
157-
{% endif %}
158-
<option value="{% url 'project_statistics' course.slug proj.slug %}">View Statistics</option>
159-
</select>
160-
<button type="button" class="btn btn-sm btn-primary" onclick="applyAction('proj-action-{{ proj.id }}')">Apply</button>
161-
</form>
143+
{% if proj.state == 'CS' %}
144+
<form method="post" action="{% url 'cadmin_project_assign_reviews' course.slug proj.slug %}" style="display: inline;" onsubmit="return confirm('Assign peer reviews for {{ proj.title }}?');">
145+
{% csrf_token %}
146+
<button type="submit" class="btn btn-sm btn-warning">Assign Reviews</button>
147+
</form>
148+
{% endif %}
149+
{% if proj.state == 'PR' %}
150+
<form method="post" action="{% url 'cadmin_project_score' course.slug proj.slug %}" style="display: inline;" onsubmit="return confirm('Score all submissions for {{ proj.title }}?');">
151+
{% csrf_token %}
152+
<button type="submit" class="btn btn-sm btn-success">Score</button>
153+
</form>
154+
{% endif %}
155+
<a href="{% url 'project_statistics' course.slug proj.slug %}" class="btn btn-sm btn-outline-primary">Statistics</a>
162156
</td>
163157
</tr>
164158
{% endfor %}
@@ -170,27 +164,4 @@ <h3>Projects</h3>
170164
{% endif %}
171165
</div>
172166
</div>
173-
174-
<script>
175-
function applyAction(selectId) {
176-
const select = document.getElementById(selectId);
177-
const url = select.value;
178-
179-
if (!url) {
180-
alert('Please select an action');
181-
return;
182-
}
183-
184-
// For statistics, open in same tab
185-
if (url.includes('statistics')) {
186-
window.location.href = url;
187-
return;
188-
}
189-
190-
// For other actions, confirm first
191-
if (confirm('Are you sure you want to perform this action?')) {
192-
window.location.href = url;
193-
}
194-
}
195-
</script>
196167
{% endblock %}

cadmin/templates/cadmin/course_list.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
{% block cadmin_content %}
88
<h2>Course Administration</h2>
99

10-
<div class="alert alert-info" role="alert">
11-
This is the admin panel for managing courses. Only staff members can access this area.
12-
</div>
13-
1410
<div class="table-responsive">
1511
<table class="table table-striped">
1612
<thead>

0 commit comments

Comments
 (0)