Issue Details (XML | Word | Printable)

Key: MDL-6369
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Tim Hunt
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-2727

Question types cannot easily define their own JavaScript functions

Created: 26/Aug/06 02:55 PM   Updated: 13/Apr/07 12:00 AM
Return to search
Component/s: Questions
Affects Version/s: 1.7
Fix Version/s: 1.9

Participants: Dmitry Pupinin and Tim Hunt
Security Level: None
Resolved date: 13/Apr/07
Affected Branches: MOODLE_17_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
Any javascript that a question type wants has to be written inline in the HTML. It would be better if each qtype was allowed a .js file that was automatically loaded by any page where that qtype was displayed or edited. (We should also ensure that YUI is always available to qtypes).

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Dmitry Pupinin added a comment - 06/Sep/06 04:47 PM
Why you can't insert link to .js in display.html?

Tim Hunt added a comment - 12/Apr/07 01:18 AM
This was already fixed by the require_js function in lib/ajaxlib.php which is part of Moodle 1.8. Cool.

However, I will add a bit to the base question type, so if you have a script.js or scripts.php file in your plugin, it will automatically require_js them for you!


Tim Hunt added a comment - 13/Apr/07 12:00 AM
To use this, you just need to put a script.js or script.php file in the question type folder. If you want to do something more complicated, override the get_html_head_contributions method defined in the base class (or just use the require_js function elsewhere in your code).