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 isNotStartedLevel #40555

Merged
merged 7 commits into from
May 18, 2021

Conversation

maureensturgeon
Copy link
Contributor

@maureensturgeon maureensturgeon commented May 12, 2021

The config value isNotStartedLevel was being set by assuming that every 'Gamelab', 'Applab', 'Weblab', 'Spritelab', 'Dance' was channel backed. The dance lab level /s/coursed-2020/lessons/7/levels/9 is not channel backed so a channel didn't exist for the level and therefore isNotStartedLevel was being set to true incorrectly. This resulted in the teacher seeing the level not started banner.

The changes in this PR rename isNotStartedLevel to displayNotStartedBanner to more accurately represent the return value of the function. It also changes how we determine if the level has been started by checking for a channel if a level is channel backed and checking for a user_level for any other level.

Before:
Screen Shot 2021-05-12 at 2 39 51 PM

After:
Screen Shot 2021-05-12 at 2 39 18 PM

Links

Testing story

Added a test for the new config value and tested locally.

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@maureensturgeon maureensturgeon requested a review from a team May 12, 2021 21:43
Copy link
Contributor

@jamescodeorg jamescodeorg left a comment

Choose a reason for hiding this comment

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

Oh, I've totally run into this bug while using the site with students, great that we're fixing!

@jamescodeorg
Copy link
Contributor

Side thought for the future: The logic for determining whether a level was started on the front-end seems overly complicated. Whether or not a level can be started seems like something we should be able to determine straightforwardly on the back-end and just tell the front-end.

@@ -107,6 +107,16 @@ def get_channel_for(level, user = nil)
channel_token&.channel
end

# If given a level and a user, returns whether any work has been done
# on the level
def level_started?(level, user)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be in user.rb or level.rb instead? Or somewhere else?

Copy link
Contributor

@jamescodeorg jamescodeorg left a comment

Choose a reason for hiding this comment

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

Generally looks great, a few follow-up questions to make sure I understand it fully.

Does this banner show up on non-app levels (e.g. free response or multiple choice)?

# If given a level and a user and optional script, returns whether the level
# has been started by the user
def level_started?(level, user, script = nil)
if level.channel_backed? # maureen make sure user is present or this will fail
Copy link
Contributor

Choose a reason for hiding this comment

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

So... have you made sure the user is present? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is why I leave notes for myself! Thanks for catching that, will update.

@@ -107,6 +107,16 @@ def get_channel_for(level, user = nil)
channel_token&.channel
end

# If given a level and a user and optional script, returns whether the level
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is script optional?

Could you elaborate a bit on what we define as having "started" a level?

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 made the script optional because in the app_options method where level_started? is being used, we're checking for the presence of script several times. Which leads me to believe there is a case where we're getting app options without a script.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, not sure how best to handle this. For querying progress, I think we need to have both (since levels can be used in multiple scripts).

(Also, there was a second question about what it means to "start" a level above.)

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 updated the comment with more information about what we mean by "started". Honestly, I was just following how the previous code defined "started", so I had to dig into when a channel and user level are created to answer this question. For channel-backed levels, a channel is created as soon as the user visits the level page, so that's when it's considered "started". For other levels the user_level is created when progress is first saved, so that's when it's considered "started".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the optional script, I could make it required to get level_started data and then wait to see if anyone reports an issue? For displaying this banner, I can't imagine a case where we'd want it outside of the context of a script.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the additional comment. I think this is fine for now but may be something we revisit in the future to see if we want to make it more consistent. (After reading your comment, I'm now kind of wondering why the logic is even different for channel-backed levels. I'm guessing it has something to do with when we want to show this banner for template levels but it might be worth chatting with Amanda about this at some point to make sure that the behavior is what we want.)

@maureensturgeon
Copy link
Contributor Author

Generally looks great, a few follow-up questions to make sure I understand it fully.

Does this banner show up on non-app levels (e.g. free response or multiple choice)?

No it will not show for non-app levels. The banner is only displayed in the CodeWorkspace component.

Copy link
Contributor

@jamescodeorg jamescodeorg left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@maureensturgeon maureensturgeon merged commit e20459a into staging May 18, 2021
@maureensturgeon maureensturgeon deleted the maureen/LP-1875-student-not-started-message branch May 18, 2021 20:14
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.

None yet

2 participants