Files
edx-platform/lms/static/coffee/src/notes.coffee
daniel cebrian 7e2652b5a8 annotation tools
First set of fixes from the pull request

This does not include some of the testing files. The textannotation and
videoannotation test files are not ready. waiting for an answer on the
issue.

Deleted token line in api.py and added test for token generator

Added notes_spec.coffee

remove spec file

fixed minor error with the test

fixes some quality errors

fixed unit test

fixed unit test

added advanced module

Added notes_spec.coffee

remove spec file

Quality and  Testing Coverage

1. in test_textannotation.py I already check for line 75 as it states
in the diff in line 43, same with test_videoanntotation
2. Like you said, exceptions cannot be checked for
firebase_token_generator.py. The version of python that is active on
the edx server is 2.7 or higher, but the code is there for correctness.
Error checking works the same way.
3. I added a test for student/views/.py within tests and deleted the
unused secret assignment.
4. test_token_generator.py is now its own file

Added Secret Token data input

fixed token generator

Annotation Tools in Place

The purpose of this pull request is to install two major modules: (1) a
module to annotate text and (2) a module to annotate video. In either
case an instructor can declare them in advanced settings under
advanced_modules and input content (HTML in text, mp4 or YouTube videos
for video). Students will be able to highlight portions and add their
comments as well as reply to each other. There needs to be a storage
server set up per course as well as a secret token to talk with said
storage.

Changes:
1. Added test to check for the creation of a token in tests.py (along
with the rest of the tests for student/view.py)
2. Removed items in cms pertaining to annotation as this will only be
possible in the lms
3. Added more comments to firebase_token_generator.py, the test files,
students/views.py
4. Added some internationalization stuff to textannotation.html and
videoannotation.html. I need some help with doing it in javascript, but
the html is covered.

incorporated lib for traslate

fixed quality errors

fixed my notes with catch token

Text and Video Annotation Modules - First Iteration

The following code-change is the first iteration of the modules for
text and video annotation.

Installing Modules:
1. Under “Advanced Settings”, add “textannotation” and
“videoannotation” to the list of advanced_modules.
2. Add link to an external storage for annotations under
“annotation_storage_url”
3. Add the secret token for talking with said storage under
“annotation_token_secret”

Using Modules
1. When creating  new unit, you can find Text and Video annotation
modules under “Advanced” component
2. Make sure you have either Text or Video in one unit, but not both.
3. Annotations are only allowed on Live/Public version and not Studio.

Added missing templates and fixed more of the quality errors

Fixed annotator not existing issue in cmd and tried to find the get_html() from the annotation module class to the descriptor

Added a space after # in comments

Fixed issue with an empty Module and token links

Added licenses and fixed vis naming scheme and location.
2014-01-27 13:47:58 -05:00

126 lines
4.6 KiB
CoffeeScript

class StudentNotes
_debug: false
targets: [] # holds elements with annotator() instances
# Adds a listener for "notes" events that may bubble up from descendants.
constructor: ($, el) ->
console.log 'student notes init', arguments, this if @_debug
if not $(el).data('notes-instance')
events = 'notes:init': @onInitNotes
$(el).delegate('*', events)
$(el).data('notes-instance', @)
# Initializes annotations on a container element in response to an init event.
onInitNotes: (event, uri=null) =>
event.stopPropagation()
storeConfig = @getStoreConfig uri
found = @targets.some (target) -> target is event.target
# Get uri
unless uri.substring(0, 4) is "http"
uri_root = (window.location.href.split(/#|\?/).shift() or "")
uri = uri_root + uri.substring(1)
parts = window.location.href.split("/")
courseid = parts[4] + "/" + parts[5] + "/" + parts[6]
# Get id and name user
idUdiv = $(event.target).parent().find(".idU")[0]
idDUdiv = $(event.target).parent().find(".idDU")[0]
idUdiv = (if typeof idUdiv isnt "undefined" then idUdiv.innerHTML else "")
idDUdiv = (if typeof idDUdiv isnt "undefined" then idDUdiv.innerHTML else "")
options =
optionsAnnotator:
permissions:
user:
id: idUdiv
name: idDUdiv
userString: (user) ->
return user.name if user and user.name
user
userId: (user) ->
return user.id if user and user.id
user
auth:
tokenUrl: location.protocol+'//'+location.host+"/token?course_id="+courseid
store:
prefix: 'http://catch.aws.af.cm/annotator'
annotationData: uri:uri
urls:
create: '/create',
read: '/read/:id',
update: '/update/:id',
destroy: '/delete/:id',
search: '/search'
loadFromSearch:
limit:10000
uri: uri
user:idUdiv
optionsVideoJS: techOrder: ["html5","flash","youtube"],customControlsOnMobile: true
optionsOVA:
posBigNew:'none'
NumAnnotations:20
optionsRichText:
tinymce:
selector: "li.annotator-item textarea"
plugins: "media image insertdatetime link code"
menubar: false
toolbar_items_size: 'small'
extended_valid_elements : "iframe[src|frameborder|style|scrolling|class|width|height|name|align|id]"
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media rubric | code "
if found
$(event.target).annotator "destroy" unless Annotator._instances.length is 0
ova = new OpenVideoAnnotation.Annotator($(event.target), options)
else
if event.target.id is "annotator-viewer"
ova = new OpenVideoAnnotation.Annotator($(event.target), options)
else
@targets.push(event.target)
# Returns a JSON config object that can be passed to the annotator Store plugin
getStoreConfig: (uri) ->
prefix = @getPrefix()
if uri is null
uri = @getURIPath()
storeConfig =
prefix: prefix
loadFromSearch:
uri: uri
limit: 0
annotationData:
uri: uri
storeConfig
# Returns the API endpoint for the annotation store
getPrefix: () ->
re = /^(\/courses\/[^/]+\/[^/]+\/[^/]+)/
match = re.exec(@getURIPath())
prefix = (if match then match[1] else '')
return "#{prefix}/notes/api"
# Returns the URI path of the current page for filtering annotations
getURIPath: () ->
window.location.href.toString().split(window.location.host)[1]
# Enable notes by default on the document root.
# To initialize annotations on a container element in the document:
#
# $('#myElement').trigger('notes:init');
#
# Comment this line to disable notes.
$(document).ready ($) -> new StudentNotes $, @