forked from catalyst/moodle-mod_ouwiki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6077be8
Showing
71 changed files
with
12,812 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
OU wiki | ||
======= | ||
|
||
Copyright 2011 The Open University | ||
|
||
|
||
This is an alternative wiki that you can install into standard Moodle. | ||
|
||
It does not replace the standard wiki, and operates alongside it. The key | ||
intention of this wiki is to provide a simple teaching tool suitable for | ||
student use with minimal required training. It is in no way intended to be | ||
a full-fledged wiki like MediaWiki. For example, there is no wiki syntax | ||
except [[links]]. | ||
|
||
|
||
Support: | ||
|
||
We cannot offer direct support. Please do not contact me directly. If you | ||
need assistance, try the wiki forum on moodle.org. (Remember to make clear | ||
that you are using OU wiki and not the standard forum.) | ||
|
||
Bug reports: | ||
|
||
Please report bugs to the Moodle tracker using the 'contributed code' project | ||
and 'Module: OU wiki' component. Under Version, please select your Moodle | ||
version e.g. 2.1, 2.2. | ||
|
||
Status: | ||
|
||
Beta quality code. We intend to switch this project to include live quality | ||
code at some point after our mid-October update. | ||
|
||
Please note that this code is tested on OU systems but we rely on the | ||
community for testing on other systems. | ||
|
||
Requires: | ||
|
||
Moodle 2.1+ | ||
Postgres / MySQL | ||
|
||
Install: | ||
|
||
Place the contents of this source tree into your Moodle installation so that | ||
within your Moodle root, this file is mod/ouwiki/README. Then visit the | ||
Moodle notifications page to install. | ||
|
||
If you want the forums to be searchable, you also need to install the | ||
local_ousearch plugin. (It is best to do this before using the wiki much, | ||
otherwise it takes ages to install as it builds indexes for everything.) | ||
When you install the ousearch plugin, a search box will automatically appear. | ||
|
||
Documentation: | ||
|
||
None. Please feel free to contribute documentation in the relevant area of | ||
the MoodleDocs wiki. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
/* Javascript for adding annotations */ | ||
|
||
var ouwiki_annotate = {}; | ||
|
||
var newWin = null; | ||
var currentMarker = ""; | ||
|
||
YAHOO.util.Event.onDOMReady(ouwiki_annotate_init); | ||
|
||
function ouwiki_annotate_init() { | ||
var save = ouwiki_annotate_config.save; | ||
var cancel = ouwiki_annotate_config.cancel; | ||
|
||
// Define various event handlers for Dialog | ||
var handleSubmit = function() { | ||
var data = this.getData(); | ||
newAnnotation(data.annotationtext); | ||
this.submit(); | ||
}; | ||
var handleCancel = function() { | ||
this.cancel(); | ||
}; | ||
var handleSuccess = function(o) { | ||
var response = o.responseText; | ||
response = response.split("<!")[0]; | ||
document.getElementById("resp").innerHTML = response; | ||
}; | ||
var handleFailure = function(o) { | ||
alert("Submission failed: " + o.status); | ||
}; | ||
|
||
// Instantiate the Dialog | ||
var annotationdialog = YAHOO.util.Dom.get('annotationdialog'); | ||
if (annotationdialog) { | ||
YAHOO.util.Dom.get(document.body).appendChild(annotationdialog); | ||
} | ||
ouwiki_annotate.annotationdialog = new YAHOO.widget.Dialog('annotationdialog', { | ||
modal: true, | ||
width: '100%', | ||
iframe: true, | ||
zIndex: 1000, // zIndex must be way above 99 to be above the active quiz tab | ||
fixedcenter: true, | ||
visible: false, | ||
close: true, | ||
constraintoviewport: true, | ||
postmethod: 'none', | ||
buttons: [ { text:save, handler:handleSubmit, isDefault: true }, | ||
{ text:cancel, handler:handleCancel } ] | ||
}); | ||
|
||
// Wire up the success and failure handlers | ||
ouwiki_annotate.annotationdialog.callback = { success: handleSuccess, failure: handleFailure }; | ||
|
||
ouwiki_annotate.annotationdialog.render(); | ||
var div = document.getElementById('annotationdialog'); | ||
if (div) { | ||
div.style.display = 'block'; | ||
} | ||
|
||
// setup keycodes | ||
markers = YAHOO.util.Dom.getElementsByClassName('ouwiki-annotation-marker', 'span'); | ||
for (var i = 0; i < markers.length; i++) { | ||
setupmarkers(markers[i], ouwiki_annotate.annotationdialog); | ||
} | ||
|
||
// Make escape close the dialogue. | ||
ouwiki_annotate.annotationdialog.cfg.setProperty('keylisteners', [new YAHOO.util.KeyListener( | ||
document, {keys:[27]}, function(types, args, obj) { ouwiki_annotate.annotationdialog.hide(); | ||
})]); | ||
|
||
// Make the form cancel button close the dialogue. | ||
YAHOO.util.Event.addListener('id_cancel', 'click', function(e) { | ||
ouwiki_annotate.annotationdialog.hide(); | ||
YAHOO.util.Event.preventDefault(e); | ||
}); | ||
|
||
// Nasty hack, remove once the YUI bug causing MDL-17594 is fixed. | ||
// https://sourceforge.net/tracker/index.php?func=detail&aid=2493426&group_id=165715&atid=836476 | ||
var elementcauseinglayoutproblem = document.getElementById('_yuiResizeMonitor'); | ||
if (elementcauseinglayoutproblem) { | ||
elementcauseinglayoutproblem.style.left = '0px'; | ||
} | ||
} | ||
|
||
function setupmarkers(marker, dialog) { | ||
marker.style.cursor = "pointer"; | ||
marker.tabIndex = "0"; | ||
marker.onkeydown = function(e) { | ||
var keycode = null; | ||
if(e){ | ||
keycode = e.which; | ||
} else if (window.event) { | ||
keycode = window.event.keyCode; | ||
} | ||
if(keycode == 13 || keycode == 32){ | ||
// call the function that handles adding an annotation | ||
openNewWindow(marker, dialog); | ||
return false; | ||
} | ||
}; | ||
|
||
marker.onclick = function() { | ||
openNewWindow(marker, dialog); | ||
return false; | ||
}; | ||
} | ||
|
||
function openNewWindow(marker,mydialog1) { | ||
currentMarker = marker.id; | ||
mydialog1.show(); | ||
} | ||
|
||
function newAnnotation(newtext) { | ||
// we need the number of the next form textarea | ||
var annotationcount = document.getElementById('annotationcount'); | ||
var annotationnum = parseInt(annotationcount.firstChild.nodeValue) + 1; | ||
|
||
//create the new form section | ||
var newfitem = document.createElement('div'); | ||
newfitem.id = 'newfitem'+annotationnum; | ||
newfitem.className = 'fitem'; | ||
newfitem.style.display = 'none'; | ||
|
||
var fitemtitle = document.createElement('div'); | ||
fitemtitle.className = 'fitemtitle'; | ||
|
||
var fitemlabel = document.createElement('label'); | ||
fitemlabel.htmlFor = 'id_annotationedit' + annotationnum; | ||
//create a textnode and add it to the label | ||
var fitemlabeltext = document.createTextNode(annotationnum); | ||
fitemlabel.appendChild(fitemlabeltext); | ||
// append the label to the div | ||
fitemtitle.appendChild(fitemlabel); | ||
|
||
//create the div for the textarea | ||
var felement = document.createElement('div'); | ||
felement.className = 'felement ftextarea'; | ||
|
||
var textareatext = document.createTextNode(newtext); | ||
var felementtextarea = document.createElement('textarea'); | ||
felementtextarea.id = 'id_annotationedit' + annotationnum; | ||
felementtextarea.name = 'new'+currentMarker.substring(6); | ||
// we need the textare size set in the moodle form rather than setting explicitly here | ||
//var textareas = YAHOO.util.Dom.getElementsByClassName('felement ftextarea', 'div'); | ||
felementtextarea.rows = '3'; | ||
felementtextarea.cols = '40'; | ||
felementtextarea.appendChild(textareatext); | ||
felement.appendChild(felementtextarea); | ||
|
||
newfitem.appendChild(fitemtitle); | ||
newfitem.appendChild(felement); | ||
|
||
// insert the new fitem before the last fitem (which is the delete orphaned checkbox) | ||
var fcontainer = YAHOO.util.Dom.getElementsByClassName('fcontainer', 'div'); | ||
var checkbox = YAHOO.util.Dom.getElementsByClassName('felement fcheckbox', 'div'); | ||
fcontainer[0].insertBefore(newfitem, checkbox[0].parentNode); | ||
|
||
markNewAnnotation(annotationnum); | ||
|
||
newfitem.style.display = 'block'; | ||
annotationcount.firstChild.nodeValue = annotationnum; | ||
} | ||
|
||
function markNewAnnotation(annotationnum) { | ||
var theMarker = document.getElementById(currentMarker); | ||
var visualmarker = document.createElement('strong'); | ||
var visualtext = document.createTextNode('('+annotationnum+')'); | ||
visualmarker.appendChild(visualtext); | ||
theMarker.parentNode.insertBefore(visualmarker, theMarker); | ||
theMarker.parentNode.removeChild(theMarker); | ||
} | ||
|
||
function ouwiki_yui_workaround(e) { | ||
// YUI does not send the button pressed with the form submission, so copy | ||
// the button name to a hidden input. | ||
var submitbutton = YAHOO.util.Event.getTarget(e); | ||
var input = document.createElement('input'); | ||
input.type = 'hidden'; | ||
input.name = submitbutton.name; | ||
input.value = 1; | ||
submitbutton.form.appendChild(input); | ||
} | ||
|
Oops, something went wrong.