Skip to content

Commit

Permalink
fix: quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tecoholic committed Sep 14, 2023
1 parent bc64c2c commit abfed95
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
17 changes: 14 additions & 3 deletions integrated_channels/xapi/statements/learner_course_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tincan import LanguageMap, Result, Score, Verb

from integrated_channels.xapi.constants import MAX_SCORE, MIN_SCORE, OBJECT_ID_URI, X_API_VERB_COMPLETED
from integrated_channels.xapi.constants import MAX_SCORE, MIN_SCORE, X_API_VERB_COMPLETED
from integrated_channels.xapi.statements.base import EnterpriseStatement


Expand All @@ -13,7 +13,18 @@ class LearnerCourseCompletionStatement(EnterpriseStatement):
xAPI Statement to serialize data related to course completion.
"""

def __init__(self, site, user, user_social_auth, course_overview, course_grade, object_type, object_id_type=OBJECT_ID_URI, *args, **kwargs):
def __init__(
self,
site,
user,
user_social_auth,
course_overview,
course_grade,
object_type,
object_id_type,
*args,
**kwargs
):
"""
Initialize and populate statement with learner info and course info.
Expand All @@ -22,7 +33,7 @@ def __init__(self, site, user, user_social_auth, course_overview, course_grade,
user_social_auth (UserSocialAuth): UserSocialAuth object for learner
course_overview (CourseOverview): course overview object containing course details.
course_grade (CourseGrade): User grade in the course.
object_id_type (string): Either OBJECT_ID_PLAIN or OBJECT_ID_URI. Defaults to OBJECT_ID_URI.
object_id_type (string): Either OBJECT_ID_PLAIN or OBJECT_ID_URI.
"""
kwargs.update(
actor=self.get_actor(user, user_social_auth),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tincan import LanguageMap, Verb

from integrated_channels.xapi.constants import OBJECT_ID_URI, X_API_VERB_REGISTERED
from integrated_channels.xapi.constants import X_API_VERB_REGISTERED
from integrated_channels.xapi.statements.base import EnterpriseStatement


Expand All @@ -13,7 +13,7 @@ class LearnerCourseEnrollmentStatement(EnterpriseStatement):
xAPI statement to serialize data related to course registration.
"""

def __init__(self, site, user, user_social_auth, course_overview, object_type, object_id_type=OBJECT_ID_URI, *args, **kwargs):
def __init__(self, site, user, user_social_auth, course_overview, object_type, object_id_type, *args, **kwargs):
"""
Initialize and populate statement with learner info and course info.
Expand All @@ -22,7 +22,7 @@ def __init__(self, site, user, user_social_auth, course_overview, object_type, o
user_social_auth (UserSocialAuth): UserSocialAuth object of learner for the enterprise if learner has a
linked third party auth account
course_overview (CourseOverview): course overview object containing course details.
object_id_type (string): Either OBJECT_ID_PLAIN or OBJECT_ID_URI. Defaults to OBJECT_ID_URI.
object_id_type (string): Either OBJECT_ID_PLAIN or OBJECT_ID_URI.
"""
kwargs.update(
actor=self.get_actor(user, user_social_auth),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from faker import Factory as FakerFactory
from pytest import mark

from integrated_channels.xapi.constants import OBJECT_ID_PLAIN, X_API_ACTIVITY_COURSE, X_API_VERB_COMPLETED
from integrated_channels.xapi.constants import (
OBJECT_ID_PLAIN,
OBJECT_ID_URI,
X_API_ACTIVITY_COURSE,
X_API_VERB_COMPLETED,
)
from integrated_channels.xapi.statements.learner_course_completion import LearnerCourseCompletionStatement
from test_utils import factories

Expand Down Expand Up @@ -151,7 +156,8 @@ def test_statement_course(self):
self.mock_social_auth,
self.course_overview,
self.course_grade,
'course'
'course',
OBJECT_ID_URI,
)
self.assertDictEqual(json.loads(statement.to_json()), self.expected_course)

Expand All @@ -165,7 +171,8 @@ def test_statement_courserun(self):
self.mock_social_auth,
self.course_overview,
self.course_grade,
'courserun'
'courserun',
OBJECT_ID_URI,
)
self.assertDictEqual(json.loads(statement.to_json()), self.expected_courserun)

Expand All @@ -179,7 +186,8 @@ def test_statement_notpassed(self):
self.mock_social_auth,
self.course_overview,
self.course_grade_notpassed,
'course'
'course',
OBJECT_ID_URI,
)
self.assertDictEqual(json.loads(statement.to_json()), self.expected_notpassed)

Expand All @@ -193,8 +201,9 @@ def test_statement_with_different_course_id_formats(self):
self.mock_social_auth,
self.course_overview,
self.course_grade,
'course'
) # defaults to URI format
'course',
OBJECT_ID_URI,
)

self.assertEqual(json.loads(statement.to_json())["object"]["id"], self.object_id_course)

Expand All @@ -205,7 +214,7 @@ def test_statement_with_different_course_id_formats(self):
self.course_overview,
self.course_grade,
'course',
OBJECT_ID_PLAIN
OBJECT_ID_PLAIN,
)

self.assertEqual(json.loads(statement.to_json())["object"]["id"], self.plain_course_id)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from faker import Factory as FakerFactory
from pytest import mark

from integrated_channels.xapi.constants import OBJECT_ID_PLAIN, X_API_ACTIVITY_COURSE, X_API_VERB_REGISTERED
from integrated_channels.xapi.constants import (
OBJECT_ID_PLAIN,
OBJECT_ID_URI,
X_API_ACTIVITY_COURSE,
X_API_VERB_REGISTERED,
)
from integrated_channels.xapi.statements.learner_course_enrollment import LearnerCourseEnrollmentStatement
from test_utils import factories

Expand Down Expand Up @@ -124,6 +129,7 @@ def test_statement_course(self):
self.mock_social_auth,
self.course_overview,
'course',
OBJECT_ID_URI,
)
self.assertDictEqual(json.loads(statement.to_json()), self.expected_course)

Expand All @@ -137,6 +143,7 @@ def test_statement_courserun(self):
self.mock_social_auth,
self.course_overview,
'courserun',
OBJECT_ID_URI,
)
self.assertDictEqual(json.loads(statement.to_json()), self.expected_courserun)

Expand All @@ -149,8 +156,9 @@ def test_statement_with_different_course_id_formats(self):
self.user,
self.mock_social_auth,
self.course_overview,
'course'
) # defaults to URI format
'course',
OBJECT_ID_URI,
)

self.assertEqual(json.loads(statement.to_json())["object"]["id"], self.object_id_course)

Expand Down

0 comments on commit abfed95

Please sign in to comment.