Merge pull request #11767 from edx/ibrahimahmed443/SOL-1691

return course end date in credit service and rename flag
This commit is contained in:
Douglas Hall
2016-03-10 05:52:06 -05:00
2 changed files with 5 additions and 3 deletions

View File

@@ -48,7 +48,7 @@ class CreditService(object):
return is_credit_course(course_key)
def get_credit_state(self, user_id, course_key_or_id, return_course_name=False):
def get_credit_state(self, user_id, course_key_or_id, return_course_info=False):
"""
Return all information about the user's credit state inside of a given
course.
@@ -66,6 +66,7 @@ class CreditService(object):
'is_credit_course': if the course has been marked as a credit bearing course
'credit_requirement_status': the user's status in fulfilling those requirements
'course_name': optional display name of the course
'course_end_date': optional end date of the course
}
"""
@@ -99,10 +100,11 @@ class CreditService(object):
'credit_requirement_status': get_credit_requirement_status(course_key, user.username)
}
if return_course_name:
if return_course_info:
course = modulestore().get_course(course_key, depth=0)
result.update({
'course_name': course.display_name,
'course_end_date': course.end,
})
return result

View File

@@ -253,7 +253,7 @@ class CreditServiceTests(ModuleStoreTestCase):
self.assertNotIn('course_name', credit_state)
# now make sure it is in there when we pass in the flag
credit_state = self.service.get_credit_state(self.user.id, self.course.id, return_course_name=True)
credit_state = self.service.get_credit_state(self.user.id, self.course.id, return_course_info=True)
self.assertIn('course_name', credit_state)
self.assertEqual(credit_state['course_name'], self.course.display_name)