-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add progress meter #19
base: main
Are you sure you want to change the base?
Add progress meter #19
Conversation
…aught into progress-meter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good (and I see you caught a couple of my mistakes!). Unfortunately the "done" logic is currently all on the client side (I am trying to rework the back end to change that) so for the moment it will have to stay on the classes page only.
I would appreciate it if you could switch the CSS to Tailwind (and if you're not comfortable with that, you need to move the existing CSS to tailwind.css as index.css is auto-generated by Tailwind and your changes would be removed on the next compile) and make the colors a bit more muted + consistent with the current site design (the progress bar shouldn't distract from the class cards).
Absolutely! |
This reverts commit a872265.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fantastic! There's just a couple of other issues:
-
it needs to be hidden when the user isn't logged in.
-
Can you add a bar for the homework page as well? I think it should be pretty trivial since you've got most of the code written already.
-
I'd like the progress text (x/54) in the center of the bar and have the text color based on the background color (white text on the pink background, dark blue text on the light blue background). An example (and solution) here: https://stackoverflow.com/questions/21909494/how-to-create-a-progressbar-with-inverted-text-color-for-progressed-part
I believe it just requires having two copies of the text and updating the clip-path on the
upper one dynamically, but if it turns out to be too much trouble, don't worry about it.
…value (...) - This allows for use of progress bar anywhere on the app. - The server will render the current completed lessonProgress count as inner meter's initial text.
- Pass in completed count to progress bar mixin
- Pass in completed and total lesson counts to progress bar mixin
Got it!
This turned out to be non-trivial as the client-side logic wasn't applicable to the dashboard page since the dashboard doesn't have all the lessons rendered. I went ahead and converted the logic to get the initial lesson and completed lesson counts server-side and pass those along to the templates. It's now working! Take a look.
This one is a bit tricky. We could turn this into an issue / todo and someone could knock it out later! It should be possible, but it might take further adjusting of the progressBar mixin structure and how the text values are handled client-side on the allLessons page by the js, as currently they're innerText of the meter divs themselves. |
@@ -23,7 +23,13 @@ export const dashboard = async (req, res) => { | |||
currentLesson = await Lesson.findById(req.user.currentClass); | |||
currentLesson = await getLessonProgress(req.user.id, currentLesson); | |||
} | |||
res.render("dashboard", { lesson: currentLesson }); | |||
|
|||
const totalCount = await LessonProgress.countDocuments(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For totalCount, if traffic to your site ever starts really picking up, it may then be best to do this query only once on server startup, and keep its value cached in memory for subsequent requests for all users as it's unlikely the total lessons will change often (if ever). For now though this works for simplicity's sake.
I actually wasn't talking about the dashboard page, I was talking about the homework page (https://communitytaught.org/hw/all). As a side note, the dashboard progress bar is not currently working - it's just a missing include of the JS file, though. While there is a case to be made that the progress bar should increment as soon as classes are watched, it does have a couple of issues:
Unfortunately, some classes require both watching and checking in, and some require just watching. Classes that don't require checking in are marked "checkedin: false" by default, meaning you would have to add more complex logic to keep the front and back end information consistent. Additionally, a similar strategy will not work for homework tracking, which is much more complicated. There are three solutions I can see:
Understood, I thought it might need to go to a separate issue. Please decide which of the two options you'd like to go with for the progress bar logic and submit a final PR. Everything really does look great, thank you so much for sticking with this. :) |
I've added a very basic progress meter to the All Classes page. At the moment, it's purely client-side with basic styling (to match Leon's stream background animation).
![image](https://user-images.githubusercontent.com/50963144/219514789-e46a0576-8f16-44a1-95cc-9d606f8a682f.png)
It works by counting the amount of lessons marked as completed on the page, as well as updating when a checkbox is ticked or unticked.
Since this is only client-side logic for now, we can't add this progress bar to the Dashboard view yet. However, this should be easily doable server-side if a query was retrieved for the amount of Lessons marked completed, served as the initial progress bar width value, and then the client-side js could keep the bar's visuals in sync between refreshes (if the user clicks some more boxes after).
Let me know what you think, and if any changes need to be made!
Some TODOs are to make for a smooth animation for the bar to fill up on page load, and to smoothly adjust as checkboxes are clicked.
(Also, if you later end up rebuilding this app in React, I can rebuild the progress bar in React as well where all of this is quite a bit simpler)