Add mentor stats test
This commit is contained in:
parent
373703813c
commit
9721464161
|
|
@ -0,0 +1,77 @@
|
||||||
|
from graphene_django.utils import GraphQLTestCase
|
||||||
|
|
||||||
|
from vbv_lernwelt.assignment.models import (
|
||||||
|
AssignmentCompletion,
|
||||||
|
AssignmentCompletionStatus,
|
||||||
|
)
|
||||||
|
from vbv_lernwelt.course.creators.test_utils import add_course_session_user, create_user
|
||||||
|
from vbv_lernwelt.course.models import CourseSessionUser
|
||||||
|
from vbv_lernwelt.dashboard.tests.test_views import BaseMentorAssignmentTestCase
|
||||||
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
|
|
||||||
|
|
||||||
|
class MentorStatisticsTestCase(BaseMentorAssignmentTestCase, GraphQLTestCase):
|
||||||
|
GRAPHQL_URL = "/server/graphql/"
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.course.configuration.is_vv = True
|
||||||
|
self.course.configuration.save()
|
||||||
|
|
||||||
|
self.mentor = create_user("mentor")
|
||||||
|
self.lm = LearningMentor.objects.create(
|
||||||
|
mentor=self.mentor, course_session=self.course_session
|
||||||
|
)
|
||||||
|
self.participants = [create_user(f"participant{i}") for i in range(4)]
|
||||||
|
|
||||||
|
def test_assignment_statistics(self):
|
||||||
|
# WHEN
|
||||||
|
has_lb = [True, True, True, False]
|
||||||
|
has_passed = [True, False, True, False]
|
||||||
|
for i in range(4):
|
||||||
|
csu = add_course_session_user(
|
||||||
|
self.course_session,
|
||||||
|
self.participants[i],
|
||||||
|
role=CourseSessionUser.Role.MEMBER,
|
||||||
|
)
|
||||||
|
if has_lb[i]:
|
||||||
|
self.lm.participants.add(csu)
|
||||||
|
|
||||||
|
AssignmentCompletion.objects.create(
|
||||||
|
course_session=self.course_session,
|
||||||
|
assignment_user=self.participants[i],
|
||||||
|
evaluation_user=self.mentor if has_lb[i] else None,
|
||||||
|
assignment=self.assignment,
|
||||||
|
completion_status=AssignmentCompletionStatus.EVALUATION_SUBMITTED.value,
|
||||||
|
evaluation_passed=has_passed[i],
|
||||||
|
)
|
||||||
|
# THEN
|
||||||
|
# WHEN
|
||||||
|
query = f"""query ($courseId: ID!) {{
|
||||||
|
mentor_course_statistics(course_id: $courseId) {{
|
||||||
|
course_session_selection_ids
|
||||||
|
user_selection_ids
|
||||||
|
assignments {{
|
||||||
|
_id
|
||||||
|
summary {{
|
||||||
|
_id
|
||||||
|
completed_count
|
||||||
|
average_passed
|
||||||
|
total_passed
|
||||||
|
total_failed
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}"""
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
variables = {"courseId": str(self.course.id)}
|
||||||
|
self.client.force_login(self.mentor)
|
||||||
|
response = self.query(query, variables=variables)
|
||||||
|
self.assertResponseNoErrors(response)
|
||||||
|
|
||||||
|
metrics = response.json()["data"]["mentor_course_statistics"]["assignments"][
|
||||||
|
"summary"
|
||||||
|
]
|
||||||
|
self.assertEqual(metrics["total_passed"], 2)
|
||||||
|
self.assertEqual(metrics["total_failed"], 1)
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from vbv_lernwelt.assignment.models import (
|
from vbv_lernwelt.assignment.models import (
|
||||||
|
Assignment,
|
||||||
AssignmentCompletion,
|
AssignmentCompletion,
|
||||||
AssignmentCompletionStatus,
|
AssignmentCompletionStatus,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.assignment.tests.assignment_factories import AssignmentFactory
|
from vbv_lernwelt.core.create_default_users import create_default_users
|
||||||
|
from vbv_lernwelt.course.creators.test_course import create_test_course
|
||||||
from vbv_lernwelt.course.creators.test_utils import (
|
from vbv_lernwelt.course.creators.test_utils import (
|
||||||
add_course_session_group_supervisor,
|
add_course_session_group_supervisor,
|
||||||
add_course_session_user,
|
add_course_session_user,
|
||||||
|
|
@ -13,7 +15,7 @@ from vbv_lernwelt.course.creators.test_utils import (
|
||||||
create_course_session_group,
|
create_course_session_group,
|
||||||
create_user,
|
create_user,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.course.models import CourseCategory, CoursePage, CourseSessionUser
|
from vbv_lernwelt.course.models import Course, CourseSession, CourseSessionUser
|
||||||
from vbv_lernwelt.dashboard.views import (
|
from vbv_lernwelt.dashboard.views import (
|
||||||
_get_mentee_count,
|
_get_mentee_count,
|
||||||
_get_mentor_open_tasks_count,
|
_get_mentor_open_tasks_count,
|
||||||
|
|
@ -21,12 +23,7 @@ from vbv_lernwelt.dashboard.views import (
|
||||||
get_course_sessions_with_roles_for_user,
|
get_course_sessions_with_roles_for_user,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
from vbv_lernwelt.learnpath.models import LearningUnit
|
||||||
CircleFactory,
|
|
||||||
LearningPathFactory,
|
|
||||||
LearningSequenceFactory,
|
|
||||||
LearningUnitFactory,
|
|
||||||
)
|
|
||||||
from vbv_lernwelt.self_evaluation_feedback.models import SelfEvaluationFeedback
|
from vbv_lernwelt.self_evaluation_feedback.models import SelfEvaluationFeedback
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -245,6 +242,7 @@ class GetMenteeCountTestCase(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_mentee_count(self):
|
def test_get_mentee_count(self):
|
||||||
|
# GIVEN
|
||||||
participants_with_mentor = [create_user(f"participant{i}") for i in range(2)]
|
participants_with_mentor = [create_user(f"participant{i}") for i in range(2)]
|
||||||
participant = create_user("participant")
|
participant = create_user("participant")
|
||||||
mentor = create_user("mentor")
|
mentor = create_user("mentor")
|
||||||
|
|
@ -252,6 +250,7 @@ class GetMenteeCountTestCase(TestCase):
|
||||||
mentor=mentor, course_session=self.course_session
|
mentor=mentor, course_session=self.course_session
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# WHEN
|
||||||
for p in participants_with_mentor:
|
for p in participants_with_mentor:
|
||||||
csu = add_course_session_user(
|
csu = add_course_session_user(
|
||||||
self.course_session,
|
self.course_session,
|
||||||
|
|
@ -266,42 +265,27 @@ class GetMenteeCountTestCase(TestCase):
|
||||||
role=CourseSessionUser.Role.MEMBER,
|
role=CourseSessionUser.Role.MEMBER,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# THEN
|
||||||
count = _get_mentee_count(str(self.course.id), mentor)
|
count = _get_mentee_count(str(self.course.id), mentor)
|
||||||
self.assertEqual(count, 2)
|
self.assertEqual(count, 2)
|
||||||
|
|
||||||
|
|
||||||
class GetMentorOpenTasksTestCase(TestCase):
|
class BaseMentorAssignmentTestCase(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.course, _ = create_course("Test Course")
|
create_default_users()
|
||||||
self.course_session = create_course_session(
|
create_test_course(include_vv=False, with_sessions=True)
|
||||||
course=self.course, title="Test Session"
|
self.course = Course.objects.first()
|
||||||
)
|
self.course_session = CourseSession.objects.first()
|
||||||
course_page = CoursePage.objects.get(course_id=self.course.id)
|
self.lu = LearningUnit.objects.first()
|
||||||
CourseCategory.objects.get_or_create(
|
self.assignment = Assignment.objects.first()
|
||||||
course=self.course, title="Allgemein", general=True
|
|
||||||
)
|
|
||||||
lp = LearningPathFactory(
|
|
||||||
title="Lernpfad",
|
|
||||||
parent=course_page,
|
|
||||||
)
|
|
||||||
circle = CircleFactory(
|
|
||||||
title="Kickoff",
|
|
||||||
parent=lp,
|
|
||||||
description="bla".strip(),
|
|
||||||
goals="A goal",
|
|
||||||
)
|
|
||||||
LearningSequenceFactory(
|
|
||||||
title="Vorbereitung", parent=circle, icon="it-icon-ls-start"
|
|
||||||
)
|
|
||||||
self.lu = LearningUnitFactory(
|
|
||||||
title="Vorbereitung", title_hidden=True, parent=circle
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
class GetMentorOpenTasksTestCase(BaseMentorAssignmentTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
self.course.configuration.is_vv = True
|
self.course.configuration.is_vv = True
|
||||||
self.course.configuration.save()
|
self.course.configuration.save()
|
||||||
|
|
||||||
self.assignment = AssignmentFactory(parent=course_page)
|
|
||||||
|
|
||||||
self.mentor = create_user("mentor")
|
self.mentor = create_user("mentor")
|
||||||
self.lm = LearningMentor.objects.create(
|
self.lm = LearningMentor.objects.create(
|
||||||
mentor=self.mentor, course_session=self.course_session
|
mentor=self.mentor, course_session=self.course_session
|
||||||
|
|
@ -329,6 +313,7 @@ class GetMentorOpenTasksTestCase(TestCase):
|
||||||
self.assertEqual(count, 0)
|
self.assertEqual(count, 0)
|
||||||
|
|
||||||
def test_get_vv_count_when_assignment_evaluated(self):
|
def test_get_vv_count_when_assignment_evaluated(self):
|
||||||
|
# GIVEN
|
||||||
csu = add_course_session_user(
|
csu = add_course_session_user(
|
||||||
self.course_session,
|
self.course_session,
|
||||||
self.participants[0],
|
self.participants[0],
|
||||||
|
|
@ -425,7 +410,7 @@ class GetMentorOpenTasksTestCase(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_vv_count_without_lm(self):
|
def test_get_vv_count_without_lm(self):
|
||||||
csu = add_course_session_user(
|
add_course_session_user(
|
||||||
self.course_session,
|
self.course_session,
|
||||||
self.participants[0],
|
self.participants[0],
|
||||||
role=CourseSessionUser.Role.MEMBER,
|
role=CourseSessionUser.Role.MEMBER,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue