Exemplo n.º 1
0
    def setUp(self):
        self.setup_sample_course()

        self.assignment = ProjectFactory.create(
            course=self.sample_course,
            author=self.instructor_one,
            policy='CourseProtected',
            project_type='selection-assignment')

        self.asset = AssetFactory.create(course=self.sample_course,
                                         primary_source='image')
        AssignmentItemFactory.create(project=self.assignment, asset=self.asset)

        self.response_one = ProjectFactory.create(
            course=self.sample_course,
            author=self.student_one,
            title="Student One Response",
            policy='PrivateEditorsAreOwners',
            parent=self.assignment)
        self.note_one = SherdNoteFactory(asset=self.asset,
                                         author=self.student_one,
                                         body='student one selection note',
                                         range1=0,
                                         range2=1)
        ProjectNoteFactory(project=self.response_one, annotation=self.note_one)

        self.response_two = ProjectFactory.create(
            course=self.sample_course,
            author=self.student_two,
            policy='PrivateEditorsAreOwners',
            parent=self.assignment)
        self.note_two = SherdNoteFactory(asset=self.asset,
                                         author=self.student_two,
                                         title="Student One Response",
                                         body='student two selection note',
                                         range1=0,
                                         range2=1)
        ProjectNoteFactory(project=self.response_two, annotation=self.note_two)

        ProjectFactory.create(course=self.sample_course,
                              author=self.student_three,
                              policy='CourseProtected',
                              parent=self.assignment,
                              date_submitted=datetime.now())

        url = reverse('project-item-view',
                      args=[self.assignment.id, self.asset.id])
        self.view = ProjectItemView()
        self.view.request = RequestFactory().get(url)
        self.view.request.course = self.sample_course
Exemplo n.º 2
0
    def setUp(self):
        self.setup_sample_course()

        self.assignment = ProjectFactory.create(
            course=self.sample_course, author=self.instructor_one,
            policy='CourseProtected',
            project_type='selection-assignment')

        self.asset = AssetFactory.create(course=self.sample_course,
                                         primary_source='image')
        AssignmentItemFactory.create(project=self.assignment, asset=self.asset)

        self.response_one = ProjectFactory.create(
            course=self.sample_course, author=self.student_one,
            title="Student One Response",
            policy='PrivateEditorsAreOwners', parent=self.assignment)
        self.note_one = SherdNoteFactory(
            asset=self.asset, author=self.student_one,
            body='student one selection note', range1=0, range2=1)
        ProjectNoteFactory(project=self.response_one, annotation=self.note_one)

        self.response_two = ProjectFactory.create(
            course=self.sample_course, author=self.student_two,
            policy='PrivateEditorsAreOwners', parent=self.assignment)
        self.note_two = SherdNoteFactory(
            asset=self.asset, author=self.student_two,
            title="Student One Response",
            body='student two selection note', range1=0, range2=1)
        ProjectNoteFactory(project=self.response_two, annotation=self.note_two)

        ProjectFactory.create(
            course=self.sample_course, author=self.student_three,
            policy='CourseProtected', parent=self.assignment,
            date_submitted=datetime.now())

        url = reverse('project-item-view',
                      args=[self.assignment.id, self.asset.id])
        self.view = ProjectItemView()
        self.view.request = RequestFactory().get(url)
        self.view.request.course = self.sample_course
Exemplo n.º 3
0
    path('accounts/', include('registration.backends.default.urls')),

    # API - JSON rendering layers. Half hand-written, half-straight tasty=pie
    path('api/asset/user/<slug:record_owner_name>/',
         AssetCollectionView.as_view(), {}, 'assets-by-user'),
    path('api/asset/<int:asset_id>/', AssetDetailView.as_view(), {},
         'asset-detail'),
    path('api/asset/', AssetCollectionView.as_view(), {}, 'assets-by-course'),
    path('api/user/courses',
         courseaffils.views.course_list_query,
         name='api-user-courses'),
    path('api/tag/', TagCollectionView.as_view(), {}, 'tag-collection-view'),
    path('api/project/user/<slug:record_owner_name>/',
         ProjectCollectionView.as_view(), {}, 'project-by-user'),
    path('api/project/<int:project_id>/<int:asset_id>/',
         ProjectItemView.as_view(), {}, 'project-item-view'),
    path('api/project/<int:project_id>/', ProjectDetailView.as_view(), {},
         'asset-detail'),
    path('api/project/', ProjectCollectionView.as_view(), {}),
    path('api', include(tastypie_api.urls)),

    # Collections Space
    path('asset/', include('mediathread.assetmgr.urls')),
    path('sequence/', include('mediathread.sequence.urls')),
    auth_urls,  # see above

    # Bookmarklet + cache defeating
    path('bookmarklets/<path:path>analyze.js',
         django.views.static.serve, {'document_root': bookmarklet_root},
         name='analyze-bookmarklet'),
    path('nocache/\w+/bookmarklets/<path:path>',
Exemplo n.º 4
0
class ProjectItemViewTest(MediathreadTestMixin, TestCase):
    def setUp(self):
        self.setup_sample_course()

        self.assignment = ProjectFactory.create(
            course=self.sample_course,
            author=self.instructor_one,
            policy='CourseProtected',
            project_type='selection-assignment')

        self.asset = AssetFactory.create(course=self.sample_course,
                                         primary_source='image')
        AssignmentItemFactory.create(project=self.assignment, asset=self.asset)

        self.response_one = ProjectFactory.create(
            course=self.sample_course,
            author=self.student_one,
            title="Student One Response",
            policy='PrivateEditorsAreOwners',
            parent=self.assignment)
        self.note_one = SherdNoteFactory(asset=self.asset,
                                         author=self.student_one,
                                         body='student one selection note',
                                         range1=0,
                                         range2=1)
        ProjectNoteFactory(project=self.response_one, annotation=self.note_one)

        self.response_two = ProjectFactory.create(
            course=self.sample_course,
            author=self.student_two,
            policy='PrivateEditorsAreOwners',
            parent=self.assignment)
        self.note_two = SherdNoteFactory(asset=self.asset,
                                         author=self.student_two,
                                         title="Student One Response",
                                         body='student two selection note',
                                         range1=0,
                                         range2=1)
        ProjectNoteFactory(project=self.response_two, annotation=self.note_two)

        ProjectFactory.create(course=self.sample_course,
                              author=self.student_three,
                              policy='CourseProtected',
                              parent=self.assignment,
                              date_submitted=datetime.now())

        url = reverse('project-item-view',
                      args=[self.assignment.id, self.asset.id])
        self.view = ProjectItemView()
        self.view.request = RequestFactory().get(url)
        self.view.request.course = self.sample_course

    def assert_visible_notes(self,
                             viewer,
                             visible,
                             editable=False,
                             citable=False):
        self.view.request.user = viewer
        response = self.view.get(None,
                                 project_id=self.assignment.id,
                                 asset_id=self.asset.id)
        the_json = json.loads(response.content)
        self.assertEquals(len(the_json['assets']), 1)

        notes = list(the_json['assets'].values())[0]['annotations']
        for idx, note in enumerate(notes):
            self.assertEquals(note['id'], visible[idx][0])
            self.assertEquals(note['editable'], visible[idx][1])
            self.assertFalse(note['citable'])

    def test_get(self):
        # responses are not submitted
        # assignment is set to "always" response policy
        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, True, False)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one, [])

        # submit student one's response
        self.response_one.create_or_update_collaboration('CourseProtected')
        self.response_one.date_submitted = datetime.now()
        self.response_one.save()

        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, True)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, True)])

        # change assignment policy to never
        self.assignment.response_view_policy = RESPONSE_VIEW_NEVER[0]
        self.assignment.save()

        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, False)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, False)])

        # change assignment policy to submitted
        self.assignment.response_view_policy = RESPONSE_VIEW_SUBMITTED[0]
        self.assignment.save()
        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, False)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, False)])

        # submit student two's response
        # all students having submitted, the annotation is now citable
        self.response_two.create_or_update_collaboration('CourseProtected')
        self.response_two.date_submitted = datetime.now()
        self.response_two.save()

        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, False, True)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, False, True)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, False, True)])
Exemplo n.º 5
0
    url(r'^accounts/', include('registration.backends.default.urls')),

    # API - JSON rendering layers. Half hand-written, half-straight tasty=pie
    url(r'^api/asset/user/(?P<record_owner_name>\w[^/]*)/$',
        AssetCollectionView.as_view(), {}, 'assets-by-user'),
    url(r'^api/asset/(?P<asset_id>\d+)/$', AssetDetailView.as_view(),
        {}, 'asset-detail'),
    url(r'^api/asset/$', AssetCollectionView.as_view(), {},
        'assets-by-course'),
    url(r'^api/user/courses$', courseaffils.views.course_list_query,
        name='api-user-courses'),
    url(r'^api/tag/$', TagCollectionView.as_view(), {}, 'tag-collection-view'),
    url(r'^api/project/user/(?P<record_owner_name>\w[^/]*)/$',
        ProjectCollectionView.as_view(), {}, 'project-by-user'),
    url(r'^api/project/(?P<project_id>\d+)/(?P<asset_id>\d+)/$',
        ProjectItemView.as_view(), {}, 'project-item-view'),
    url(r'^api/project/(?P<project_id>\d+)/$', ProjectDetailView.as_view(),
        {}, 'asset-detail'),
    url(r'^api/project/$', ProjectCollectionView.as_view(), {}),
    url(r'^api', include(tastypie_api.urls)),

    # Collections Space
    url(r'^asset/', include('mediathread.assetmgr.urls')),

    url(r'^sequence/', include('mediathread.sequence.urls')),

    auth_urls,  # see above

    # Bookmarklet + cache defeating
    url(r'^bookmarklets/(?P<path>analyze.js)$', django.views.static.serve,
        {'document_root': bookmarklet_root}, name='analyze-bookmarklet'),
Exemplo n.º 6
0
class ProjectItemViewTest(MediathreadTestMixin, TestCase):

    def setUp(self):
        self.setup_sample_course()

        self.assignment = ProjectFactory.create(
            course=self.sample_course, author=self.instructor_one,
            policy='CourseProtected',
            project_type='selection-assignment')

        self.asset = AssetFactory.create(course=self.sample_course,
                                         primary_source='image')
        AssignmentItemFactory.create(project=self.assignment, asset=self.asset)

        self.response_one = ProjectFactory.create(
            course=self.sample_course, author=self.student_one,
            title="Student One Response",
            policy='PrivateEditorsAreOwners', parent=self.assignment)
        self.note_one = SherdNoteFactory(
            asset=self.asset, author=self.student_one,
            body='student one selection note', range1=0, range2=1)
        ProjectNoteFactory(project=self.response_one, annotation=self.note_one)

        self.response_two = ProjectFactory.create(
            course=self.sample_course, author=self.student_two,
            policy='PrivateEditorsAreOwners', parent=self.assignment)
        self.note_two = SherdNoteFactory(
            asset=self.asset, author=self.student_two,
            title="Student One Response",
            body='student two selection note', range1=0, range2=1)
        ProjectNoteFactory(project=self.response_two, annotation=self.note_two)

        ProjectFactory.create(
            course=self.sample_course, author=self.student_three,
            policy='CourseProtected', parent=self.assignment,
            date_submitted=datetime.now())

        url = reverse('project-item-view',
                      args=[self.assignment.id, self.asset.id])
        self.view = ProjectItemView()
        self.view.request = RequestFactory().get(url)
        self.view.request.course = self.sample_course

    def assert_visible_notes(self, viewer, visible,
                             editable=False, citable=False):
        self.view.request.user = viewer
        response = self.view.get(None, project_id=self.assignment.id,
                                 asset_id=self.asset.id)
        the_json = json.loads(response.content)
        self.assertEquals(len(the_json['assets']), 1)

        notes = the_json['assets'].values()[0]['annotations']
        for idx, note in enumerate(notes):
            self.assertEquals(note['id'], visible[idx][0])
            self.assertEquals(note['editable'], visible[idx][1])
            self.assertFalse(note['citable'])

    def test_get(self):
        # responses are not submitted
        # assignment is set to "always" response policy
        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, True, False)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one, [])

        # submit student one's response
        self.response_one.create_or_update_collaboration(
            'CourseProtected')
        self.response_one.date_submitted = datetime.now()
        self.response_one.save()

        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, True)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, True)])

        # change assignment policy to never
        self.assignment.response_view_policy = RESPONSE_VIEW_NEVER[0]
        self.assignment.save()

        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, False)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, False)])

        # change assignment policy to submitted
        self.assignment.response_view_policy = RESPONSE_VIEW_SUBMITTED[0]
        self.assignment.save()
        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, False)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_two.id, True, False)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, False)])

        # submit student two's response
        # all students having submitted, the annotation is now citable
        self.response_two.create_or_update_collaboration(
            'CourseProtected')
        self.response_two.date_submitted = datetime.now()
        self.response_two.save()

        self.assert_visible_notes(self.student_one,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, False, True)])
        self.assert_visible_notes(self.student_two,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, False, True)])
        self.assert_visible_notes(self.instructor_one,
                                  [(self.note_one.id, False, True),
                                   (self.note_two.id, False, True)])