Repository: learningequality/kolibri

Issue:
Automatic Syncing Updates: Resource size is displayed for content in Reports and Plan tabs
## Overview 

This issue is a full-stack issue that updates the Coach Plugin's Reports and Plan tabs to include information about resource size, both within the resource and in the main table. 

## Specifications 
### Figma 

Please see [complete figma spec](https://www.figma.com/file/MpCG7r5PULOCJsEvnTSti8/Android-Designs-2022?node-id=960%3A16822&t=yKUs0H8sJ8FrRN6r-0) for all relevant screens and details. Below is just one example
<img width="735" alt="Screen Shot 2022-11-21 at 10 50 33 AM" src="https://user-images.githubusercontent.com/17235236/203098767-e0620d5b-c765-4ff1-8e0a-d087ac09052e.png">


## Acceptance Criteria
- [ ]  Frontend is updated with resources sizes on both Lesson and Quiz tables, with a total, and by-resource in each row
- [ ] Each resource has a total size available when you navigate into the resource

### Out of Scope
➡️ Accessibility notes: 
* Accessibility remediations for the reports page will be handled in . However, please do not make anything worse 😄 

## References 
- [Notion project page](https://www.notion.so/learningequality/Remote-Content-Syncing-Automatic-syncing-d0a28f150b324d4da019790228117068)
- [Figma spec](https://www.figma.com/file/MpCG7r5PULOCJsEvnTSti8/Android-Designs-2022?node-id=194%3A2922&t=yKUs0H8sJ8FrRN6r-0)
- [Gherkin scenarios](https://www.notion.so/learningequality/Gherkin-scenarios-02096ac9925844f8902c818cab607d4b#45dcdae16db8450b98023b559724277f)


Discussion:

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
@@ -138,11 +138,13 @@ def perform_update(self, serializer):
     @action(detail=False)
     def size(self, request, **kwargs):
         exams = self.get_queryset()
-        exams_sizes_dict = {}
+        exams_sizes_set = []
         for exam in exams:
+            quiz_size = {}
             quiz_nodes = ContentNode.objects.filter(
                 id__in={source["exercise_id"] for source in exam.question_sources}
             )
-            exams_sizes_dict[exam.id] = total_file_size(quiz_nodes)
+            quiz_size[exam.id] = total_file_size(quiz_nodes)
+            exams_sizes_set.append(quiz_size)
 
-        return Response([exams_sizes_dict])
+        return Response(exams_sizes_set)
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
@@ -105,11 +105,13 @@ def annotate_queryset(self, queryset):
     @action(detail=False)
     def size(self, request, **kwargs):
         lessons = self.get_queryset()
-        lessons_sizes_dict = {}
+        lessons_set = []
         for lesson in lessons:
+            lesson_size = {}
             resource_nodes = ContentNode.objects.filter(
                 id__in=[r["contentnode_id"] for r in lesson.resources]
             )
-            lessons_sizes_dict[lesson.id] = total_file_size(resource_nodes)
+            lesson_size[lesson.id] = total_file_size(resource_nodes)
+            lessons_set.append(lesson_size)
 
-        return Response([lessons_sizes_dict])
+        return Response(lessons_set)


Test patch:
diff --git a/integration_testing/016-features/coach/plan/coach-make-lesson-visible.feature b/integration_testing/016-features/coach/plan/coach-make-lesson-visible.feature
--- a/integration_testing/016-features/coach/plan/coach-make-lesson-visible.feature
+++ b/integration_testing/016-features/coach/plan/coach-make-lesson-visible.feature
@@ -7,7 +7,7 @@ Feature: Coach makes lessons visible
       And I see the table of lessons which includes <lesson>
       And in the second browser or an incognito tab I am signed in as a learner on *Learn > Classes > '<class>'*
 
-  Scenario: Coach turns ON the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch in the column *Visible to learners* for the lesson <lesson> is in the OFF position (gray)
       When I click the switch for <lesson>
       Then I see the switch slide in the ON position (green)
@@ -15,7 +15,18 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I see the lesson '<lesson>'
 
-  Scenario: Coach turns OFF the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch in the column *Visible to learners* for the lesson <lesson> is in the OFF position (gray)
+      And there are learners using Learn-only Devices in this class
+      When I click the switch for <lesson>
+      Then I see the switch slide in the ON position (green)
+        And I see a modal open that says *Make lesson visible* and displays the total size in bytes of the current lesson
+      When I click *Continue*
+      Then I see a snackbar notification that says *Lesson is visible to learners*
+      When I reload the browser as a learner
+      Then I see the lesson '<lesson>'
+
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch in the column *Visible to learners* for the lesson <lesson> is in the ON position (green)
       When I click the switch for <lesson>
       Then I see the switch slide in the OFF position (gray)
@@ -23,12 +34,23 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I don't see the lesson '<lesson>'
 
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch in the column *Visible to learners* for the lesson <lesson> is in the ON position (green)
+      And there are learners using Learn-only Devices in this class
+      When I click the switch for <lesson>
+      Then I see the switch slide in the OFF position (gray)
+        And I see a modal open that says *Make lesson not visible*
+      When I click *Continue*
+      Then I see a snackbar notification that says *Lesson is visible to learners*
+      When I reload the browser as a learner
+      Then I don't see the lesson '<lesson>'
+
   Background:
     Given I am signed in to kolibri as coach user
       And I am on *Coach - '<class>' > Report > Lessons* page
       And I see the table of lessons which includes <lesson>
 
-  Scenario: Coach turns ON the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch in the column *Visible to learners* for the lesson <lesson> is in the OFF position (gray)
       When I click the switch for <lesson>
       Then I see the switch slide in the ON position (green)
@@ -36,7 +58,18 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I see the lesson '<lesson>'
 
-  Scenario: Coach turns OFF the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch in the column *Visible to learners* for the lesson <lesson> is in the OFF position (gray)
+      And there are learners using Learn-only Devices in this class
+    When I click the switch for <lesson>
+    Then I see the switch slide in the ON position (green)
+      And I see a modal open that says *Make lesson visible*
+    When I click *Continue*
+    Then I see a snackbar notification that says *Lesson is visible to learners*
+    When I reload the browser as a learner
+    Then I see the lesson '<lesson>'
+
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch in the column *Visible to learners* for the lesson <lesson> is in the ON position (green)
       When I click the switch for <lesson>
       Then I see the switch slide in the OFF position (gray)
@@ -44,11 +77,22 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I don't see the lesson '<lesson>'
 
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch in the column *Visible to learners* for the lesson <lesson> is in the ON position (green)
+      And there are learners using Learn-only Devices in this class
+    When I click the switch for <lesson>
+    Then I see the switch slide in the OFF position (gray)
+      And I see a modal open that says *Make lesson not visible*
+    When I click *Continue*
+    Then I see a snackbar notification that says *Lesson is not visible to learners*
+    When I reload the browser as a learner
+    Then I don't see the lesson '<lesson>'
+
   Background:
     Given I am signed in to Kolibri as a Coach user
       And I am on *Coach - '<class>' > Plan > Lessons > '<lesson>'* page
 
-  Scenario: Coach turns ON the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch *Visible to learners* is in the OFF position (gray)
       When I click the switch for <lesson>
       Then I see the switch slide in the ON position (green)
@@ -56,7 +100,19 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I see the lesson '<lesson>'
 
-  Scenario: Coach turns OFF the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch *Visible to learners* is in the OFF position (gray)
+      And there are learners using Learn-only Devices in this class
+    When I click the switch for <lesson>
+    Then I see the switch slide in the ON position (green)
+      And I see a modal open that says *Make lesson visible*
+    When I click *Continue*
+    Then I see a snackbar notification that says *Lesson is visible to learners*
+    When I reload the browser as a learner
+    Then I see the lesson '<lesson>'
+
+
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch *Visible to learners* is in the ON position (green)
       When I click the switch for <lesson>
       Then I see the switch slide in the OFF position (gray)
@@ -64,11 +120,22 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I don't see the lesson '<lesson>'
 
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch *Visible to learners* is in the ON position (green)
+      And there are learners using Learn-only Devices in this class
+    When I click the switch for <lesson>
+    Then I see the switch slide in the OFF position (gray)
+      And I see a modal open that says *Make lesson not visible*
+    When I click *Continue*
+    Then I see a snackbar notification that says *Lesson is not visible to learners*
+    When I reload the browser as a learner
+    Then I don't see the lesson '<lesson>'
+
   Background:
     Given I am signed in to Kolibri as a Coach user
       And I am on *Coach - '<class>' > Report > Lessons > '<lesson>'* page
 
-  Scenario: Coach turns ON the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch *Visible to learners* is in the OFF position (gray)
       When I click the switch for <lesson>
       Then I see the switch slide in the ON position (green)
@@ -76,7 +143,18 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I see the lesson '<lesson>'
 
-  Scenario: Coach turns OFF the lesson *Visible for learners* status
+  Scenario: Coach turns ON the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch *Visible to learners* is in the OFF position (gray)
+      And there are learners using Learn-only Devices in this class
+    When I click the switch for <lesson>
+    Then I see the switch slide in the ON position (green)
+      And I see a modal open that says *Make lesson visible*
+    When I click *Continue*
+    Then I see a snackbar notification that says *Lesson is visible to learners*
+    When I reload the browser as a learner
+    Then I see the lesson '<lesson>'
+
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - no Learner Only Devices
     Given that switch *Visible to learners* is in the ON position (green)
       When I click the switch for <lesson>
       Then I see the switch slide in the OFF position (gray)
@@ -84,6 +162,17 @@ Feature: Coach makes lessons visible
       When I reload the browser as a learner
         Then I don't see the lesson '<lesson>'
 
+  Scenario: Coach turns OFF the lesson *Visible for learners* status - Learner Only Devices
+    Given that switch *Visible to learners* is in the ON position (green)
+      And there are learners using Learn-only Devices in this class
+    When I click the switch for <lesson>
+    Then I see the switch slide in the OFF position (gray)
+      And I see a modal open that says *Make lesson not visible*
+    When I click *Continue*
+    Then I see a snackbar notification that says *Lesson is not visible to learners*
+    When I reload the browser as a learner
+    Then I don't see the lesson '<lesson>'
+
 Examples:
 | lesson                |
 | mathematics exercises |