kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Update score on content card for practice quizzes

Open sairina opened this issue 3 years ago • 21 comments

Observed behavior

The content cards currently do not have the ability to show the score. We will need to connect to the backend to pull information for the most recent score for a practice quiz from the learner to populate on the cards.

Expected behavior

See the Figma here for the practice quiz cards.

Screen Shot 2021-11-09 at 2 11 46 PM

User-facing consequences

Currently, users will see that a practice quiz has been completed, but will not have the ability to see their most recent score until they go into the learner report.

sairina avatar Nov 09 '21 22:11 sairina

Hi, I would like to contribute! Could you please point me in the direction of the code that deals with displaying the quiz cards.

qrossCS avatar Nov 14 '21 23:11 qrossCS

I would like to work on this issue.

akash5100 avatar Nov 15 '21 13:11 akash5100

There are two aspects to this issue - one is the frontend, which would require editing both the frontend state management for progress tracking (found here: https://github.com/learningequality/kolibri/blob/release-v0.15.x/kolibri/plugins/learn/assets/src/composables/useContentNodeProgress.js#L13), and the ProgressBar component that is used across multiple cards https://github.com/learningequality/kolibri/blob/release-v0.15.x/kolibri/plugins/learn/assets/src/views/ProgressBar.vue

On the backend, we would need to return a more complex response in the case of practice quizzes - at the moment the values returned are only content_id and progress, but this would require more information to be returned - i.e. number of attemptlogs for the most recent masterylog. The code for the current API endpoint is here: https://github.com/learningequality/kolibri/blob/release-v0.15.x/kolibri/core/content/api.py#L1268

For example code of how to retrieve the most recent MasteryLog, see here: https://github.com/learningequality/kolibri/pull/8634/files#diff-7b27ce42afb14b2ac585383ca91a1afca8b49bd9ea595d1923d740f6f547dfc8R457 (although this code is not currently PostgreSQL compatible).

rtibbles avatar Nov 15 '21 16:11 rtibbles

So for the backend process here, #8634 is prerequisite? I was thinking of starting with the backend and then linking it to cards from the frontend, was my idea right? how should I get the number of attempting from the most recent masterylog can you help me with it?

akash5100 avatar Nov 19 '21 10:11 akash5100

#8634 isn't a prerequisite - it was just an example of how to retrieve the the most recent MasteryLog, which would be required in order to calculate the score.

On a masterylog by masterylog basis, you can call masterylog.attemptlogs.all() on the object to get the related attemptlogs. However, if we want to implement this within the ContentNodeProgressViewset here: https://github.com/learningequality/kolibri/blob/release-v0.15.x/kolibri/core/content/api.py#L1267 it would be good to be able to generate a query that returns all of these values for you at once.

For an example of how to annotate a MasteryLog queryset with the number answered and the number correct, see here: https://github.com/learningequality/kolibri/blob/8463da925e9e0cf92288be510e3f18b089de8064/kolibri/plugins/coach/class_summary_api.py#L156

rtibbles avatar Nov 19 '21 13:11 rtibbles

@rtibbles I quite did not understand how should I start. here

logs = list(
            ContentSummaryLog.objects.filter(
                user=self.request.user,
                content_id__in=queryset.exclude(kind=content_kinds.TOPIC).values_list(
                    "content_id", flat=True
                ),
            ).values("content_id", "progress")

currently we only get content_id and progress. so, we also need to return a log for masterylog.attemptlogs.all() and get the number of attemptlogs.

we can do it by .annotate(attempts=Count("masterylogs__attemptlogs")) right? and if this is right we can do .values("content_id", "progress","attempts") so now we have attempts in logs.

Is this correct? guide me if I am going wrong. also sorry for being late.

akash5100 avatar Nov 22 '21 10:11 akash5100

logs = list(
            ContentSummaryLog.objects.filter(
                user=self.request.user,
                content_id__in=queryset.exclude(kind=content_kinds.TOPIC).values_list("content_id", flat=True))
            .annotate(attempts=Count("masterylogs__attemptlogs"))
            .values("content_id", "progress","attempts")
        )

akash5100 avatar Nov 22 '21 10:11 akash5100

@rtibbles can you check the above (backend) solution?

akash5100 avatar Dec 07 '21 07:12 akash5100

Hi @akash5100 - apologies, I missed your notification in the middle of the Thanksgiving holiday here.

This is nearly there, the main issue is that you would be counting all of the attempts for every MasteryLog - when what is desired is the total number of correct questions and the total number of questions in order to be able to compute a score.

Instead of just counting the total number of attemptlogs associated with the summary log, you would need to count the total number of attemptlogs, and the total number of correct attemptlogs for the most recent masterylog. You would also need to count the number of questions associated with the content node.

There is some code in my recent PR that nearly does this: https://github.com/learningequality/kolibri/pull/8807/commits/61a49bc8b9f6269c8986faa7488294a974ea2564#diff-1a4cafebd9967f427eaca030d47aa155aced82ec4397be23a3fdcaf0c3ec3f5cR46

The main additional thing you would need to do is to first annotate onto the ContentSummaryLog the most recent MasteryLog - this is best done by doing a reverse ordering on end_timestamp and then getting the first item. I do a similar subquery to annotate the previous masterylog here: https://github.com/learningequality/kolibri/pull/8807/commits/283e79d636a1546801dd1cf49a6245d58a78472b#diff-1a4cafebd9967f427eaca030d47aa155aced82ec4397be23a3fdcaf0c3ec3f5cR43

Once you have annotated the most recent masterylog for the content summary log, you can do a further annotation that counts the total number of attempt logs for that specific mastery log, the total number of correct attempt logs for that specific masterylog, and then you can find out the total number of questions for the ContentNode using 'assessmentmetadata__num_assessments'.

Between these three fields, you should then have what you need in the progress data to display the two states above (number of questions left if in progress, score if completed).

rtibbles avatar Dec 08 '21 00:12 rtibbles

I would like to be assigned to this issue.

laynestephens avatar Nov 08 '23 14:11 laynestephens

Hi @laynestephens, thanks! You're welcome to give this a try. There are many comments by @rtibbles with useful guidance - please have a look. Do not hesitate to ask any additional questions.

MisRob avatar Nov 10 '23 09:11 MisRob

Hi again! I am working with a partner on this issue, @adviti-mishra , and I was wondering if they could be assigned simultaneously.

laynestephens avatar Nov 22 '23 19:11 laynestephens

Hi @laynestephens, yes sure. We will need @adviti-mishra to comment on this issue so I can assign them.

MisRob avatar Nov 24 '23 09:11 MisRob

Hello @MisRob Thank you so much! I'm with @laynestephens and would love to be assigned as well.

adviti-mishra avatar Nov 25 '23 23:11 adviti-mishra

Hi @adviti-mishra and @laynestephens, since we haven't seen activity here for a long time, I will assign you, If you're still interested, you're welcome to messages us and we can assign again. Be well

MisRob avatar Feb 15 '24 12:02 MisRob

@MisRob I would like to work on this issue

Wck-iipi avatar Mar 29 '24 14:03 Wck-iipi

@Wck-iipi Thanks for volunteering for this issue, I'll assign it to you. Let us know if you have any questions :)

LianaHarris360 avatar Mar 29 '24 18:03 LianaHarris360

Hi @Wck-iipi, are you still planning to work on this or would it be better to unassign?

MisRob avatar May 11 '24 08:05 MisRob

@MisRob You can unassign this. I won't be able to find time to do this as current week is really busy.

Wck-iipi avatar May 12 '24 14:05 Wck-iipi

Hi, I am picking this up. You can assign me!

thesujai avatar Aug 12 '24 11:08 thesujai

Assigned!

rtibbles avatar Aug 12 '24 14:08 rtibbles