Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix self paced course content visiblity #11452

Merged
merged 5 commits into from
Feb 17, 2016

Conversation

mushtaqak
Copy link
Contributor

ECOM-3615

Fix self-paced course displaying "published, not yet released" issue

@mushtaqak mushtaqak changed the title [WIP] Fix self paced course content visiblity Fix self paced course content visiblity Feb 10, 2016
@mushtaqak mushtaqak force-pushed the mushtaq/ECOM-3615-fix-self-paced-scheduled-content branch from 1f97e09 to e474196 Compare February 11, 2016 11:50
@mushtaqak mushtaqak force-pushed the mushtaq/ECOM-3615-fix-self-paced-scheduled-content branch from e474196 to f9c3759 Compare February 11, 2016 13:06
@mushtaqak
Copy link
Contributor Author

@adampalay @awaisdar001 May you please review

if course:
try:
return course.self_paced and SelfPacedConfiguration.current().enabled
except AttributeError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to handle the case where no SelfPacedConfiguration is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not Actually. SelfPacedConfiguration inherits ConfigurationModel which has current() method that creates a dict and returns it. So if it is not set, it returns enabled=False in the dict when we call SelfPacedConfiguration.current()

"""
Returns True if course is self-paced, False otherwise.
"""
return course.self_paced and SelfPacedConfiguration.current().enabled if course else False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this is cleaner:
return course and course.self_paced and SelfPacedConfiguration.current().enabled

BTW, what happens if there is no entry in SelfPacedConfiguration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no entry in SelfPacedConfiguration it would return false.


with self.store.default_store(store_type):
# Create course, chapter and setup future release date to make chapter in scheduled state
course = CourseFactory.create()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's cleaner to pass store_type to the default_store kwarg in the create method

@adampalay
Copy link
Contributor

some nits, o/w 👍


# Check that has scheduled state
xblock_info = self._get_xblock_info(chapter.location)
self._verify_visibility_state(xblock_info, VisibilityState.ready)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak xblock_info will also be in live state? Is it worth checking that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awaisdar001 xblock_info will only have one state at a time. So it would either have ready state or live visibility state. So it would be redundant to check for live state if we already have checked for ready state.

is_live = datetime.now(UTC) > xblock.start
children = child_info and child_info.get('children', [])
if children and len(children) > 0:
is_live = is_course_self_paced or datetime.now(UTC) > xblock.start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion, Instead of passing is_course_self_paced in the method argument would require the param to pass everywhere the method will be used.

How about something like this?
is_live = is_self_paced(course) or datetime.now(UTC) > xblock.start

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, but I didn't wanted to pass whole course object which was unnecessary, so I passed only what is required in _compute_visibility_state method.

However, I should make is_course_self_paced param to be false by default.

@mushtaqak
Copy link
Contributor Author

@adampalay @awaisdar001 comments addressed.

"""
Returns True if course is self-paced, False otherwise.
"""
return course and course.self_paced and SelfPacedConfiguration.current().enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if there is any table in mysql where this mapping is added? I mean where we add information about course if it is self paced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked but there is no such SelfPaced to Course mapping table in MySQL.

@awaisdar001
Copy link
Contributor

👍

mushtaqak pushed a commit that referenced this pull request Feb 17, 2016
…cheduled-content

Fix self paced course content visiblity
@mushtaqak mushtaqak merged commit b94204a into master Feb 17, 2016
@mushtaqak mushtaqak deleted the mushtaq/ECOM-3615-fix-self-paced-scheduled-content branch March 16, 2016 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants