Skip to content

Commit

Permalink
use "completed" rather than "passed" for welcome
Browse files Browse the repository at this point in the history
  • Loading branch information
elichad committed Jul 25, 2023
1 parent 5ce498e commit f0ca9d6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
15 changes: 13 additions & 2 deletions amy/dashboard/tests/test_instructor_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,26 @@ def setUp(self):
self._setUpUsersAndLogin()
self.welcome = TrainingRequirement.objects.get(name="Welcome Session")
self.progress_url = reverse("training-progress")
self.SESSION_LINK_TEXT = "Register for a Welcome Session on"

def test_session_passed(self):
TrainingProgress.objects.create(trainee=self.admin, requirement=self.welcome)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Welcome Session passed")
self.assertContains(rv, "Welcome Session completed")
self.assertNotContains(rv, self.SESSION_LINK_TEXT)

def test_session_failed(self):
TrainingProgress.objects.create(
trainee=self.admin, requirement=self.welcome, state="f"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Welcome Session failed")
self.assertNotContains(rv, self.SESSION_LINK_TEXT)

def test_no_participation_in_a_session_yet(self):
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Welcome Session not completed yet")
self.assertContains(rv, self.SESSION_LINK_TEXT)


class TestDemoSessionStatus(TestBase):
Expand All @@ -281,13 +285,20 @@ def test_session_passed(self):
self.assertContains(rv, "Demo passed")
self.assertNotContains(rv, self.SESSION_LINK_TEXT)

def test_session_asked_to_repeat(self):
TrainingProgress.objects.create(
trainee=self.admin, requirement=self.demo, state="a"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Demo asked to repeat")
self.assertContains(rv, self.SESSION_LINK_TEXT)

def test_session_failed(self):
TrainingProgress.objects.create(
trainee=self.admin, requirement=self.demo, state="f"
)
rv = self.client.get(self.progress_url)
self.assertContains(rv, "Demo failed")
self.assertContains(rv, self.SESSION_LINK_TEXT)

def test_no_participation_in_a_session_yet(self):
rv = self.client.get(self.progress_url)
Expand Down
3 changes: 3 additions & 0 deletions amy/templates/dashboard/training_progress.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ <h2>Your progress towards becoming a Carpentries Instructor</h2>
<td>
{% if progress_demo %}
{% progress_trainee_view progress_demo %}
{% if progress_demo.state == "a" %}
<p>Register for a Demo Session on this Etherpad: <a href="https://pad.carpentries.org/teaching-demos">Teaching Demos</a>.</p>
{% endif %}
{% elif user.passed_demo %}
<p class="text-success">Demo Session passed.
</p>
Expand Down
15 changes: 13 additions & 2 deletions amy/workshops/templatetags/training_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,30 @@ def checkout_deadline(start_date):


@register.simple_tag
def progress_trainee_view(progress):
def progress_trainee_view(progress: TrainingProgress) -> str:
assert isinstance(progress, TrainingProgress)

# state: follow our internal choices
# except for Welcome Session
# as 'passed' implies assessment, but you just have to show up
state_display = progress.get_state_display().lower()
if state_display == "passed" and progress.requirement.name == "Welcome Session":
state_display = "completed"

# date: show event dates for training, most recent update date otherwise
date = progress.event.end if progress.event else progress.last_updated_at

# notes: show notes if state is failed or asked to repeat
notes = (
f"<p>Administrator comments: {progress.notes}</p>"
if progress.state in ["f", "a"]
else ""
)

# put it all together
text = (
f'<p class="text-{progress_state_class(progress.state)}"> '
f"{progress.requirement.name} {progress.get_state_display().lower()} "
f"{progress.requirement.name} {state_display} "
f'as of {date.strftime("%B %d, %Y")}.</p>{notes}'
)

Expand Down

0 comments on commit f0ca9d6

Please sign in to comment.