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: Accordion state #1544

Merged
merged 5 commits into from
Dec 6, 2023

Conversation

SLimbu30
Copy link
Collaborator

@SLimbu30 SLimbu30 commented Nov 28, 2023

Description

  • Changes in the accordion state when being clicked.
  • Tracks the accordion state according to the level and episode.

How Has This Been Tested?

Locally in my computer

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have linked this PR to a ZenHub Issue.

This change is Reviewable

@SLimbu30 SLimbu30 changed the title Changes in accordion state Fix: Accordion state Nov 28, 2023
@SLimbu30 SLimbu30 changed the title Fix: Accordion state fix: Accordion state Nov 28, 2023
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Merging #1544 (804ed12) into master (e412665) will not change coverage.
The diff coverage is n/a.

❗ Current head 804ed12 differs from pull request most recent head 8223e44. Consider uploading reports for the commit 8223e44 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1544   +/-   ##
=======================================
  Coverage   91.79%   91.79%           
=======================================
  Files         110      110           
  Lines        5860     5860           
=======================================
  Hits         5379     5379           
  Misses        481      481           

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @karatmate)


game/static/game/js/game.js line 24 at r2 (raw file):

document.addEventListener("DOMContentLoaded", function() {
  var dataElement = document.getElementById('data');

var is an old way of declaring variables in Js - instead, you can use let and const. Please use:

  • let when the variable needs to be changed later on in the code.
  • const when declaring a constant which only needs to be read / queried and not changed.

Please perform this change throughout the code you've added.


game/static/game/js/game.js line 26 at r2 (raw file):

  var dataElement = document.getElementById('data');
  var currentEpisode = dataElement ? dataElement.getAttribute('data-episode') : null;
  

You've got some extra whitespaces here - please remove them 🙂


game/static/game/js/game.js line 36 at r2 (raw file):

  var currentLevelId = LEVEL_ID; 
  var currentEpisode = this.determineEpisodeFromLevel(currentLevelId);
  localStorage.setItem('currentEpisode', currentEpisode);  

Here you are getting the level ID, then determining the episode based on the level ID.
LEVEL_ID comes from game.html.
You'll notice that game.html also has a var called EPISODE - maybe you can get the ID directly from that instead of getting the LEVEL ID, and that way you might not even need the determineEpisodeFromLevel function anymore.

Code quote:

  var currentLevelId = LEVEL_ID;
  var currentEpisode = this.determineEpisodeFromLevel(currentLevelId);
  localStorage.setItem('currentEpisode', currentEpisode);

game/templates/game/game.html line 92 at r2 (raw file):

  });
  
</script>

Please double-check whether you need this, it seems you're already doing that in game.js anyway, right?

Code quote:

<script>
  document.addEventListener("DOMContentLoaded", function(){
      var dataElement = document.getElementById('data');
      var currentEpisode = dataElement ? dataElement.getAttribute('data-episode') : null;

      if (currentEpisode) {
          localStorage.setItem('currentEpisode', currentEpisode);
      }
  });

</script>

game/templates/game/level_selection.html line 44 at r2 (raw file):

</script>

<script>

Since level_selection.js is imported in the line directly after this script, could you try moving this JS code to level_selection.js and see if it still works? In general, when following this kind of software architecture, it's better to keep JS code in JS files instead of HTML files.

Copy link
Collaborator Author

@SLimbu30 SLimbu30 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 5 unresolved discussions (waiting on @faucomte97)


game/static/game/js/game.js line 24 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

var is an old way of declaring variables in Js - instead, you can use let and const. Please use:

  • let when the variable needs to be changed later on in the code.
  • const when declaring a constant which only needs to be read / queried and not changed.

Please perform this change throughout the code you've added.

Done.


game/static/game/js/game.js line 26 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

You've got some extra whitespaces here - please remove them 🙂

Done.


game/static/game/js/game.js line 36 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Here you are getting the level ID, then determining the episode based on the level ID.
LEVEL_ID comes from game.html.
You'll notice that game.html also has a var called EPISODE - maybe you can get the ID directly from that instead of getting the LEVEL ID, and that way you might not even need the determineEpisodeFromLevel function anymore.

Done.


game/templates/game/game.html line 92 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Please double-check whether you need this, it seems you're already doing that in game.js anyway, right?

Done.


game/templates/game/level_selection.html line 44 at r2 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Since level_selection.js is imported in the line directly after this script, could you try moving this JS code to level_selection.js and see if it still works? In general, when following this kind of software architecture, it's better to keep JS code in JS files instead of HTML files.

Done.

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 4 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @karatmate)

@faucomte97 faucomte97 merged commit 9d35423 into ocadotechnology:master Dec 6, 2023
4 of 6 checks passed
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.

2 participants