Skip to content

Commit

Permalink
Copy rte.js
Browse files Browse the repository at this point in the history
  • Loading branch information
paresharma committed Mar 26, 2015
1 parent 0c333ef commit e7b7586
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,46 @@ Make the javascript RTE available to the application
// Add the following line to application.js
//= require scorm_rte/rte
```
Or, you can add this line to `config/initializers/assets.rb`
*Or*, you can add this line to `config/initializers/assets.rb`
```ruby
Rails.application.config.assets.precompile += %w( scorm_rte/rte.js )
```
And, make it available to the subsequent views
```
<%= javascript_include_tag 'scorm_rte/rte' %>
```
*Or*, better still you can copy the RTE js to the application and handle it yourself
```
[bundle exec] rake scorm_rte:copy_rte
```

Well, almost done.!!!
One last thing, that is to assign a unique ID to each instance of the SCO. This will be be used to query the db to keep track of everything that's going on at each User/SCO level.

```ruby
# This can be achieved with this controller helper
# and maybe in some way similar to this
Use the controller helper `assign_sco_instance_id(sco_instane_id)`.

def launch_scorm_player
assign_sco_instance_id(unique_id)
```ruby
# This can be achieved in some way similar to this
class LmsController < ApplicationController
def launch_scorm_player
assign_sco_instance_id(sco_instane_id)

# Rest of the code follows
end
# Rest of the code follows
...
end

private
private

def unique_id
"#{current_user.id}:#{current_course.id}"
def sco_instane_id
"#{current_user.id}:#{current_course.id}"
end
end

```

# TO DO
* Add tests
* ~~Handle custom mount point~~
* Allow export of RTE js to the host application for customization
* ~~Allow export of RTE js to the host application for customization~~
* Possibly implement error and diagnostics or, switch to TinCan perhaps :)


Expand Down
16 changes: 12 additions & 4 deletions lib/tasks/scorm_rte_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# desc "Explaining what the task does"
# task :scorm_rte do
# # Task goes here
# end
namespace :scorm_rte do
desc "Copies the RTE js from scorm_rte assets to main_app assets"
task :copy_rte do
app_path = Rails.root.to_s + '/app/assets/javascripts/scorm_rte'
engine_path = ScormRte::Engine.root.to_s + '/app/assets/javascripts/scorm_rte/rte.js.erb'

FileUtils.mkdir_p app_path
FileUtils.cp engine_path, app_path

puts "Copied #{engine_path} to #{app_path}"
end
end

0 comments on commit e7b7586

Please sign in to comment.