Skip to content

Commit de67e15

Browse files
committed
when re-opening an attempt, save a RemarkedScormElement
So in the attempt timeline, you can see who re-opened it.
1 parent 4519623 commit de67e15

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

numbas_lti/models.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,8 @@ class Meta:
897897
ordering = ['-time',]
898898

899899
COMPLETION_STATUSES = [
900-
('not attempted',_('Not attempted')),
901-
('incomplete',_('Incomplete')),
900+
('not attempted',_('Not started')),
901+
('incomplete',_('In progress')),
902902
('completed',_('Complete')),
903903
]
904904

@@ -1293,6 +1293,23 @@ def finalise(self):
12931293
'completion_status':'completed',
12941294
})
12951295

1296+
def reopen(self, reopened_by=None):
1297+
e = ScormElement.objects.create(
1298+
attempt=self,
1299+
key='cmi.completion_status',
1300+
value='incomplete',
1301+
time=timezone.now(),
1302+
counter=1
1303+
)
1304+
1305+
if reopened_by:
1306+
RemarkedScormElement.objects.create(element=e, user=reopened_by)
1307+
1308+
self.completion_status = 'incomplete'
1309+
self.sent_receipt = False
1310+
self.receipt_time = None
1311+
self.save(update_fields=('completion_status', 'sent_receipt', 'receipt_time',))
1312+
12961313
@property
12971314
def raw_score(self):
12981315
if self.remarked_parts.exists() or self.resource.discounted_parts.exists():

numbas_lti/static/attempt_timeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ const app = createApp({
237237
if(key=='cmi.completion_status') {
238238
this.completion_status = element.value;
239239
var messages = {
240-
'incomplete': _('Started the attempt.'),
240+
'incomplete': element.remarked ? _('Re-opened the attempt.') : _('Started the attempt.'),
241241
'completed': _('Ended the attempt.'),
242242
};
243243
var message = messages[element.value];

numbas_lti/templates/numbas_lti/management/attempt_timeline.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<span v-else><time :datetime="item.time_iso">[[item.time_string]]</time></span>
5050
</p>
5151
<p v-if="group.remarked_by" class="remarked-by small">
52-
{% translate "Re-marked by" %}
52+
{% translate "Changed by" %}
5353
<span>[[group.remarked_by]]</span>
5454
</p>
5555
</td>

numbas_lti/templates/numbas_lti/show_attempts.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ <h1>
3838
<thead>
3939
<tr>
4040
<th scope="col">{% translate "Start time" %}</th>
41+
<th scope="col">{% translate "Status" %}</th>
4142
<th scope="col">{% translate "Score" %}</th>
42-
<th scope="col"></th>
43+
<th scope="col"><span class="sr-only">{% translate "Controls" %}</span></th>
4344
</tr>
4445
</thead>
4546
<tbody>
4647
{% if can_start_new_attempt %}
4748
<tr>
48-
<td colspan="2">
49+
<td colspan="3">
4950
<td>
5051
<a class="button warning" href="{% url_with_lti 'new_attempt' %}">{% icon 'plus' %} {% translate "Start a new attempt" %}</a>
5152
</td>
@@ -54,15 +55,10 @@ <h1>
5455
{% for attempt in object_list %}
5556
<tr>
5657
<td>{% time_tag attempt.start_time %}</td>
58+
<td>{{attempt.get_completion_status_display}}</td>
5759
<td>
5860
{% if attempt.should_show_scores %}
5961
{{attempt.raw_score}} / {{attempt.max_score}} ({{attempt.scaled_score|percentage}})
60-
{% else %}
61-
{% if attempt.completed %}
62-
{% translate "Completed" %}
63-
{% else %}
64-
<em>{% translate "In progress" %}</em>
65-
{% endif %}
6662
{% endif %}
6763
{% if attempt.is_remarked %}
6864
<br>

numbas_lti/views/attempt.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,16 @@ class ReopenAttemptView(MustBeInstructorMixin,generic.detail.DetailView):
9999

100100
def get(self, request, *args, **kwargs):
101101
attempt = self.get_object()
102-
e = ScormElement.objects.create(
103-
attempt=attempt,
104-
key='cmi.completion_status',
105-
value='incomplete',
106-
time=timezone.now(),
107-
counter=1
108-
)
109-
messages.add_message(self.request,messages.SUCCESS,_('{}\'s attempt has been reopened.'.format(attempt.user.get_full_name())))
110-
return redirect(self.reverse_with_lti('manage_attempts',args=(attempt.resource.pk,)))
102+
103+
attempt.reopen(reopened_by=self.request.user)
104+
105+
if self.request.user != attempt.user:
106+
messages.add_message(self.request,messages.SUCCESS,_('{}\'s attempt has been reopened.'.format(attempt.user.get_full_name())))
107+
next_url = self.reverse_with_lti('manage_attempts',args=(attempt.resource.pk,))
108+
else:
109+
next_url = self.reverse_with_lti('show_attempts')
110+
111+
return redirect(next_url)
111112

112113
class AttemptSCORMListing(MustHaveExamMixin,MustBeInstructorMixin,ResourceManagementViewMixin,generic.detail.DetailView):
113114
model = Attempt

0 commit comments

Comments
 (0)