Repository: ocadotechnology/codeforlife-portal

Issue:
Implement KS3 teaching materials on the portal
Banner
Preview tag
Links

See https://github.com/ocadotechnology/codeforlife-portal/issues/667 for design


Discussion:

Resolving patch:
diff --git a/portal/views/teacher/pdfs.py b/portal/views/teacher/pdfs.py
--- a/portal/views/teacher/pdfs.py
+++ b/portal/views/teacher/pdfs.py
@@ -897,5 +897,39 @@
         "links": ["uks2_assessment_guide", "uks2_self_assessment_sheet"],
         "url": "python/assessment/UKS2-TRS.pdf",
         "page_origin": "#uks2-assessments"
-    }
+    },
+
+    # ...................KS3 sessions...........#
+    "ks3_session_1": {
+        "title": "MMO",
+        "description": "AI:MMO: the MMO Basics",
+        "links": ["KS1_S1_1", "KS3_S1_2", "KS3_S1_3"],
+        "url": "",
+        "page_origin": "#ks3-sessions"
+    },
+
+    # ..............KS3 Resource Sheets...........#
+    # ...Session 1...#
+    "KS3_S1_1": {
+        "title": "Code cheat sheet",
+        "description": "To be used to code the AI:MMO game.",
+        "links": [],
+        "url": "KS3/resource_sheets/KS3-Cheat-Sheet.pdf",
+        "page_origin": "#ks3-resource-sheets"
+    },
+    "KS3_S1_2": {
+        "title": "Indentation - Why it's important",
+        "description": "To be used to understand how to use Python to code the AI:MMO game.",
+        "links": [],
+        "url": "KS3/resource_sheets/KS3-PythonIndentation.pdf",
+        "page_origin": "#ks3-resource-sheets"
+    },
+    "KS3_S1_3": {
+        "title": "Understanding the turn-based game",
+        "description": "To be used to understand the AI:MMO game.",
+        "links": [],
+        "url": "KS3/resource_sheets/KS3-HandleTurn.pdf",
+        "page_origin": "#ks3-resource-sheets"
+    },
+
 }
diff --git a/portal/views/teacher/teach.py b/portal/views/teacher/teach.py
--- a/portal/views/teacher/teach.py
+++ b/portal/views/teacher/teach.py
@@ -71,16 +71,18 @@
 @user_passes_test(logged_in_as_teacher, login_url=reverse_lazy('login_view'))
 def materials(request):
 
-    session_names = ["ks1_session_", "lks2_session_", "uks2_session_"]
-    resource_sheets_names = ["KS1_S", "LKS2_S", "UKS2_S"]
+    session_names = ["ks1_session_", "lks2_session_", "uks2_session_", "ks3_session_"]
+    resource_sheets_names = ["KS1_S", "LKS2_S", "UKS2_S", "KS3_S"]
     ks1_sessions = []
     lks2_sessions = []
     uks2_sessions = []
-    session_dictionaries = [ks1_sessions, lks2_sessions, uks2_sessions]
+    ks3_sessions = []
+    session_dictionaries = [ks1_sessions, lks2_sessions, uks2_sessions, ks3_sessions]
     ks1_sheets = []
     lks2_sheets = []
     uks2_sheets = []
-    resource_sheets_dictionaries = [ks1_sheets, lks2_sheets, uks2_sheets]
+    ks3_sheets = []
+    resource_sheets_dictionaries = [ks1_sheets, lks2_sheets, uks2_sheets, ks3_sheets]
 
     for ks_index, session_name in enumerate(session_names):
         get_session_pdfs(session_name, session_dictionaries[ks_index])
@@ -94,6 +96,8 @@ def materials(request):
                    'lks2_sheets': lks2_sheets,
                    'uks2_sessions': uks2_sessions,
                    'uks2_sheets': uks2_sheets,
+                   'ks3_sessions': ks3_sessions,
+                   'ks3_sheets': ks3_sheets,
                    })
 
 


Test patch:
diff --git a/portal/tests/pageObjects/portal/materials_page.py b/portal/tests/pageObjects/portal/materials_page.py
--- a/portal/tests/pageObjects/portal/materials_page.py
+++ b/portal/tests/pageObjects/portal/materials_page.py
@@ -47,3 +47,7 @@ def __init__(self, browser):
     def click_pdf_link(self):
         self.browser.find_element_by_id('pdf_link').click()
         return pdf_viewer_page.PDFViewerPage(self.browser)
+
+    def click_keystage_link(self, keystage):
+        self.browser.find_element_by_id(keystage).click()
+        return self
diff --git a/portal/tests/pageObjects/portal/pdf_viewer_page.py b/portal/tests/pageObjects/portal/pdf_viewer_page.py
--- a/portal/tests/pageObjects/portal/pdf_viewer_page.py
+++ b/portal/tests/pageObjects/portal/pdf_viewer_page.py
@@ -35,6 +35,7 @@
 # program; modified versions of the program must be marked as such and not
 # identified as the original program.
 from base_page import BasePage
+import resources_page
 
 
 class PDFViewerPage(BasePage):
@@ -42,3 +43,7 @@ def __init__(self, browser):
         super(PDFViewerPage, self).__init__(browser)
 
         assert self.on_correct_page('pdf_viewer_page')
+
+    def click_resources_button_link(self):
+        self.browser.find_element_by_id('resources_button').click()
+        return resources_page.ResourcesPage(self.browser)
diff --git a/portal/tests/test_security.py b/portal/tests/test_security.py
--- a/portal/tests/test_security.py
+++ b/portal/tests/test_security.py
@@ -36,7 +36,7 @@
 # identified as the original program.
 
 from django.contrib.auth.models import User
-from django.core.urlresolvers import reverse
+from django.core.urlresolvers import reverse, reverse_lazy
 from django.test import Client, TestCase
 from portal.models import Student, UserProfile
 from utils.classes import create_class_directly
@@ -100,3 +100,8 @@ def test_reminder_cards_wrong_teacher(self):
     def test_class_page_wrong_teacher(self):
         """Try and view a class page without being the teacher for that class."""
         self._test_incorrect_teacher_cannot_login('onboarding-class')
+
+    def test_anonymous_cannot_access_teaching_materials(self):
+        c = Client()
+        page = reverse_lazy('materials')
+        self.assertNotEqual(str(c.get(page).status_code)[0], 2)
diff --git a/portal/tests/test_teacher.py b/portal/tests/test_teacher.py
--- a/portal/tests/test_teacher.py
+++ b/portal/tests/test_teacher.py
@@ -116,6 +116,15 @@ def test_view_resources(self):
 
         assert self.is_pdf_viewer_page(page)
 
+        page = page.click_resources_button_link().go_to_materials_page()
+
+        assert self.is_materials_page(page)
+
+        keystages = ['ks1', 'lks2', 'uks2', 'ks3']
+        for ks in keystages:
+            page = page.click_keystage_link(ks)
+            assert self.is_materials_page(page)
+
     def test_edit_details(self):
         email, password = signup_teacher_directly()
         create_organisation_directly(email)