Skip to content

Commit 3a00a3d

Browse files
Add submission edit links to enrollment page and clear LiP buttons
Co-authored-by: alexeygrigorev <875246+alexeygrigorev@users.noreply.github.com>
1 parent f577e8e commit 3a00a3d

4 files changed

Lines changed: 113 additions & 2 deletions

File tree

cadmin/templates/cadmin/enrollment_edit.html

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,82 @@ <h3>Learning in Public Control</h3>
117117
</div>
118118
</div>
119119

120+
<div class="card my-4">
121+
<div class="card-header">
122+
<h3>Homework Submissions</h3>
123+
</div>
124+
<div class="card-body">
125+
{% if homework_submissions %}
126+
<div class="table-responsive">
127+
<table class="table table-striped table-hover">
128+
<thead>
129+
<tr>
130+
<th>Homework</th>
131+
<th>Submitted</th>
132+
<th>Score</th>
133+
<th>Actions</th>
134+
</tr>
135+
</thead>
136+
<tbody>
137+
{% for submission in homework_submissions %}
138+
<tr>
139+
<td>{{ submission.homework.title }}</td>
140+
<td>{{ submission.submitted_at|date:"Y-m-d H:i" }}</td>
141+
<td>{{ submission.total_score }}</td>
142+
<td>
143+
<a href="{% url 'cadmin_homework_submission_edit' course.slug submission.homework.slug submission.id %}" class="btn btn-sm btn-primary">
144+
<i class="fas fa-edit"></i> Edit
145+
</a>
146+
</td>
147+
</tr>
148+
{% endfor %}
149+
</tbody>
150+
</table>
151+
</div>
152+
{% else %}
153+
<p class="text-muted">No homework submissions yet.</p>
154+
{% endif %}
155+
</div>
156+
</div>
157+
158+
<div class="card my-4">
159+
<div class="card-header">
160+
<h3>Project Submissions</h3>
161+
</div>
162+
<div class="card-body">
163+
{% if project_submissions %}
164+
<div class="table-responsive">
165+
<table class="table table-striped table-hover">
166+
<thead>
167+
<tr>
168+
<th>Project</th>
169+
<th>Submitted</th>
170+
<th>Score</th>
171+
<th>Actions</th>
172+
</tr>
173+
</thead>
174+
<tbody>
175+
{% for submission in project_submissions %}
176+
<tr>
177+
<td>{{ submission.project.title }}</td>
178+
<td>{{ submission.submitted_at|date:"Y-m-d H:i" }}</td>
179+
<td>{{ submission.total_score }}</td>
180+
<td>
181+
<a href="{% url 'cadmin_project_submission_edit' course.slug submission.project.slug submission.id %}" class="btn btn-sm btn-primary">
182+
<i class="fas fa-edit"></i> Edit
183+
</a>
184+
</td>
185+
</tr>
186+
{% endfor %}
187+
</tbody>
188+
</table>
189+
</div>
190+
{% else %}
191+
<p class="text-muted">No project submissions yet.</p>
192+
{% endif %}
193+
</div>
194+
</div>
195+
120196
<div class="my-4">
121197
<a href="{% url 'leaderboard_score_breakdown' course_slug=course.slug enrollment_id=enrollment.id %}" class="btn btn-secondary">View Score Breakdown</a>
122198
<a href="{% url 'leaderboard' course.slug %}" class="btn btn-secondary">View Leaderboard</a>

cadmin/templates/cadmin/homework_submission_edit.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,20 @@ <h4>Learning in Public Links</h4>
136136
Enter URLs separated by commas. Each link contributes to the learning in public score (capped at {{ homework.learning_in_public_cap }}).
137137
</small>
138138
</div>
139+
<button type="button" class="btn btn-warning" id="clear-lip-links" onclick="clearLearningInPublicLinks()">
140+
<i class="fas fa-trash"></i> Remove Learning in Public Links
141+
</button>
139142
</div>
140143
</div>
141144

145+
<script>
146+
function clearLearningInPublicLinks() {
147+
if (confirm('Are you sure you want to remove all learning in public links for this submission? This will set the learning in public score to 0.')) {
148+
document.getElementById('learning_in_public_links').value = '';
149+
}
150+
}
151+
</script>
152+
142153
<div class="card mb-3">
143154
<div class="card-header">
144155
<h4>Current Scores (Read-Only)</h4>

cadmin/templates/cadmin/project_submission_edit.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ <h4>Additional Project Scores</h4>
8484
<div class="form-group mb-3">
8585
<label for="project_learning_in_public_score">Project Learning in Public Score</label>
8686
<input type="number" class="form-control additional-score" id="project_learning_in_public_score" name="project_learning_in_public_score" value="{{ submission.project_learning_in_public_score }}" required>
87+
<button type="button" class="btn btn-sm btn-warning mt-2" onclick="clearProjectLearningInPublicScore()">
88+
<i class="fas fa-trash"></i> Remove Project Learning in Public Score
89+
</button>
8790
</div>
8891
</div>
8992
</div>
@@ -101,6 +104,9 @@ <h4>Peer Review Scores</h4>
101104
<div class="form-group mb-3">
102105
<label for="peer_review_learning_in_public_score">Peer Review Learning in Public Score</label>
103106
<input type="number" class="form-control peer-review-score" id="peer_review_learning_in_public_score" name="peer_review_learning_in_public_score" value="{{ submission.peer_review_learning_in_public_score }}" required>
107+
<button type="button" class="btn btn-sm btn-warning mt-2" onclick="clearPeerReviewLearningInPublicScore()">
108+
<i class="fas fa-trash"></i> Remove Peer Review Learning in Public Score
109+
</button>
104110
</div>
105111
</div>
106112
</div>
@@ -220,6 +226,22 @@ <h4>Overall Results</h4>
220226
// Calculate initial values
221227
calculateTotal();
222228
});
229+
230+
function clearProjectLearningInPublicScore() {
231+
if (confirm('Are you sure you want to remove the project learning in public score? This will set it to 0.')) {
232+
document.getElementById('project_learning_in_public_score').value = '0';
233+
// Trigger recalculation
234+
document.getElementById('project_learning_in_public_score').dispatchEvent(new Event('input'));
235+
}
236+
}
237+
238+
function clearPeerReviewLearningInPublicScore() {
239+
if (confirm('Are you sure you want to remove the peer review learning in public score? This will set it to 0.')) {
240+
document.getElementById('peer_review_learning_in_public_score').value = '0';
241+
// Trigger recalculation
242+
document.getElementById('peer_review_learning_in_public_score').dispatchEvent(new Event('input'));
243+
}
244+
}
223245
</script>
224246

225247
{% endblock %}

cadmin/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ def enrollment_edit(request, course_slug, enrollment_id):
532532
return redirect("cadmin_enrollment_edit", course_slug=course_slug, enrollment_id=enrollment_id)
533533

534534
# Get some stats about this enrollment
535-
homework_submissions = Submission.objects.filter(enrollment=enrollment)
536-
project_submissions = ProjectSubmission.objects.filter(enrollment=enrollment)
535+
homework_submissions = Submission.objects.filter(enrollment=enrollment).select_related('homework').order_by('-submitted_at')
536+
project_submissions = ProjectSubmission.objects.filter(enrollment=enrollment).select_related('project').order_by('-submitted_at')
537537

538538
total_homework_lip_score = sum(s.learning_in_public_score for s in homework_submissions)
539539
total_project_lip_score = sum(
@@ -544,7 +544,9 @@ def enrollment_edit(request, course_slug, enrollment_id):
544544
context = {
545545
"course": course,
546546
"enrollment": enrollment,
547+
"homework_submissions": homework_submissions,
547548
"homework_submissions_count": homework_submissions.count(),
549+
"project_submissions": project_submissions,
548550
"project_submissions_count": project_submissions.count(),
549551
"total_homework_lip_score": total_homework_lip_score,
550552
"total_project_lip_score": total_project_lip_score,

0 commit comments

Comments
 (0)