Beispiel #1
0
    def setUp(self):
        self.setup_sample_course()
        self.setup_alternate_course()

        taxonomy = {
            'Shapes': ['Square', 'Triangle'],
            'Colors': ['Red', 'Blue', 'Green']
        }
        self.create_vocabularies(self.sample_course, taxonomy)

        taxonomy = {'Materials': ['Paper', 'Wood', 'Stone']}
        self.create_vocabularies(self.alt_course, taxonomy)

        asset = AssetFactory(course=self.sample_course,
                             author=self.student_one,
                             title="Asset One")

        # instructor_one in Sample Course
        note = SherdNoteFactory(asset=asset,
                                author=self.student_three,
                                title="Nice Tie",
                                tags=',student_three_selection',
                                body='student three selection note',
                                range1=0,
                                range2=1)
        term = Term.objects.get(name="square")
        self.create_term_relationship(note, term)

        note = SherdNoteFactory(asset=asset,
                                author=self.instructor_one,
                                title="Left Corner",
                                tags=',instructor_one_selection',
                                body='instructor one selection note',
                                range1=0,
                                range2=1)
        term = Term.objects.get(name="square")
        self.create_term_relationship(note, term)
        term = Term.objects.get(name="red")
        self.create_term_relationship(note, term)

        # alt_student in Alternate Course
        asset = AssetFactory(course=self.alt_course,
                             author=self.alt_student,
                             title="Asset Two")
        note = SherdNoteFactory(asset=asset,
                                author=self.student_two,
                                title="Whole Item Selection",
                                tags=',alt_student_selection',
                                body='alt student selection note',
                                range1=0,
                                range2=1)
        term = Term.objects.get(name="paper")
        self.create_term_relationship(note, term)
Beispiel #2
0
    def test_create_sherdnote_on_own_asset(self):
        """
        Ensure we can create a new SherdNote (annotation) object.
        """
        asset = AssetFactory(primary_source='image',
                             author=self.u,
                             course=self.sample_course)
        url = reverse('sherdnote-create', kwargs={'asset_id': asset.pk})

        response = self.client.post(url, {}, format='json')
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST,
                         'Empty POST data fails')

        data = {
            'title': 'note title',
            'body': 'note body',
            'range1': 23,
            'range2': 27.565,
        }
        response = self.client.post(url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(SherdNote.objects.count(), 1)
        note = SherdNote.objects.get()
        self.assertEqual(note.title, 'note title')
        self.assertEqual(note.body, 'note body')
        self.assertEqual(note.range1, 23)
        self.assertEqual(note.range2, 27.565)
        self.assertEqual(note.author, self.u)
Beispiel #3
0
    def setUp(self):
        self.setup_sample_course()

        self.assignment1 = ProjectFactory.create(
            title='Alpha', course=self.sample_course,
            author=self.instructor_one, policy='CourseProtected',
            project_type='assignment')

        self.response1 = ProjectFactory.create(
            title="Response 1",
            course=self.sample_course, author=self.student_one,
            policy='InstructorShared', parent=self.assignment1)

        self.asset = AssetFactory(course=self.sample_course)
        SherdNote.objects.global_annotation(
            self.asset, self.student_one, auto_create=True)
        self.student_one_selection1 = SherdNoteFactory(
            asset=self.asset, author=self.student_one,
            tags=',student_one_selection',
            title="Selection", range1=116.25, range2=6.75)
        self.student_one_selection2 = SherdNoteFactory(
            asset=self.asset, author=self.student_one,
            title="Selection", range1=116.25, range2=6.75)
        self.student_two_selection = SherdNoteFactory(
            asset=self.asset, author=self.student_two,
            title="Selection", range1=16.25, range2=2.75)

        self.add_citation(self.response1, self.student_one_selection1)
        self.add_citation(self.response1, self.student_two_selection)
Beispiel #4
0
    def test_copy_annotation(self):
        asset = AssetFactory(course=self.sample_course, primary_source='image')

        self.assertIsNone(asset.global_annotation(self.student_two, False))

        note = SherdNoteFactory(asset=asset,
                                author=self.student_one,
                                title='Sample Note',
                                annotation_data='{1:2}',
                                body='student one notes',
                                tags=',student_one_selection',
                                range1=0,
                                range2=1)

        params = {'asset_id': asset.id, 'annotation_id': note.id}

        url = reverse('annotation-copy-view', args=[asset.id, note.id])
        self.client.login(username=self.student_two.username, password='******')
        response = self.client.post(url,
                                    params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        the_json = loads(response.content)

        self.assertEquals(the_json['asset']['id'], asset.id)
        self.assertNotEquals(the_json['annotation']['id'], note.id)

        self.assertEquals(response.status_code, 200)
        note = SherdNote.objects.get(author=self.student_two,
                                     title=note.title,
                                     range1=note.range1,
                                     range2=note.range2,
                                     annotation_data=note.annotation_data)
        self.assertEquals(note.tags, '')
        self.assertIsNone(note.body)
        self.assertIsNotNone(asset.global_annotation(self.student_two, False))
Beispiel #5
0
    def test_create_sherdnote_on_own_image_asset(self):
        """
        Ensure we can create a new SherdNote (annotation) object.
        """
        asset = AssetFactory(primary_source='image',
                             author=self.u,
                             course=self.sample_course)
        url = reverse('sherdnote-create', kwargs={'asset_id': asset.pk})

        response = self.client.post(url, {}, format='json')
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST,
                         'Empty POST data fails')

        data = {
            'title': 'Image annotation',
            'body': 'Image annotation body',
            'range1': -2,
            'range2': -1,
            'annotation_data': {
                'geometry': {
                    'type':
                    'Polygon',
                    'coordinates': [[[[276.88964843749994, 128.6806640625],
                                      [323.78417968749994, 14.2275390625],
                                      [435.80566406249994, 100.990234375],
                                      [276.88964843749994, 128.6806640625]]]]
                },
                'default':
                False,
                'x':
                -2,
                'y':
                -1,
                'zoom':
                1,
                'extent': [
                    276.88964843749994, 14.2275390625, 435.80566406249994,
                    128.6806640625
                ]
            }
        }
        response = self.client.post(url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(SherdNote.objects.count(), 2)
        note = SherdNote.objects.get(title='Image annotation')
        self.assertEqual(note.body, 'Image annotation body')
        self.assertEqual(note.range1, -2)
        self.assertEqual(note.range2, -1)
        self.assertEqual(note.author, self.u)

        # Test annotation data (this saves/loads as JSON text)
        annotation_data = note.annotation()
        self.assertEqual(annotation_data['geometry']['type'], 'Polygon')
        self.assertEqual(annotation_data['geometry']['coordinates'][0][0][0],
                         [276.88964843749994, 128.6806640625])
        self.assertEqual(annotation_data['extent'], [
            276.88964843749994, 14.2275390625, 435.80566406249994,
            128.6806640625
        ])
Beispiel #6
0
    def test_update_reference_in_string(self):
        old_asset = AssetFactory(course=self.sample_course,
                                 author=self.student_one)
        old_note = SherdNoteFactory(asset=old_asset,
                                    author=self.student_one,
                                    title="Selection",
                                    range1=43,
                                    range2=75)
        alt_note = SherdNoteFactory(asset=old_asset,
                                    author=self.student_one,
                                    title="Alt Selection",
                                    range1=43,
                                    range2=75)

        new_asset = AssetFactory(course=self.sample_course,
                                 author=self.student_one)
        new_note = SherdNoteFactory(asset=new_asset,
                                    author=self.student_one,
                                    title="Selection",
                                    range1=43,
                                    range2=75)

        text = ('<p><a href="/asset/%s/annotations/%s/">Selection</a>'
                '</p><p><a href="/asset/%s/annotations/%s/">Selection</a>'
                '</p><p><a href="/asset/%s/annotations/%s/">Alt Selection</a>'
                '</p><a href="/asset/%s/">Global</a></p>' %
                (old_asset.id, old_note.id, old_asset.id, old_note.id,
                 old_asset.id, alt_note.id, old_asset.id))

        new_text = new_note.update_references_in_string(text, old_note)

        citations = SherdNote.objects.references_in_string(
            new_text, old_note.author)
        self.assertEquals(len(citations), 4)
        self.assertEquals(citations[0].id, new_note.id)
        self.assertEquals(citations[0].asset.id, new_note.asset.id)

        self.assertEquals(citations[1].id, new_note.id)
        self.assertEquals(citations[1].asset.id, new_note.asset.id)

        self.assertEquals(citations[2].id, alt_note.id)
        self.assertEquals(citations[2].asset.id, old_asset.id)

        gann = old_asset.global_annotation(self.student_one, auto_create=False)
        self.assertEquals(citations[3].id, gann.id)
        self.assertEquals(citations[3].asset.id, old_asset.id)
Beispiel #7
0
 def test_is_already_imported(self):
     session = {'Name': 'The Name', 'Id': 'source url'}
     self.assertFalse(
         self.ingester.is_already_imported(self.sample_course, session))
     AssetFactory(course=self.sample_course,
                  author=self.student_one,
                  primary_source='mp4_panopto')
     self.assertTrue(
         self.ingester.is_already_imported(self.sample_course, session))
Beispiel #8
0
 def test_create_sherdnote_as_anon(self):
     """
     Ensure we can create a new SherdNote (annotation) object.
     """
     asset = AssetFactory(primary_source='image')
     url = reverse('sherdnote-create', kwargs={'asset_id': asset.pk})
     data = {'title': 'note title', 'body': 'note body'}
     response = self.client.post(url, data, format='json')
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
     self.assertEqual(SherdNote.objects.count(), 0)
Beispiel #9
0
    def test_create_sherdnote_on_own_asset(self):
        """
        Ensure we can create a new SherdNote (annotation) object.
        """
        asset = AssetFactory(primary_source='image',
                             author=self.u,
                             course=self.sample_course)
        url = reverse('sherdnote-create', kwargs={'asset_id': asset.pk})

        response = self.client.post(url, {}, format='json')
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST,
                         'Empty POST data fails')

        data = {
            'title': 'note title',
            'body': 'note body',
            'range1': 23,
            'range2': 27.565,
        }
        response = self.client.post(url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(SherdNote.objects.count(), 2)
        note = SherdNote.objects.get(title='note title')
        self.assertEqual(note.body, 'note body')
        self.assertEqual(note.range1, 23)
        self.assertEqual(note.range2, 27.565)
        self.assertEqual(note.author, self.u)

        data = {
            'title': 'note title 2',
            'body': 'note body 2',
            'range1': 43,
            'range2': 47.565,
            'tags': 'My Tag,Green,Black',
        }
        response = self.client.post(url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(SherdNote.objects.count(), 3)
        note = SherdNote.objects.get(title='note title 2')
        self.assertEqual(note.body, 'note body 2')
        self.assertEqual(note.range1, 43)
        self.assertEqual(note.range2, 47.565)
        self.assertEqual(note.author, self.u)

        # test saved tag functionality
        tags = note.tags_split()
        self.assertEqual(len(tags), 3)
        Tag.objects.get(name='my tag')
        Tag.objects.get(name='green')
        Tag.objects.get(name='black')
        with self.assertRaises(Tag.DoesNotExist):
            Tag.objects.get(name='unknown tag')
Beispiel #10
0
    def test_get_related_assets(self):
        asset2 = AssetFactory(course=self.sample_course,
                              author=self.student_one)
        note2 = SherdNoteFactory(asset=asset2, author=self.student_one)

        ids = [self.student_one_ga.id, self.student_one_note.id, note2.id]
        notes = SherdNote.objects.filter(id__in=ids)

        assets = notes.get_related_assets()
        self.assertEquals(assets.count(), 2)
        self.assertTrue(self.asset in assets)
        self.assertTrue(asset2 in assets)
Beispiel #11
0
 def setUp(self):
     self.setup_sample_course()
     self.asset = AssetFactory(course=self.sample_course)
     self.data = {
         'annotation-title': 'Annotation Test',
         'annotation-body': 'notes go here',
         'annotation-annotation_data': '',
         'annotation-context_pk': self.asset.id,
         'annotation-range1': -4.5,
         'annotation-range2': 23,
         'annotation-tags': 'foo,bar',
         'next': 'foo'
     }
Beispiel #12
0
    def test_update_title_on_asset(self):
        asset = AssetFactory(title='My Title',
                             primary_source='image',
                             author=self.u,
                             course=self.sample_course)
        url = reverse('asset-update', kwargs={'asset_id': asset.pk})

        response = self.client.put(url, {'title': 'New Title'}, format='json')

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        asset.refresh_from_db()
        self.assertEqual(Asset.objects.count(), 1)
        self.assertEqual(asset.title, 'New Title')
Beispiel #13
0
    def test_create_sherdnote_as_anon(self):
        """
        Ensure we can't update this asset.
        """
        asset = AssetFactory(title='My Title', primary_source='image')
        url = reverse('asset-update', kwargs={'asset_id': asset.pk})
        response = self.client.put(url, {'title': 'asset title'},
                                   format='json')

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        asset.refresh_from_db()
        self.assertEqual(Asset.objects.count(), 1)
        self.assertEqual(asset.title, 'My Title')
Beispiel #14
0
 def test_create_sherdnote_on_asset_not_visible(self):
     asset = AssetFactory(primary_source='image')
     url = reverse('sherdnote-create', kwargs={'asset_id': asset.pk})
     data = {
         'title': 'note title',
         'body': 'note body',
         'range1': 23,
         'range2': 27,
     }
     response = self.client.post(url, data, format='json')
     self.assertEqual(
         response.status_code, status.HTTP_403_FORBIDDEN,
         'Can\'t create SherdNote on an asset that\'s not visible to me.')
     self.assertEqual(SherdNote.objects.count(), 0)
Beispiel #15
0
    def test_send_email(self):
        item = AssetFactory(id=1,
                            title='Item',
                            course=self.sample_course,
                            author=self.student_one,
                            primary_source='mp4_panopto')

        self.ingester.send_email(self.sample_course, self.student_one, item)

        self.assertEqual(len(mail.outbox), 1)

        self.assertEqual(mail.outbox[0].subject,
                         'Mediathread submission now available')
        self.assertEqual(mail.outbox[0].from_email, settings.SERVER_EMAIL)
        self.assertEqual(mail.outbox[0].to, [self.student_one.email])
Beispiel #16
0
    def setUp(self):
        self.setup_sample_course()
        self.factory = RequestFactory()

        taxonomy = {
            'Shapes': ['Square', 'Triangle', 'Circle'],
            'Colors': ['Red', 'Blue', 'Green']
        }
        self.create_vocabularies(self.sample_course, taxonomy)

        self.asset = AssetFactory(course=self.sample_course)
        self.note = SherdNoteFactory(asset=self.asset,
                                     author=self.student_one,
                                     title="Whole Item Selection",
                                     range1=116.25,
                                     range2=6.75)
Beispiel #17
0
    def setUp(self):
        self.setup_sample_course()
        asset = AssetFactory(author=self.student_one,
                             primary_source='image',
                             course=self.sample_course)

        self.note1 = SherdNoteFactory(asset=asset,
                                      author=self.student_one,
                                      title='one',
                                      range1=116.25,
                                      range2=6.75)

        self.note2 = SherdNoteFactory(asset=asset,
                                      author=self.student_one,
                                      title='two',
                                      range1=116.25,
                                      range2=6.75)
Beispiel #18
0
    def setUp(self):
        self.setup_sample_course()
        self.asset = AssetFactory(
            course=self.sample_course,
            primary_source='flv',
            metadata_blob='{"wardenclyffe-id": ["33210"], "license": [""]')
        SourceFactory(asset=self.asset, label='thumb', url='foo')

        self.url = reverse('asset-update-view')

        self.params = {
            'secret': 'something secret',
            'metadata-uuid': '1234567',
            'metadata-tag': 'update',
            'thumb': 'new thumb',
            'mp4_pseudo': ''
        }
Beispiel #19
0
    def test_annotation_delete(self):
        asset = AssetFactory(course=self.sample_course, primary_source='image')
        note = SherdNoteFactory(asset=asset,
                                author=self.student_one,
                                tags=',student_one_selection',
                                range1=0,
                                range2=1)

        request = RequestFactory().post('/')
        request.user = self.student_one
        request.course = self.sample_course

        response = annotation_delete(request, asset.id, note.id)
        self.assertEquals(response.status_code, 302)

        response = annotation_delete(request, asset.id, note.id)
        self.assertEquals(response.status_code, 404)
Beispiel #20
0
    def setUp(self):
        self.setup_sample_course()

        self.asset = AssetFactory(
            course=self.sample_course,
            author=self.student_one,
            primary_source='image',
        )

        self.student_one_ga = SherdNoteFactory(asset=self.asset,
                                               author=self.student_one,
                                               tags=',student_one_item',
                                               title=None,
                                               range1=None,
                                               range2=None)
        self.assertTrue(self.student_one_ga.is_global_annotation())
        self.student_one_note = SherdNoteFactory(asset=self.asset,
                                                 author=self.student_one,
                                                 tags=',student_one_selection',
                                                 range1=0,
                                                 range2=1)

        self.student_two_ga = SherdNoteFactory(asset=self.asset,
                                               author=self.student_two,
                                               tags=',student_two_item',
                                               title=None,
                                               range1=None,
                                               range2=None)
        self.student_two_note = SherdNoteFactory(asset=self.asset,
                                                 author=self.student_two,
                                                 tags=',student_two_selection',
                                                 range1=0,
                                                 range2=1)

        self.instructor_one_ga = SherdNoteFactory(asset=self.asset,
                                                  author=self.instructor_one,
                                                  tags=',instructor_one_item',
                                                  title=None,
                                                  range1=None,
                                                  range2=None)
        self.instructor_one_note = SherdNoteFactory(
            asset=self.asset,
            author=self.instructor_one,
            tags=',image,instructor_one_selection,',
            range1=0,
            range2=1)
Beispiel #21
0
    def test_add_tag(self):
        asset = AssetFactory(course=self.sample_course)
        ann, created = SherdNote.objects.global_annotation(
            asset, self.instructor_one)

        ann.tags = ',foobar'
        ann.save()

        ann.add_tag("foo")
        ann.add_tag("bar")
        ann.save()

        tags = ann.tags_split()
        self.assertEquals(len(tags), 3)
        self.assertEquals(tags[0].name, 'bar')
        self.assertEquals(tags[1].name, 'foo')
        self.assertEquals(tags[2].name, 'foobar')
Beispiel #22
0
    def test_get(self):
        asset = AssetFactory(course=self.sample_course, primary_source='image')
        SherdNoteFactory(asset=asset,
                         author=self.student_one,
                         tags=',student_one_selection',
                         range1=0,
                         range2=1)
        SherdNoteFactory(asset=asset,
                         author=self.student_one,
                         tags=',student_one_item',
                         title=None,
                         range1=None,
                         range2=None)

        url = reverse('asset-references', args=[asset.id])

        # anonymous
        response = self.client.get(url)
        self.assertEquals(response.status_code, 302)

        self.client.login(username=self.student_one, password='******')

        # non-ajax
        response = self.client.get(url)
        self.assertEquals(response.status_code, 405)

        # ajax
        response = self.client.get(url, {},
                                   HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content)
        self.assertTrue('tags' in the_json)
        self.assertTrue('vocabulary' in the_json)
        self.assertTrue('references' in the_json)

        # invalid asset
        url = reverse('asset-references', args=[1234])
        response = self.client.get(url, {},
                                   HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content)
        self.assertFalse('tags' in the_json)
        self.assertFalse('vocabulary' in the_json)
        self.assertFalse('references' in the_json)
Beispiel #23
0
    def setUp(self):
        self.setup_sample_course()

        self.asset1 = AssetFactory(course=self.sample_course)
        global_annotation, created = SherdNote.objects.global_annotation(
            self.asset1, self.student_three, auto_create=True)
        self.assertTrue(global_annotation.is_global_annotation())

        whole_item_annotation = SherdNoteFactory(
            asset=self.asset1, author=self.student_three,
            title="Whole Item Selection", range1=0, range2=0)
        self.assertFalse(whole_item_annotation.is_global_annotation())

        real_annotation = SherdNoteFactory(
            asset=self.asset1, author=self.student_three,
            title="Selection", range1=116.25, range2=6.75)
        self.assertFalse(real_annotation.is_global_annotation())

        self.assignment1 = ProjectFactory.create(
            title='Alpha', course=self.sample_course,
            author=self.instructor_one, policy='CourseProtected',
            project_type='assignment')

        self.response1 = ProjectFactory.create(
            title="Response 1",
            course=self.sample_course, author=self.student_one,
            policy='InstructorShared', parent=self.assignment1)
        self.response2 = ProjectFactory.create(
            title="Response 2", date_submitted=datetime.now(),
            course=self.sample_course, author=self.student_two,
            policy='InstructorShared', parent=self.assignment1)

        self.assignment2 = ProjectFactory.create(
            title='Beta', course=self.sample_course,
            author=self.instructor_one, policy='CourseProtected',
            project_type='assignment')

        self.project = ProjectFactory(title='Gamma', course=self.sample_course,
                                      author=self.instructor_one,
                                      policy='CourseProtected')

        self.add_citation(self.project, global_annotation)
        self.add_citation(self.project, whole_item_annotation)
        self.add_citation(self.project, real_annotation)
Beispiel #24
0
    def test_is_global_annotation(self):
        asset = AssetFactory(course=self.sample_course)
        global_annotation, created = SherdNote.objects.global_annotation(
            asset, self.student_three, auto_create=True)
        self.assertTrue(global_annotation.is_global_annotation())

        whole_item_annotation = SherdNoteFactory(asset=asset,
                                                 author=self.student_three,
                                                 title="Whole Item Selection",
                                                 range1=0,
                                                 range2=0)
        self.assertFalse(whole_item_annotation.is_global_annotation())

        real_annotation = SherdNoteFactory(asset=asset,
                                           author=self.student_three,
                                           title="Whole Item Selection",
                                           range1=116.25,
                                           range2=6.75)
        self.assertFalse(real_annotation.is_global_annotation())
Beispiel #25
0
    def test_annotation_create_global(self):
        asset = AssetFactory(course=self.sample_course, primary_source='image')
        request = RequestFactory().post('/', {},
                                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.student_one
        request.course = self.sample_course
        response = annotation_create_global(request, asset.id)
        self.assertEquals(response.status_code, 200)

        ga = asset.global_annotation(self.student_one, auto_create=False)
        self.assertIsNotNone(ga)

        the_json = loads(response.content)
        self.assertEquals(the_json['asset']['id'], asset.id)
        self.assertEquals(the_json['annotation']['id'], ga.id)

        # invalid asset
        with self.assertRaises(Http404):
            annotation_create_global(request, 1234)
Beispiel #26
0
    def setUp(self):
        super(self.__class__, self).setUp()

        self.asset = AssetFactory(course=self.sample_course,
                                  author=self.student_one)

        self.ga1 = SherdNoteFactory(asset=self.asset,
                                    author=self.student_one,
                                    tags=',student_one_item',
                                    title=None,
                                    range1=None,
                                    range2=None)
        self.assertTrue(self.ga1.is_global_annotation())
        self.note1 = SherdNoteFactory(asset=self.asset,
                                      author=self.student_one,
                                      tags=',student_one_selection',
                                      range1=0,
                                      range2=1)

        self.ga2 = SherdNoteFactory(asset=self.asset,
                                    author=self.student_two,
                                    tags=',student_two_item',
                                    title=None,
                                    range1=None,
                                    range2=None)
        self.note2 = SherdNoteFactory(asset=self.asset,
                                      author=self.student_two,
                                      tags=',student_two_selection',
                                      range1=0,
                                      range2=1)

        self.ga3 = SherdNoteFactory(asset=self.asset,
                                    author=self.instructor_one,
                                    tags=',instructor_one_item',
                                    title=None,
                                    range1=None,
                                    range2=None)
        self.note3 = SherdNoteFactory(asset=self.asset,
                                      author=self.instructor_one,
                                      tags=',image,instructor_one_selection,',
                                      range1=0,
                                      range2=1)
Beispiel #27
0
    def test_get_global_annotation(self):
        asset = AssetFactory(course=self.sample_course)
        author = self.instructor_one

        ann, created = SherdNote.objects.global_annotation(asset, author)
        self.assertTrue(created)

        ann, created = SherdNote.objects.global_annotation(asset, author)
        self.assertFalse(created)

        self.assertEquals(ann.title, None)
        self.assertEquals(ann.title, None)
        self.assertEquals(ann.body, None)
        self.assertEquals(ann.tags, '')

        author = self.student_one
        ann, created = SherdNote.objects.global_annotation(asset, author)
        self.assertTrue(created)
        self.assertEquals(ann.title, None)
        self.assertEquals(ann.body, None)
        self.assertEquals(ann.tags, '')
Beispiel #28
0
    def test_add_session_status(self):
        item = AssetFactory(
            id=1, title='Item',
            course=self.sample_course, author=self.student_one,
            primary_source='mp4_panopto')

        session = {'Name': 'bar', 'Id': 1}
        self.ingester.add_session_status(
            self.sample_course, session, item, self.student_one, False)
        messages = [m.message for m in get_messages(self.request)]
        self.assertTrue(
            'bar (1) saved as <a href="/asset/1/">Item</a> for Student One' in
            messages)

        session = {'Name': 'bar', 'Id': 1}
        self.ingester.add_session_status(
            self.sample_course, session, item, self.student_one, True)
        messages = [m.message for m in get_messages(self.request)]
        self.assertTrue(
            ('bar (1) saved as <a href="/asset/1/">Item</a>'
             ' for Student One. <b>student_one is a new user</b>') in messages)
Beispiel #29
0
    def test_range_as_timecode(self):
        asset = AssetFactory(course=self.sample_course)

        global_annotation, created = SherdNote.objects.global_annotation(
            asset, self.student_three, auto_create=True)
        self.assertEquals(global_annotation.range_as_timecode(), "")

        whole_item_annotation = SherdNoteFactory(asset=asset,
                                                 author=self.student_three)
        self.assertEquals(whole_item_annotation.range_as_timecode(), "")

        real_annotation = SherdNoteFactory(asset=asset,
                                           author=self.student_three,
                                           range1=28,
                                           range2=39)
        self.assertEquals(real_annotation.range_as_timecode(), "0:28 - 0:39")

        real_annotation = SherdNoteFactory(asset=asset,
                                           author=self.student_three,
                                           range1=43,
                                           range2=75)
        self.assertEquals(real_annotation.range_as_timecode(), "0:43 - 01:15")
Beispiel #30
0
    def test_create_sherdnote_on_classmates_asset(self):
        """
        Ensure we can create a new SherdNote (annotation) object on a
        classmate's asset.
        """
        asset = AssetFactory(primary_source='image',
                             author=self.student_one,
                             course=self.sample_course)
        url = reverse('sherdnote-create', kwargs={'asset_id': asset.pk})

        data = {
            'title': 'note title',
            'body': 'note body',
            'range1': 23,
            'range2': 27.565,
        }
        response = self.client.post(url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(SherdNote.objects.count(), 2)
        note = SherdNote.objects.get(title='note title')
        self.assertEqual(note.author, self.u)