Repository: learningequality/kolibri

Issue:
Toggle button not working properly with its props 
<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

## Observed behavior
<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->

There are toggle buttons to help the user to switch  between two different states but here in some parts, the toggle button is not working properly and it's not able to change its state 

Moreover, even its able to change its state but unable to display those changes in the frontend 


## Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:

01:10 info: something happened
01:12 error: something bad happened

-->
[Screencast from 02-05-23 06:15:09 PM IST.webm](https://user-images.githubusercontent.com/81693090/235673299-e3d75c21-fa6d-4f95-8bc5-75713e0fc29c.webm)


## Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

It should be able to toggle between visible to non-visible with the correct active display 

## User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->
Its quite difficult for the admin to identify whether it is visible to learners

## Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->
1. Navigate towards Coach 
2. Navigate towards your class
3. Click on any particular lesson 
4. Toggle the button visible to learners

## Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

…

Coach > Plan - Problems with calculating the Total size of lessons visible to learners
## Observed behavior
Observed while testing https://github.com/learningequality/kolibri/pull/10452 - the total size of lessons visible to learners is not calculated correctly after I add more than a single lesson at Coach > Plan. See the video for details.

## Expected behavior
The correct value for the total lesson size should be displayed

## Steps to reproduce the issue
1. Install the the following [Kolibri 0.16a12 build ](https://github.com/learningequality/kolibri/suites/12297334558/artifacts/651689066) 
2. Go to Coach > Plan > Lesson
3. Add a single lesson with resources and observe the total size
4. Add a second lesson and note that the total size value is displayed as 'NaN B'. Also the lesson size value in the table for the first lesson is no longer correct.

## Video

https://user-images.githubusercontent.com/79847249/232797414-b29e6ad9-fc78-47c5-9734-3c0d3ede00f9.mp4

## Usage Details
Ubuntu - Chrome, Firefox


Discussion:

@radinamatic 

Resolving patch:
diff --git a/kolibri/core/exams/api.py b/kolibri/core/exams/api.py
--- a/kolibri/core/exams/api.py
+++ b/kolibri/core/exams/api.py
@@ -137,7 +137,7 @@ def perform_update(self, serializer):
 
     @action(detail=False)
     def size(self, request, **kwargs):
-        exams = self.get_queryset()
+        exams = self.filter_queryset(self.get_queryset())
         exams_sizes_set = []
         for exam in exams:
             quiz_size = {}
diff --git a/kolibri/core/lessons/viewsets.py b/kolibri/core/lessons/viewsets.py
--- a/kolibri/core/lessons/viewsets.py
+++ b/kolibri/core/lessons/viewsets.py
@@ -46,7 +46,7 @@ def _map_lesson_classroom(item):
 class LessonViewset(ValuesViewset):
     serializer_class = LessonSerializer
     filter_backends = (KolibriAuthPermissionsFilter, DjangoFilterBackend)
-    filter_fields = ("collection",)
+    filter_fields = ("collection", "id")
     permission_classes = (LessonPermissions,)
     queryset = Lesson.objects.all().order_by("-date_created")
 
@@ -104,7 +104,7 @@ def annotate_queryset(self, queryset):
 
     @action(detail=False)
     def size(self, request, **kwargs):
-        lessons = self.get_queryset()
+        lessons = self.filter_queryset(self.get_queryset())
         lessons_set = []
         for lesson in lessons:
             lesson_size = {}


Test patch: