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

feat: Add exercises tags #326

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

feat: Add exercises tags #326

wants to merge 7 commits into from

Conversation

orronai
Copy link
Collaborator

@orronai orronai commented Oct 5, 2021

  • Added tags per course
  • Added for the exercises.html template the tags
  • Added the tables of the tags
  • Added a test

- Added tags per course
- Added for the exercises.html template the tags
- Added the tables of the tags
- Added a test
@orronai orronai linked an issue Oct 5, 2021 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #326 (07c743c) into master (f3ed156) will increase coverage by 0.28%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #326      +/-   ##
==========================================
+ Coverage   84.08%   84.36%   +0.28%     
==========================================
  Files          63       64       +1     
  Lines        2903     2955      +52     
==========================================
+ Hits         2441     2493      +52     
  Misses        462      462              
Impacted Files Coverage Δ
lms/lmsdb/models.py 91.66% <100.00%> (+0.39%) ⬆️
lms/lmsweb/views.py 93.19% <100.00%> (+0.19%) ⬆️
lms/models/solutions.py 98.97% <100.00%> (+0.03%) ⬆️
lms/models/tags.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3ed156...07c743c. Read the comment docs.

lms/templates/exercises.html Outdated Show resolved Hide resolved
lms/templates/exercises.html Outdated Show resolved Hide resolved
lms/models/solutions.py Outdated Show resolved Hide resolved
tests/test_exercises.py Show resolved Hide resolved
lms/lmsdb/models.py Outdated Show resolved Hide resolved
lms/lmsdb/models.py Outdated Show resolved Hide resolved
lms/lmsdb/models.py Outdated Show resolved Hide resolved
lms/lmsdb/models.py Show resolved Hide resolved
lms/lmsweb/views.py Outdated Show resolved Hide resolved
lms/lmsdb/models.py Show resolved Hide resolved
- Added a bridge of tags in models folder
- Added course and date_created column to the tags table
- Added a constraint to the tags table
lms/lmsdb/models.py Outdated Show resolved Hide resolved
@classmethod
def get_objects(
cls, user_id: int, fetch_archived: bool = False,
from_all_courses: bool = False, exercise_tag: Optional[str] = None,
Copy link
Member

Choose a reason for hiding this comment

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

We should find a better way. Creating these godlike functions with trillion parameters is a bad habit. Can you please find another way to do it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't really find a better way

@@ -561,11 +615,11 @@ def test_results(self) -> Iterable[dict]:
@classmethod
def of_user(
cls, user_id: int, with_archived: bool = False,
from_all_courses: bool = False,
from_all_courses: bool = False, exercise_tag: Optional[str] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Same - we should try not to write such godlike functions

lms/lmsweb/views.py Outdated Show resolved Hide resolved
lms/models/solutions.py Outdated Show resolved Hide resolved
lms/models/tags.py Outdated Show resolved Hide resolved
lms/models/tags.py Outdated Show resolved Hide resolved
lms/models/tags.py Outdated Show resolved Hide resolved
lms/templates/exercises.html Show resolved Hide resolved
- Splitted a function into 3 functions
- Changed some functions names
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 8, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.07%.

Quality metrics Before After Change
Complexity 2.05 ⭐ 1.95 ⭐ -0.10 👍
Method Length 35.66 ⭐ 36.04 ⭐ 0.38 👎
Working memory 6.73 🙂 6.73 🙂 0.00
Quality 80.72% 80.65% -0.07% 👎
Other metrics Before After Change
Lines 2035 2137 102
Changed files Quality Before Quality After Quality Change
lms/lmsdb/models.py 84.22% ⭐ 84.45% ⭐ 0.23% 👍
lms/lmsweb/views.py 74.68% 🙂 74.84% 🙂 0.16% 👍
lms/models/solutions.py 74.06% 🙂 74.41% 🙂 0.35% 👍
tests/conftest.py 90.98% ⭐ 90.89% ⭐ -0.09% 👎
tests/test_exercises.py 70.00% 🙂 71.34% 🙂 1.34% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
lms/lmsweb/views.py comment 13 🙂 202 😞 8 🙂 50.15% 🙂 Try splitting into smaller methods
lms/models/solutions.py get_view_parameters 5 ⭐ 139 😞 12 😞 55.53% 🙂 Try splitting into smaller methods. Extract out complex expressions
lms/lmsweb/views.py view 8 ⭐ 140 😞 10 😞 56.16% 🙂 Try splitting into smaller methods. Extract out complex expressions
lms/lmsweb/views.py login 5 ⭐ 129 😞 12 😞 56.69% 🙂 Try splitting into smaller methods. Extract out complex expressions
lms/lmsdb/models.py Solution._base_next_unchecked 0 ⭐ 95 🙂 20 ⛔ 57.42% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@@ -357,6 +357,31 @@ def exercises_page():
)


@webapp.route('/exercises/<tagname>')
Copy link
Member

Choose a reason for hiding this comment

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

Maybe /exercises/tag/<tagname>? Or /tags/exercise/_ in case we'll want to tag other things in the future (users, maybe?)

@@ -375,6 +375,27 @@ def on_notification_saved(
instance.delete_instance()


class Tag(BaseModel):
Copy link
Member

Choose a reason for hiding this comment

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

I now think about changing this tablename to ExerciseTag, and the connection to ExerciseToTag, in order to allow easy future expansion of the tags to user. IDK what the right approach to a state where we have both Users and Exercises that use tags, but I have a strong hunch that they shouldn't share the same table.

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.

Tag Exercise
2 participants