Global

Members

(constant) byCategory

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Emoji data based on the data available from https://github.com/iamcal/emoji-data.

(constant) clearSearch

Source:

Reset the search icon and trigger the init for the block.

endTime

Source:
Properties:
Name Type Description
endTime Number

Timestamp at which time runs out.

(constant) init

Source:

Initialise all of the modules for the overview block.

(constant) init

Source:

Initialise the timeline view navigation by adding event listeners to the navigation elements.

(constant) init

Source:

Intialise the courses list and cards views on page load.

(constant) init

Source:

Initialize module

isEditing

Source:

Return the current edit mode.

Components should use this method to check if edit mode is active.

locked

Source:

Set the lock value and locks or unlocks the element.

locked

Source:

Get the current locked value from the element.

prepare

Source:

Prepares to begin a drag operation - call with a mousedown or touchstart event.

If the returned object has 'start' true, then you can set up a drag proxy, and call start. This function will call preventDefault automatically regardless of whether starting or not.

(constant) reset

Source:

Reset the courses views to their original state on first page load.courseOffset

This is called when configuration has changed for the event lists to cause them to reload their data.

start

Source:

Starts automatic scrolling if user moves near edge of window. This should be called in response to mouse down or touch start.

start

Source:

Call to start a drag operation, in response to a mouse down or touch start event. Normally call this after calling prepare and receiving start true (you can probably skip prepare if only supporting drag not touch).

Note: The caller is responsible for creating a 'drag proxy' which is the thing that actually gets dragged. At present, this doesn't really work properly unless it is added directly within the body tag.

You also need to ensure that there is CSS so the proxy is absolutely positioned, and styled to look like it is floating.

You also need to absolutely position the proxy where you want it to start.

state

Source:

Return the current state.

stop

Source:

Stops automatic scrolling. This should be called in response to mouse up or touch end.

StorageWrapper :Object

Source:

Wraps browsers localStorage object

Type:
  • Object

supportComponents

Source:

Return if the current course support components to refresh the content.

timeoutId

Source:
Properties:
Name Type Description
timeoutId Number

ID of the timeout that updates the clock.

timer

Source:
Properties:
Name Type Description
timer Element

The timer element.

Methods

_activityAnchor(event)

Source:

The activity anchor event.

Parameters:
Name Type Description
event Event

_addEventTotalMovement(event)

Source:

Add the total amout of movement to a mouse event.

Parameters:
Name Type Description
event MouseEvent

_allSectionToggler(event)

Source:

Handle the collapse/expand all sections button.

Toggler click is delegated to the main course content element because new sections can appear at any moment and this way we prevent accidental double bindings.

Parameters:
Name Type Description
event Event

the triggered event

_callEditWebservice(action, courseId, ids, targetSectionId, targetCmId)

Source:

Private method to call core_courseformat_update_course webservice.

Parameters:
Name Type Description
action string
courseId number
ids array
targetSectionId number

optional target section id (for moving actions)

targetCmId number

optional target cm id (for moving actions)

_callParentMethod(methodname, dropdata, event)

Source:

Convenient method for calling parent component functions if present.

Parameters:
Name Type Description
methodname string

the name of the method

dropdata Object

the current drop data object

event Event

the original event

_checkSectionlist(detail)

Source:

Check the section list and disable some options if needed.

Parameters:
Name Type Description
detail Object

the update details.

Properties
Name Type Description
state Object

the state object.

_completionHandler(event)

Source:

Activity manual completion listener.

Parameters:
Name Type Description
event Event

the custom ecent

_completionHandler(event)

Source:

Activity manual completion listener.

Parameters:
Name Type Description
event Event

the custom event

Properties
Name Type Description
detail object

the event details

_containsOnlyFiles(event) → {boolean}

Source:

Check if the dragged event contains only files.

Files dragging does not generate drop data because they came from outside the page and the component must check it before validating the event.

Parameters:
Name Type Description
event Event

the original event.

Returns:

if the drag dataTransfers contains files.

Type
boolean

(async) _createCm(param)

Source:

Create a newcm instance.

Parameters:
Name Type Description
param object
Properties
Name Type Description
state Object
element Object

_createCmItem(container, cmid) → {Element}

Source:

Create a new course module item in a section.

Thos method will append a fake item in the container and trigger an ajax request to replace the fake element by the real content.

Parameters:
Name Type Description
container Element

the container element (section)

cmid Number

the course-module ID

Returns:

the created element

Type
Element

(async) _createSection(details)

Source:

Create a new section instance.

Parameters:
Name Type Description
details Object

the update details.

Properties
Name Type Description
state Object

the state data.

element Object

the element data.

_createSectionItem(container, sectionid) → {Element}

Source:

Create a new section item.

This method will append a fake item in the container and trigger an ajax request to replace the fake element by the real content.

Parameters:
Name Type Description
container Element

the container element (section)

sectionid Number

the course-module ID

Returns:

the created element

Type
Element

_deleteCm(param)

Source:

Remove a cm from the list.

The actual DOM element removal is delegated to the cm component.

Parameters:
Name Type Description
param object
Properties
Name Type Description
element Object

_deleteSection(details)

Source:

Remove a section from the list.

The actual DOM element removal is delegated to the section component.

Parameters:
Name Type Description
details Object

the update details.

Properties
Name Type Description
element Object

the element data.

_destroyModal(modal, element)

Source:

Hide and later destroy a modal.

Behat will fail if we remove the modal while some boostrap collapse is executing.

Parameters:
Name Type Description
modal Modal
element HTMLElement

the dom element to focus on.

Source:

Replace an element with a copy with a different tag name.

Parameters:
Name Type Description
element Element

the original element

_dragEnd(event)

Source:

Drag end event handler.

Parameters:
Name Type Description
event Event

the event.

_dragEnter(event)

Source:

Drag enter event handler.

The JS drag&drop API triggers several dragenter events on the same element because it bubbles the child events as well. To prevent this form affecting the dropzones display, this methods use "entercount" to determine if it's one extra child event or a valid one.

Parameters:
Name Type Description
event Event

the event.

_dragLeave(event)

Source:

Drag over leave handler.

The JS drag&drop API triggers several dragleave events on the same element because it bubbles the child events as well. To prevent this form affecting the dropzones display, this methods use "entercount" to determine if it's one extra child event or a valid one.

Parameters:
Name Type Description
event Event

the event.

_dragOver(event)

Source:

Drag over event handler.

We only use dragover event when a draggable action starts inside a valid dropzone. In those cases the API won't trigger any dragEnter because the dragged alement was already there. We use the dropzonevisible to determine if the component needs to display the dropzones or not.

Parameters:
Name Type Description
event Event

the event.

_dragStart(event)

Source:

Drag start event handler.

This method will generate the current dropable data. This data is the one used to determine if a droparea accepts the dropping or not.

Parameters:
Name Type Description
event Event

the event.

_drop(event)

Source:

Drop event handler.

This method will call both hideDropZones and drop methods on the parent component.

Parameters:
Name Type Description
event Event

the event.

_expandSectionNode(element, forceValue)

Source:

Expand a section node.

By default the method will use element.indexcollapsed to decide if the section is opened or closed. However, using forceValue it is possible to open or close a section independant from the indexcollapsed attribute.

Parameters:
Name Type Description
element Object

the course module state element

forceValue boolean

optional forced expanded value

(async) _fixOrder(container, neworder, selector, dettachedelements, createMethod)

Source:

Fix/reorder the section or cms order.

Parameters:
Name Type Description
container Element

the HTML element to reorder.

neworder Array

an array with the ids order

selector string

the element selector

dettachedelements Object

a list of dettached elements

createMethod function

method to create missing elements

_fixOrder(container, neworder, allitems)

Source:

Fix/reorder the section or cms order.

Parameters:
Name Type Description
container Element

the HTML element to reorder.

neworder Array

an array with the ids order

allitems Array

the list of html elements that can be placed in the container

_getClosestActionMenuToogler(element) → {HTMLElement|undefined}

Source:

Get the closest actions menu toggler to an action element.

Parameters:
Name Type Description
element HTMLElement

the action link element

Returns:
Type
HTMLElement | undefined

_getDraggableData() → {Object}

Source:

Get the draggable data of this component.

Returns:

exported course module drop data

Type
Object

_getDropData(event) → {Object|undefined}

Source:

Get the current dropdata for a specific event.

The browser can generate drag&drop events related to several user interactions:

  • Drag a page elements: this case is registered in the activeDropData map
  • Drag some HTML selections: ignored for now
  • Drag a file over the browser: file drag may appear in the future but for now they are ignored.
Parameters:
Name Type Description
event Event

the original event.

Returns:

with the dragged data (or undefined if none)

Type
Object | undefined

_indexContents()

Source:

Regenerate content indexes.

This method is used when a legacy action refresh some content element.

_modalBodyRenderedPromise(modalParams) → {Promise}

Source:

Render a modal and return a body ready promise.

Parameters:
Name Type Description
modalParams object

the modal params

Returns:

the modal body ready promise

Type
Promise

_prepareFields(stateManager, updateName, fields) → {Object}

Source:

Add default values to state elements.

This method is called every time a webservice returns a update state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

Returns:

final fields data

Type
Object

_processEvent(event) → {Object|false}

Source:

Process a drag and drop event and delegate logic to the parent component.

Parameters:
Name Type Description
event Event

the drag and drop event

Returns:

the dropdata or null if the event should not be processed

Type
Object | false

_publishEvents()

Source:

Internal method to publish events.

This is a private method, it will be invoked when the state is set back to read only mode.

_refreshAllSectionsToggler(state)

Source:

Refresh the collapse/expand all sections element.

Parameters:
Name Type Description
state Object

The state data

_refreshCm(param)

Source:

Update a course index cm using the state information.

Parameters:
Name Type Description
param object
Properties
Name Type Description
element Object

details the update details.

_refreshCm(param)

Source:

Update a course index cm using the state information.

Parameters:
Name Type Description
param object
Properties
Name Type Description
element Object

details the update details.

(async) _refreshCompletion(details)

Source:

Update the activity completion icon.

Parameters:
Name Type Description
details Object

the update details

Properties
Name Type Description
state Object

the state data

element Object

the element data

_refreshCourseSectionlist(param)

Source:

Refresh the section list.

Parameters:
Name Type Description
param Object
Properties
Name Type Description
element Object

details the update details.

_refreshCourseSectionlist(param)

Source:

Refresh the section list.

Parameters:
Name Type Description
param object
Properties
Name Type Description
element Object

_refreshPageItem(details)

Source:

Handle a page item update.

Parameters:
Name Type Description
details Object

the update details

Properties
Name Type Description
element Object

the course state data.

_refreshPageItem(details)

Source:

Handle a page item update.

Parameters:
Name Type Description
details Object

the update details

Properties
Name Type Description
state Object

the state data.

element Object

the course state data.

_refreshPageItem(details)

Source:

Handle a page item update.

Parameters:
Name Type Description
details Object

the update details

Properties
Name Type Description
state Object

the state data.

element Object

the course state data.

_refreshSection(param)

Source:

Update a course index section using the state information.

Parameters:
Name Type Description
param object
Properties
Name Type Description
element Object

details the update details.

_refreshSection(param)

Source:

Update a course index section using the state information.

Parameters:
Name Type Description
param Object

details the update details.

Properties
Name Type Description
element Object

the section element

_refreshSectionCmlist(param)

Source:

Refresh a section cm list.

Parameters:
Name Type Description
param Object
Properties
Name Type Description
element Object

details the update details.

_refreshSectionCmlist(param)

Source:

Refresh a section cm list.

Parameters:
Name Type Description
param object
Properties
Name Type Description
element Object

_refreshSectionCollapsed(args)

Source:

Update section collapsed.

Parameters:
Name Type Description
args object
Properties
Name Type Description
state Object

The state data

element Object

The element to update

_refreshSectionCollapsed(args)

Source:

Update section collapsed.

Parameters:
Name Type Description
args object
Properties
Name Type Description
element object

The leement to be expanded

_refreshSectionNumber(param)

Source:

Update a course section when the section number changes.

The courseActions module used for most course section tools still depends on css classes and section numbers (not id). To prevent inconsistencies when a section is moved, we need to refresh the

Course formats can override the section title rendering so the frontend depends heavily on backend rendering. Luckily in edit mode we can trigger a title update using the inplace_editable module.

Parameters:
Name Type Description
param Object
Properties
Name Type Description
element Object

details the update details.

_reloadCm(param0)

Source:

Reload a course module contents.

Most course module HTML is still strongly backend dependant. Some changes require to get a new version of the module.

Parameters:
Name Type Description
param0 object

the watcher details

Properties
Name Type Description
element object

the state object

_reloadSection(param0)

Source:

Reload a course section contents.

Section HTML is still strongly backend dependant. Some changes require to get a new version of the section.

Parameters:
Name Type Description
param0 details

the watcher details

Properties
Name Type Description
element object

the state object

(async) _requestAddSection(target, event)

Source:

Handle a create section request.

Parameters:
Name Type Description
target Element

the dispatch action element

event Event

the triggered event

(async) _requestDeleteSection(target, event)

Source:

Handle a delete section request.

Parameters:
Name Type Description
target Element

the dispatch action element

event Event

the triggered event

(async) _requestMoveCm(target, event)

Source:

Handle a move cm request.

Parameters:
Name Type Description
target Element

the dispatch action element

event Event

the triggered event

(async) _requestMoveSection(target, event)

Source:

Handle a move section request.

Parameters:
Name Type Description
target Element

the dispatch action element

event Event

the triggered event

_scanIndex(selector, index, creationhandler)

Source:

Reindex a content (section or cm) of the course content.

This method is used internally by _indexContents.

Parameters:
Name Type Description
selector string

the DOM selector to scan

index *

the index attribute to update

creationhandler *

method to create a new indexed element

_scrollHandler()

Source:

Check the current page scroll and update the active element if necessary.

_sectionTogglers(event)

Source:

Setup sections toggler.

Toggler click is delegated to the main course content element because new sections can appear at any moment and this way we prevent accidental double bindings.

Parameters:
Name Type Description
event Event

the triggered event

_sectionTogglers(event)

Source:

Setup sections toggler.

Toggler click is delegated to the main course index element because new sections can appear at any moment and this way we prevent accidental double bindings.

Parameters:
Name Type Description
event Event

the triggered event

_setAddSectionLocked(locked)

Source:

Disable all add sections actions.

Parameters:
Name Type Description
locked boolean

the new locked value.

_startProcessing()

Source:

Setup the component to start a transaction.

Some of the course actions replaces the current DOM element with a new one before updating the course state. This means the component cannot preload any index properly until the transaction starts.

_updateStateSectionPreference(stateManager, preferenceName, sectionIds, preferenceValue) → {array}

Source:

Private batch update for a section preference attribute.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

preferenceName string

the preference name

sectionIds array

the affected section ids

preferenceValue boolean

the new preferenceValue value

Returns:

the list of all sections with that preference set to true

Type
array

accessibilityHide()

Source:

Restores the aria visibility on the DOM elements changed when displaying the dialogue popup and makes the dialogue aria hidden to allow screen readers to navigate the main page correctly when the dialogue is closed.

accessibilityShow()

Source:

Sets the appropriate aria attributes on this dialogue and the other elements in the DOM to ensure that screen readers are able to navigate the dialogue popup correctly.

activeSearch(clearIcon)

Source:

Change the searching icon to its' active state.

Parameters:
Name Type Description
clearIcon HTMLElement

Our closing icon to manipulate.

addEventListener(target, type, listener)

Source:

Add and bind an event listener to a target and keep track of all event listeners.

The native element.addEventListener method is not object oriented friently as the "this" represents the element that triggers the event and not the listener class. As components can be unregister and removed at any time, the BaseComponent provides this method to keep track of all component listeners and do all of the bind stuff.

Parameters:
Name Type Description
target Element

the event target

type string

the event name

listener function

the class method that recieve the event

addIconToContainer(container) → {Promise}

Source:

Add a loading icon to the end of the specified container and return an unresolved promise.

Resolution of the returned promise causes the icon to be faded out and removed.

Parameters:
Name Type Description
container jQuery

The element to add the spinner to

Returns:

The Promise used to create the icon.

Type
Promise

addIconToContainerWithPromise(container, loadingIconPromise) → {jQuery}

Source:

Add a loading icon to the end of the specified container and return an unresolved promise.

Resolution of the returned promise causes the icon to be faded out and removed.

Parameters:
Name Type Description
container jQuery

The element to add the spinner to

loadingIconPromise Promise

The jQuery Promise which determines the removal of the icon

Returns:

The Promise used to create and then remove the icon.

Type
jQuery

addIconToContainerWithPromise(container) → {Promise}

Source:

Add a loading icon to the end of the specified container and return an unresolved promise.

Resolution of the returned promise causes the icon to be faded out and removed.

Parameters:
Name Type Description
container jQuery

The element to add the spinner to

Returns:

A jQuery Promise to resolve when ready

Type
Promise

addMutations(newFunctions)

Source:

Add individual functions to the mutations.

Note new mutations will be added to the existing ones. To replace the full mutation object with a new one, use setMutations method.

Parameters:
Name Type Description
newFunctions Object

an object with new mutation functions.

(async) addSection(stateManager, targetSectionId)

Source:

Add a new section to a specific course location.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

targetSectionId number

optional the target section id

addSelectors(newSelectors)

Source:

Add or update the component selectors.

Parameters:
Name Type Description
newSelectors Object

an object of new selectors.

addToFavourites(root, courseId)

Source:

Add course to favourites

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id number

addUpdateTypes(newFunctions)

Source:

Add methods to process update state messages.

The state manager provide a default update, create and delete methods. However, some applications may require to override the default methods or even add new ones like "refresh" or "error".

Parameters:
Name Type Description
newFunctions Object

the new update types functions.

allItemsArray(state) → {Array}

Source:

Return a sorted list of all sections and cms items in the state.

Parameters:
Name Type Description
state Object

the current state.

Returns:

all sections and cms items in the state.

Type
Array

asyncSet(value, setFunction) → {Promise}

Source:

Set or resolve and set the value using the function.

Parameters:
Name Type Description
value string | object

The string or jQuery promise.

setFunction function

The setter

Returns:
Type
Promise

attachToDOM()

Source:

Attach the modal to the correct part of the page.

If it hasn't already been added it runs any javascript that has been cached until now.

calculateZIndex() → {int}

Source:

Determine the highest z-index value currently on the page.

Returns:
Type
int

callWatchersHandler(event)

Source:

State changed listener.

This function take any state change and send it to the proper watchers.

To prevent internal state changes from colliding with other reactive instances, only the general "state changed" is triggered at document level. All the internal changes are triggered at private target level without bubbling. This way any reactive instance can alert only its own watchers.

Parameters:
Name Type Description
event CustomEvent

cm(state, cminfo) → {Object}

Source:

Generate a cm export data from the state.

Parameters:
Name Type Description
state Object

the current state.

cminfo Object

the course module state data.

Returns:
Type
Object

cmCompletion(state, cminfo) → {Object}

Source:

Generate a compoetion export data from the cm element.

Parameters:
Name Type Description
state Object

the current state.

cminfo Object

the course module state data.

Returns:
Type
Object

cmCompletion(stateManager, cmIds, complete)

Source:

Mark or unmark course modules as complete.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

cmIds array

the list of course modules ids

complete bool

the new completion value

cmDrag(stateManager, cmIds, dragValue)

Source:

Mark or unmark course modules as dragging.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

cmIds array

the list of course modules ids

dragValue bool

the new dragging value

cmDraggableData(state, cmid) → {Object|null}

Source:

Generate a dragable cm data structure.

This method is used by any draggable course module element to generate drop data for its reactive/dragdrop instance.

Parameters:
Name Type Description
state *

the state object

cmid *

the cours emodule id

Returns:
Type
Object | null

cmLock(stateManager, cmIds, lockValue)

Source:

Lock or unlock course modules.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

cmIds array

the list of course modules ids

lockValue bool

the new locked value

(async) cmMove(stateManager, cmids, targetSectionId, targetCmId)

Source:

Move course modules to specific course location.

Note that one of targetSectionId or targetCmId should be provided in order to identify the new location:

  • targetCmId: the activities will be located avobe the target cm. The targetSectionId value will be ignored in this case.
  • targetSectionId: the activities will be appended to the section. In this case targetSectionId should not be present.
Parameters:
Name Type Description
stateManager StateManager

the current state manager

cmids array

the list of cm ids to move

targetSectionId number

the target section id

targetCmId number

the target course module id

cmState(stateManager, cmids)

Source:

Get updated state data related to some cm ids.

Parameters:
Name Type Description
stateManager StateManager

the current state

cmids array

the list of cm ids to update

collapseGroup(item)

Source:

Collpase a group item.

Parameters:
Name Type Description
item JQuery

the jQuery object

configDragDrop(cmid)

Source:

Configure the component drag and drop.

Parameters:
Name Type Description
cmid number

course module id

configDragDrop(sectionitem)

Source:

Register state values and the drag and drop subcomponent.

Parameters:
Name Type Description
sectionitem BaseComponent

section item component

configDragDrop(sectionid, state, fullregion)

Source:

Initial state ready method.

Parameters:
Name Type Description
sectionid number

the section id

state Object

the initial state

fullregion Element

the complete section region to mark as dragged

configState(state)

Source:

Save some values form the state.

Parameters:
Name Type Description
state Object

the current state

count(args) → {Promise}

Source:

Get a count of LTI tool types and tool proxies from Moodle for the given search args.

See also: mod/lti/classes/external.php get_tool_types_and_proxies_count()

Parameters:
Name Type Description
args Object

Search parameters

Returns:

Promise that will be resolved when the ajax call returns.

Type
Promise

countOtherVisibleModals() → {int}

Source:

Count the number of other visible modals (not including this one).

Returns:
Type
int

course(state) → {Object}

Source:

Generate the course export data from the state.

Parameters:
Name Type Description
state Object

the current state.

Returns:
Type
Object

(async) courseState(stateManager)

Source:

Get the full updated state data of the course.

Parameters:
Name Type Description
stateManager StateManager

the current state

create(descriptor)

Source:

Component create function.

Default init method will call "create" when all internal attributes are set but before the component is not yet registered in the reactive module.

In this method any component can define its own defaults such as:

  • this.selectors {object} the default query selectors of this component.
  • this.events {object} a list of event names this component dispatch
  • extract any data from the main dom element (this.element)
  • set any other data the component uses
Parameters:
Name Type Description
descriptor descriptor

the component descriptor

create(parent)

Source:

Constructor hook.

Parameters:
Name Type Description
parent BaseComponent

the parent component.

create(descriptor)

Source:

Constructor hook.

Parameters:
Name Type Description
descriptor Object

the component descriptor

create()

Source:

Constructor hook.

create()

Source:

Constructor hook.

create()

Source:

Constructor hook.

create()

Source:

Constructor hook.

create(descriptor)

Source:

Constructor hook.

Parameters:
Name Type Description
descriptor Object

create()

Source:

Constructor hook.

create()

Source:

Constructor hook.

create()

Source:

Constructor hook.

create()

Source:

Component creation hook.

create()

Source:

Constructor hook.

create(descriptor)

Source:

Constructor hook.

Parameters:
Name Type Description
descriptor Object

defaultCreate(stateManager, updateName, fields)

Source:

Process a create state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

defaultDelete(stateManager, updateName, fields)

Source:

Process a delete state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

defaultOverride(stateManager, updateName, fields)

Source:

Process an override state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

defaultPrepareFields(stateManager, updateName, fields) → {Object}

Source:

Prepare fields for processing.

This method is used to add default values or calculations from the frontend side.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

Returns:

final fields data

Type
Object

defaultPut(stateManager, updateName, fields)

Source:

Process a put state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

defaultRemove(stateManager, updateName, fields)

Source:

Process a remove state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

defaultUpdate(stateManager, updateName, fields)

Source:

Process a update state message.

Parameters:
Name Type Description
stateManager Object

the state manager

updateName String

the state element to update

fields Object

the new data

destroy()

Source:

Remove this modal from the DOM.

destroy()

Source:

Component destroy hook.

BaseComponent call this method when a component is unregistered or removed.

Components may override this method to clean the HTML or do some action when the component is unregistered or removed.

destroy()

Source:

Remove all subcomponents dependencies.

destroy()

Source:

Remove all subcomponents dependencies.

destroy()

Source:

Remove all subcomponents dependencies.

dispatch(actionName, params)

Source:

Dispatch a change in the state.

This method is the only way for components to alter the state. Watchers will receive a read only state to prevent illegal changes. If some user action require a state change, the component should dispatch a mutation to trigger all the necessary logic to alter the state.

Parameters:
Name Type Description
actionName string

the action name (usually the mutation name)

params mixed

any number of params the mutation needs.

dispatch(args)

Source:

Dispatch a change in the state.

Usually reactive modules throw an error directly to the components when something goes wrong. However, course editor can directly display a notification.

Parameters:
Name Type Description
args mixed

any number of params the mutation needs.

dispatchRegistrationFail()

Source:

Dispatch a component registration fail event to inform the parent node.

As dispatchRegistrationSuccess, this method will communicate the registration fail to the parent node to inform the possible parent component.

dispatchRegistrationSuccess()

Source:

Dispatch a component registration event to inform the parent node.

The registration event is different from the rest of the component events because is the only way in which components can communicate its existence to a possible parent. Most components will be created by including a mustache file, child components must emit a registration event to the parent DOM element to alert about the registration.

dragEnd(dropdata)

Source:

The element drop end hook.

Parameters:
Name Type Description
dropdata Object

the dropdata

dragEnd(dropdata)

Source:

The element drop end hook.

Parameters:
Name Type Description
dropdata Object

the dropdata

dragEnd(dropdata)

Source:

The element end start hook.

Parameters:
Name Type Description
dropdata Object

the dropdata

dragStart(dropdata)

Source:

The element drop start hook.

Parameters:
Name Type Description
dropdata Object

the dropdata

dragStart(dropdata)

Source:

The element drop start hook.

Parameters:
Name Type Description
dropdata Object

the dropdata

dragStart(dropdata)

Source:

The element drop start hook.

Parameters:
Name Type Description
dropdata Object

the dropdata

drop(dropdata)

Source:

Drop event handler.

Parameters:
Name Type Description
dropdata Object

the accepted drop data

drop(dropdata)

Source:

Drop event handler.

Parameters:
Name Type Description
dropdata Object

the accepted drop data

drop(dropdata)

Source:

Drop event handler.

Parameters:
Name Type Description
dropdata Object

the accepted drop data

enterCallback(jQueryItem)

Source:

Handle enter key on a collpasible node.

Parameters:
Name Type Description
jQueryItem JQuery

the jQuery object

expandAllGroups()

Source:

Expand all groups.

expandGroup(item)

Source:

Expand a group item.

Parameters:
Name Type Description
item JQuery

the jQuery object

formatSeconds(secs) → {String}

Source:

Helper method to convert time remaining in seconds into HH:MM:SS format.

Parameters:
Name Type Description
secs Number

Time remaining in seconds to get value for.

Returns:

Time remaining in HH:MM:SS format.

Type
String

get(key) → {boolean|string}

Source:

Get a value from local storage. Remember - all values must be strings.

Parameters:
Name Type Description
key string

The cache key to check.

Returns:

False if the value is not in the cache, or some other error - a string otherwise.

Type
boolean | string

get(type) → {object}

Source:

Get a registered type of modal.

Parameters:
Name Type Description
type string

The type of modal to get

Returns:

The registered config for the modal

Type
object

get(name, id) → {Object|undefined}

Source:

Get state data.

Components access the state frequently. This convenience method is a shortcut to this.reactive.state.stateManager.get() method.

Parameters:
Name Type Description
name String

the state object name

id *

an optional object id for state maps.

Returns:

the state object found

Type
Object | undefined

get(name, id) → {Object|undefined}

Source:

Get an element from the state or form an alternative state object.

The altstate param is used by external update functions that gets the current state as param.

Parameters:
Name Type Description
name String

the state object name

id *

and object id for state maps.

Returns:

the state object found

Type
Object | undefined

getActiveItem() → {Element|undefined}

Source:

Return the current active node.

Returns:

the active item if any

Type
Element | undefined

getAddFavouriteMenuItem(root, courseId) → {Object}

Source:

Get the action menu item

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id.

Returns:

The add to favourite menu item.

Type
Object

getBackdrop() → {object}

Source:

Get the modal backdrop.

Returns:

jQuery promise

Type
object

getBody() → {object}

Source:

Get the modal body element.

Returns:

jQuery object

Type
object

getBodyPromise() → {object}

Source:

Get a promise resolving to the body region.

Returns:

jQuery object

Type
object

getClasses() → {Object}

Source:

Return the component drag and drop CSS classes.

Returns:

the dragdrop css classes

Type
Object

getColumnOrder(listRoot) → {Array}

Source:

Gets the newly reordered columns to display in the question bank view.

Parameters:
Name Type Description
listRoot Element
Returns:
Type
Array

getContent() → {object}

Source:

Return the jQuery element with the content. This will return either the unread notification container or the all notification container depending on which is currently visible.

Returns:

jQuery object currently visible content contianer

Type
object

getCourseId(root) → {Number}

Source:

Get the course id from a favourite element.

Parameters:
Name Type Description
root Object

The favourite icon container element.

Returns:

Course id.

Type
Number

getDraggableData() → {Object}

Source:

Get the draggable data of this component.

Returns:

exported course module drop data

Type
Object

getElementLocked(target) → {boolean}

Source:

Get the current locked value from the element.

Parameters:
Name Type Description
target Element

the event target

Returns:
Type
boolean

getElements(query, dataId) → {NodeList}

Source:

Get the all subelement that match a query selector.

Parameters:
Name Type Description
query string | undefined

optional subelement query

dataId string | undefined

optional data-id value

Returns:

the DOM elements

Type
NodeList

getEvents() → {Object}

Source:

Return the component custom event names.

Components may override this method to provide their own events.

Component custom events is an important part of component reusability. This function is static because is part of the component definition and should be accessible from outsite the instances. However, values will be available at instance level in the this.events object.

Returns:

the component events.

Type
Object

getExporter() → {Exporter}

Source:

Return a data exporter to transform state part into mustache contexts.

Returns:

the exporter class

Type
Exporter

getFavouriteIconContainer(root, courseId) → {Object}

Source:

Get the container element for the favourite icon.

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id number

Returns:

The favourite icon container

Type
Object

getFilterValues(root) → {filters}

Source:

Get filter values from DOM.

Parameters:
Name Type Description
root object

The root element for the courses view.

Returns:

Set filters.

Type
filters

getFooter() → {object}

Source:

Get the modal footer element.

Returns:

jQuery object

Type
object

getFooterPromise() → {object}

Source:

Get a promise resolving to the footer region.

Returns:

jQuery object

Type
object

getHideCourseMenuItem(root, courseId) → {Object}

Source:

Get the action menu item

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id.

Returns:

The hide course menu item.

Type
Object

getInitialPromise() → {Promise}

Source:

Generate a promise that will be resolved when the initial state is loaded.

In most cases the final state will be loaded using an ajax call. This is the reason why states manager are created unlocked and won't be reactive until the initial state is set.

Returns:

the resulting promise

Type
Promise

getLastCm() → {element|null}

Source:

Get the last CM element of that section.

Returns:
Type
element | null

getLastCm() → {element|null}

Source:

Get the last CM element of that section.

Returns:

the las course module element of the section.

Type
element | null

getLastCm() → {element|null}

Source:

Get the last CM element of that section.

Returns:
Type
element | null

getModal() → {object}

Source:

Get the modal element of this modal.

Returns:

jQuery object

Type
object

getModalCount() → {int}

Source:

Get the unique modal count.

Returns:
Type
int

getMyCourses(filters, limit) → {promise}

Source:

Get enrolled courses from backend.

Parameters:
Name Type Description
filters object

The filters for this view.

limit int

The number of courses to show.

Returns:

Resolved with an array of courses.

Type
promise

getNotificationElement(id) → {object|null}

Source:

Find the notification element for the given id.

Parameters:
Name Type Description
id int
Returns:

The notification element

Type
object | null

getOffset() → {int}

Source:

Get the offset value for the current state of the popover in order to sent to the backend to correctly paginate the notifications.

Returns:

current offset

Type
int

getPagedContentContainer(root, index) → {Object}

Source:

Get the paged content container element.

Parameters:
Name Type Description
root Object

The course overview container

index Number

Rendered page index.

Returns:

The rendered paged container.

Type
Object

getRemoveFavouriteMenuItem(root, courseId) → {Object}

Source:

Get the action menu item

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id.

Returns:

The remove from favourites menu item.

Type
Object

getRoot() → {object}

Source:

Get the root element of this modal.

Returns:

jQuery object

Type
object

getSearchMyCourses(filters, limit, searchValue) → {promise}

Source:

Search for enrolled courses from backend.

Parameters:
Name Type Description
filters object

The filters for this view.

limit int

The number of courses to show.

searchValue string

What does the user want to search within their courses.

Returns:

Resolved with an array of courses.

Type
promise

getSelector(selectorName) → {string|undefined}

Source:

Return a component selector.

Parameters:
Name Type Description
selectorName string

the selector name

Returns:

the query selector

Type
string | undefined

(async) getServerCourseState() → {Object}

Source:

Load the current course state from the server.

Returns:

the current course state

Type
Object

getShowCourseMenuItem(root, courseId) → {Object}

Source:

Get the action menu item

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id.

Returns:

The show course menu item.

Type
Object

getState() → {Promise}

Source:

Return the initial state promise.

Typically, components do not require to use this promise because registerComponent will trigger their stateReady method automatically. But it could be useful for complex components that require to combine state, template and string loadings.

Returns:
Type
Promise

getStorageValue(key) → {boolean|string}

Source:

Get a value from the course editor static storage if any.

The course editor static storage uses the sessionStorage to store values from the components. This is used to prevent unnecesary template loadings on every page. However, the storage does not work if no sessionStorage can be used (in debug mode for example), if the page is in editing mode or if the initial state change from the last page.

Parameters:
Name Type Description
key string

the key to get

Returns:

the storage value or false if cannot be loaded

Type
boolean | string

getTitle() → {object}

Source:

Get the modal title element.

Returns:

jQuery object

Type
object

getTitlePromise() → {Promise}

Source:

Get a promise resolving to the title region.

Returns:
Type
Promise

getWatchers() → {array}

Source:

Return the list of watchers that component has.

Each watcher is represented by an object with two attributes:

  • watch (string) the specific state event to watch. Example 'section.visible:updated'
  • handler (function) the function to call when the watching state change happens

Any component shoudl override this method to define their state watchers.

Returns:

array of watchers.

Type
array

getWatchers() → {Array}

Source:

Return the component watchers.

Returns:

of watchers

Type
Array

getWatchers() → {Array}

Source:

Return the component watchers.

Returns:

of watchers

Type
Array

getWatchers() → {Array}

Source:

Component watchers.

Returns:

of watchers

Type
Array

getWatchers() → {Array}

Source:

Component watchers.

Returns:

of watchers

Type
Array

getWatchers() → {Array}

Source:

Component watchers.

Returns:

of watchers

Type
Array

getWatchers() → {Array}

Source:

Component watchers.

Returns:

of watchers

Type
Array

handleItemClick(event, jQueryItem)

Source:

Handle an item click.

Parameters:
Name Type Description
event Event

the click event

jQueryItem jQuery

the item clicked

hasDoneInitialLoad() → {bool}

Source:

Check if the first load of notification has been triggered for the current state of the popover.

Returns:

true if first notification loaded, false otherwise

Type
bool

hasFocus() → {bool}

Source:

Check if this modal has focus.

Returns:
Type
bool

hasFooterContent() → {bool}

Source:

Check if the footer has any content in it.

Returns:
Type
bool

hasLoadedAllContent() → {bool}

Source:

Check if we've loaded all of the notifications for the current popover state.

Returns:

true if all notifications loaded, false otherwise

Type
bool

hasTransitions() → {bool}

Source:

Check if this modal has CSS transitions applied.

Returns:
Type
bool

hide()

Source:

Hide this modal.

hideCourse(root, courseId)

Source:

Hide course

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id number

hideDropZone()

Source:

Hide the component dropzone.

hideDropZone()

Source:

Hide the component dropzone.

hideDropZone()

Source:

Hide the component dropzone.

hideElement(root, id)

Source:

Reset the loadedPages dataset to take into account the hidden element

Parameters:
Name Type Description
root Object

The course overview container

id Number

The course id number

hideFavouriteIcon(root, courseId)

Source:

Hide the favourite icon.

Parameters:
Name Type Description
root Object

The favourite icon container element.

courseId Number

Course id number.

hideFooter()

Source:

Hide the footer element.

hideIfNotForm()

Source:

Hide this modal if it does not contain a form.

hideUnreadCount()

Source:

Hide the unread notification count badge on the menu toggle.

incrementOffset()

Source:

Increment the offset for the current state, if required.

init()

Source:

Initialize the page.

init(timerId)

Source:

Set up the submission timer.

Parameters:
Name Type Description
timerId Number

Unique ID of the timer element.

initializePagedContent(root, promiseFunction, inputValue)

Source:

Initialise the courses list and cards views on page load.

Parameters:
Name Type Default Description
root object

The root element for the courses view.

promiseFunction function

How do we fetch the courses and what do we do with them?

inputValue null | string null

What to search for

isGroupCollapsed(jQueryItem) → {boolean}

Source:

Check if a gorup item is collapsed.

Parameters:
Name Type Description
jQueryItem JQuery

the jQuery object

Returns:

if the element is collapsed

Type
boolean

isLarge() → {bool}

Source:

Check if the modal is a large modal.

Returns:
Type
bool

isSmall() → {bool}

Source:

Check if the modal is a small modal.

Returns:
Type
bool

isVisible() → {bool}

Source:

Check if this modal is visible.

Returns:
Type
bool

itemsPerPageFunc(pagingLimit, root) → {Array.<Number>}

Source:

Figure out how many items are going to be allowed to be rendered in the block.

Parameters:
Name Type Description
pagingLimit Number

How many courses to display

root Object

The course overview container

Returns:

How many courses will be rendered

Type
Array.<Number>

(async) loadCourse(courseId, serverStateKey)

Source:

Set up the course editor when the page is ready.

The course can only be loaded once per instance. Otherwise an error is thrown.

The backend can inform the module of the current state key. This key changes every time some update in the course affect the current user state. Some examples are:

  • The course content has been edited
  • The user marks some activity as completed
  • The user collapses or uncollapses a section (it is stored as a user preference)
Parameters:
Name Type Description
courseId number

course id

serverStateKey string

the current backend course cache reference

loadMoreNotifications() → {object}

Source:

Send a request for more notifications from the server, if we aren't already loading some and haven't already loaded all of them.

Takes into account the current mode of the popover and will request only unread notifications if required.

All notifications are marked as read by the server when they are returned.

Returns:

jQuery promise that is resolved when notifications have been retrieved and added to the DOM

Type
object

loadStaticContent() → {boolean}

Source:

Load the course index from the session storage if any.

Returns:

true if the static version is loaded form the session

Type
boolean

(async) loadTemplateContent(state)

Source:

Load the course index template.

Parameters:
Name Type Description
state Object

the initial state

markAllAsRead() → {Promise}

Source:

Send a request to the server to mark all unread notifications as read and update the unread count and unread notification elements appropriately.

Returns:
Type
Promise

module:core/emoji/auto_complete(root, textArea, hasSuggestionCallback, selectCallback)

Source:

Initialise the emoji auto complete.

Parameters:
Name Type Description
root Element

The root container element for the auto complete

textArea Element

The text area element to monitor for auto complete

hasSuggestionCallback function

Callback for when there are auto-complete suggestions

selectCallback function

Callback for when the user selects an emoji

module:core/emoji/picker(root, selectCallback)

Source:

Initialise the emoji picker.

Parameters:
Name Type Description
root Element

The root element for the picker

selectCallback function

Callback for when the user selects an emoji

module:core/menu_navigation(elementRoot)

Source:

The initial entry point that a given module can pass a HTMLElement.

Parameters:
Name Type Description
elementRoot HTMLElement

The menu to add handlers upon.

module:core/moremenu(menu)

Source:

Initialise the more menus.

Parameters:
Name Type Description
menu HTMLElement

The navbar moremenu.

module:mod_forum/local/grades/local/grader/gradingpanel(component, context, gradingComponent, gradingSubtype, itemName) → {Object}

Source:

Get the grade panel setter and getter for the current component. This function dynamically pulls the relevant gradingpanel JS file defined in the grading method. We do this because we do not know until execution time what the grading type is and we do not want to import unused files.

Parameters:
Name Type Description
component String

The component being graded

context Number

The contextid of the thing being graded

gradingComponent String

The thing providing the grading type

gradingSubtype String

The subtype fo the grading component

itemName String

The name of the thing being graded

Returns:
Type
Object

module:mod_forum/local/grades/local/grader/user_picker(users, showUserCallback, preChangeUserCallback, currentUserIDopt) → {UserPicker}

Source:

Create a new user picker.

Parameters:
Name Type Attributes Description
users Array

The list of users

showUserCallback function

The function to call to show a specific user

preChangeUserCallback function

The fucntion to call to save the grade for the current user

currentUserID Number <optional>

The userid of the current user

Returns:
Type
UserPicker

noCoursesRender(root) → {promise}

Source:

Given there are no courses to render provide the rendered template.

Parameters:
Name Type Description
root object

The root element for the courses view.

Returns:

jQuery promise resolved after rendering is complete.

Type
promise

pageBuilder(coursesData, currentPage, pageData, actions, activeSearch)

Source:

Mutates and controls the loadedPages array and handles the bootstrapping.

Parameters:
Name Type Default Description
coursesData Array | Object

Array of all of the courses to start building the page from

currentPage Number

What page are we currently on?

pageData Object

Any current page information

actions Object

Paged content helper

activeSearch null | boolean null

Are we currently actively searching and building up search results?

processUpdate(updateName, action, fields, updateTypes)

Source:

Process a single state update.

Note this method will not lock or unlock the state by itself.

Parameters:
Name Type Description
updateName string

the state element to update

action string

to action to perform

fields object

the new data

updateTypes Object

optional functions to override the default update types.

processUpdates(updates, updateTypes)

Source:

Process a state updates array and do all the necessary changes.

Note this method unlocks the state while it is executing and relocks it when finishes.

Parameters:
Name Type Description
updates array
updateTypes Object

optional functions to override the default update types.

query(args) → {Promise}

Source:

Get a list of LTI tool types and tool proxies from Moodle for the given search args.

See also: mod/lti/classes/external.php get_tool_types_and_proxies()

Parameters:
Name Type Description
args Object

Search parameters

Returns:

Promise that will be resolved when the ajax call returns.

Type
Promise

register(type, module, template)

Source:

Register a modal with the registry.

Parameters:
Name Type Description
type string

The type of modal (must be unique)

module function

The modal module (must be a constructor function of type core/modal)

template string

The template name of the modal

registerChildComponent(component)

Source:

Register a child component into the reactive instance.

Parameters:
Name Type Description
component self

the component to register.

registerCloseOnCancel()

Source:

Register a listener to close the dialogue when the cancel button is pressed.

registerCloseOnSave()

Source:

Register a listener to close the dialogue when the save button is pressed.

registerComponent(component) → {object}

Source:

Register a new component.

Component can provide some optional functions to the reactive module:

  • getWatchers: returns an array of watchers
  • stateReady: a method to call when the initial state is loaded

It can also provide some optional attributes:

  • name: the component name (default value: "Unkown component") to customize debug messages.

The method will also use dispatchRegistrationSuccess and dispatchRegistrationFail. Those are BaseComponent methods to inform parent components of the registration status. Components should not override those methods.

Parameters:
Name Type Description
component object

the new component

Properties
Name Type Attributes Description
name string <optional>

the component name to display in warnings and errors.

dispatchRegistrationSuccess function <optional>

method to notify registration success

dispatchRegistrationFail function <optional>

method to notify registration fail

getWatchers function <optional>

getter of the component watchers

stateReady function <optional>

method to call when the state is ready

Returns:

the registered component

Type
object

registerEventListeners()

Source:

Set up all of the event handling for the modal.

registerEventListeners()

Source:

Register event listeners for the default_notification_preferences page.

registerEventListeners()

Source:

Add all of the required event listeners for this notification popover.

registerEventListeners(root, page)

Source:

Listen to, and handle events for the myoverview block.

Parameters:
Name Type Description
root Object

The myoverview block container element.

page HTMLElement

The whole HTMLElement for our block.

registerPagedEventHandlers(root, namespace)

Source:

Intialise the paged list and cards views on page load. Returns an array of paged contents that we would like to handle here

Parameters:
Name Type Description
root object

The root element for the courses view

namespace string

The namespace for all the events attached

registerSelector(root)

Source:

Event listener for the Display filter (cards, list).

Parameters:
Name Type Description
root object

The root element for the overview block

registerStateAction(field, prop, action, data)

Source:

Register a state modification and generate the necessary events.

This method is used mainly by proxy helpers to dispatch state change event. However, mutations can use it to inform components about non reactive changes in the state (only the two first levels of the state are reactive).

Each action can produce several events:

  • The specific attribute updated, created or deleter (example: "cm.visible:updated")
  • The general state object updated, created or deleted (example: "cm:updated")
  • If the element has an ID attribute, the specific event with id (example: "cm[42].visible:updated")
  • If the element has an ID attribute, the general event with id (example: "cm[42]:updated")
  • A generic state update event "state:update"
Parameters:
Name Type Description
field string

the affected state field name

prop string | null

the affecter field property (null if affect the full object)

action string

the action done (created/updated/deleted)

data *

the affected data

remove()

Source:

Remove a previously rendered component instance.

This method will remove the component HTML and unregister it from the reactive module.

removeAllEventListeners()

Source:

Remove all event listeners from this component.

This method is called also when the component is unregistered or removed.

Note that only listeners registered with the addEventListener method will be removed. Other manual listeners will keep active.

removeEventListener(target, type, listener)

Source:

Remove an event listener from a component.

This method allows components to remove listeners without keeping track of the listeners bind versions of the method. Both addEventListener and removeEventListener keeps internally the relation between the original class method and the bind one.

Parameters:
Name Type Description
target Element

the event target

type string

the event name

listener function

the class method that recieve the event

removeFromFavourites(root, courseId)

Source:

Remove course from favourites

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id number

renderComponent(target, file, data) → {Promise}

Source:

Render a new Component using a mustache file.

It is important to note that this method should NOT be used for loading regular mustache files as it returns a Promise that will only be resolved if the mustache registers a component instance.

Parameters:
Name Type Description
target element

the DOM element that contains the component

file string

the component mustache file to render

data *

the mustache data

Returns:

a promise of the resulting component instance

Type
Promise

renderCourses(root, coursesData) → {promise}

Source:

Render the dashboard courses.

Parameters:
Name Type Description
root object

The root element for the courses view.

coursesData array

containing array of returned courses.

Returns:

jQuery promise resolved after rendering is complete.

Type
promise

renderNotifications(notifications, container) → {object}

Source:

Render the notification data with the appropriate template and add it to the DOM.

Parameters:
Name Type Description
notifications array

Notification data

container object

jQuery object the container to append the rendered notifications

Returns:

jQuery promise that is resolved when all notifications have been rendered and added to the DOM

Type
object

renderUnreadCount()

Source:

Show the unread notification count badge on the menu toggle if there are unread notifications, otherwise hide it.

resetGlobals()

Source:

In cases when switching between regular rendering and search rendering we need to reset some variables.

searchFunctionalityCurry() → {function}

Source:

Initialize the searching functionality so we can call it when required.

Returns:
Type
function

section(state, sectioninfo) → {Object}

Source:

Generate a section export data from the state.

Parameters:
Name Type Description
state Object

the current state.

sectioninfo Object

the section state data.

Returns:
Type
Object

(async) sectionContentCollapsed(stateManager, sectionIds, collapsed)

Source:

Update the course content collapsed attribute of some sections.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

sectionIds array

the affected section ids

collapsed boolean

the new collapsed value

(async) sectionDelete(stateManager, sectionIds)

Source:

Delete sections.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

sectionIds array

the list of course modules ids

sectionDrag(stateManager, sectionIds, dragValue)

Source:

Mark or unmark course sections as dragging.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

sectionIds array

the list of section ids

dragValue bool

the new dragging value

sectionDraggableData(state, sectionid) → {Object|null}

Source:

Generate a dragable cm data structure.

This method is used by any draggable section element to generate drop data for its reactive/dragdrop instance.

Parameters:
Name Type Description
state *

the state object

sectionid *

the cours section id

Returns:
Type
Object | null

(async) sectionIndexCollapsed(stateManager, sectionIds, collapsed)

Source:

Update the course index collapsed attribute of some sections.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

sectionIds array

the affected section ids

collapsed boolean

the new collapsed value

sectionLock(stateManager, sectionIds, lockValue)

Source:

Lock or unlock course sections.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

sectionIds array

the list of section ids

lockValue bool

the new locked value

(async) sectionMove(stateManager, sectionIds, targetSectionId)

Source:

Move course modules to specific course location.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

sectionIds array

the list of section ids to move

targetSectionId number

the target section id

sectionState(stateManager, sectionIds)

Source:

Get updated state data related to some section ids.

Parameters:
Name Type Description
stateManager StateManager

the current state

sectionIds array

the list of section ids to update

set(key, value) → {boolean}

Source:

Set a value to local storage. Remember - all values must be strings.

Parameters:
Name Type Description
key string

The cache key to set.

value string

The value to set.

Returns:

False if the value can't be saved in the cache, or some other error - true otherwise.

Type
boolean

setBody(value)

Source:

Set the modal body element.

This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with HTML and Javascript most commonly from a Templates.render call.

Parameters:
Name Type Description
value string | object

The body string or jQuery promise which resolves to the body.

Fires:

setCourseFavouriteState(courseId, status) → {Promise}

Source:

Set the courses favourite status and push to repository

Parameters:
Name Type Description
courseId Number

Course id to favourite.

status boolean

new favourite status.

Returns:

Repository promise.

Type
Promise

setCourseHiddenState(courseId, status) → {Promise}

Source:

Set the courses hidden status and push to repository

Parameters:
Name Type Description
courseId Number

Course id to favourite.

status Boolean

new hidden status.

Returns:

Repository promise.

Type
Promise

setDraggable(value)

Source:

Enable or disable the draggable property.

Parameters:
Name Type Description
value bool

the new draggable value

setElementLocked(target, locked)

Source:

Lock/unlock an element.

Parameters:
Name Type Description
target Element

the event target

locked boolean

the new locked value

setFooter(value)

Source:

Set the modal footer element. The footer element is made visible, if it isn't already.

This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with HTML and Javascript most commonly from a Templates.render call.

Parameters:
Name Type Description
value string | object

The footer string or jQuery promise

setInitialState(stateData)

Source:

Set the initial state.

Parameters:
Name Type Description
stateData object

the initial state data.

setInitialState(initialState)

Source:

Loads the initial state.

Note this method will trigger a state changed event with "state:loaded" actionname.

The state mode will be set to read only when the initial state is loaded.

Parameters:
Name Type Description
initialState object

setLarge()

Source:

Mark the modal as a large modal.

setLimit(root) → {function}

Source:

Return the callback to be passed to the subscribe event

Parameters:
Name Type Description
root object

The root element for the courses view

Returns:

Partially applied function that'll execute when passed a limit

Type
function

setLoadedAllContent(val)

Source:

Set the state of the loaded all content property for the current state of the popover.

Parameters:
Name Type Description
val bool

True if all content is loaded, false otherwise

setMutations(manager)

Source:

Replace the current mutations with a new object.

This method is designed to override the full mutations class, for example by extending the original one. To add some individual mutations, use addMutations instead.

Parameters:
Name Type Description
manager object

the new mutations intance

setOrder(columns) → {Promise}

Source:

Call external function set_order - inserts the updated column in the config_plugins table.

Parameters:
Name Type Description
columns String

String that contains column order.

Returns:
Type
Promise

setPageItem(stateManager, type, id, isStatic)

Source:

Set the page current item.

Only one element of the course state can be the page item at a time.

There are several actions that can alter the page current item. For example, when the user is in an activity page, the page item is always the activity one. However, in a course page, when the user scrolls to an element, this element get the page item.

If the page item is static means that it is not meant to change. This is important because static page items has some special logic. For example, if a cm is the static page item and it is inside a collapsed section, the course index will expand the section to make it visible.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

type String | undefined

the element type (section or cm). Undefined will remove the current page item.

id Number | undefined

the element id

isStatic boolean | undefined

if the page item is static

setReadOnly(readonly)

Source:

Locks or unlocks the state to prevent illegal updates.

Mutations use this method to modify the state. Once the state is updated, they must block again the state.

All changes done while the state is writable will be registered using registerStateAction. When the state is set again to read only the method will trigger _publishEvents to communicate changes to all watchers.

Parameters:
Name Type Description
readonly bool

if the state is in read only mode enabled

setScrollable(value)

Source:

Set this modal to be scrollable or not.

Parameters:
Name Type Description
value bool

Whether the modal is scrollable or not

setSmall()

Source:

Mark the modal as a small modal.

setStorageValue(key, value) → {boolean}

Source:

Stores a value into the course editor static storage if available

Parameters:
Name Type Description
key String

the key to store

value *

the value to store (must be compatible with JSON,stringify)

Returns:

true if the value is stored

Type
boolean

setTitle(value)

Source:

Set the modal title element.

This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with HTML most commonly from a Str.get_string call.

Parameters:
Name Type Description
value string | object

The title string or jQuery promise which resolves to the title.

setupSortableLists(listRoot)

Source:

Sets up sortable list in the column sort order page.

Parameters:
Name Type Description
listRoot Element

show() → {Promise}

Source:

Display this modal. The modal will be attached to the DOM if it hasn't already been.

Returns:
Type
Promise

showCourse(root, courseId)

Source:

Show course

Parameters:
Name Type Description
root Object

The course overview container

courseId Number

Course id number

showDropZone(dropdata)

Source:

Display the component dropzone.

Parameters:
Name Type Description
dropdata Object

the accepted drop data

showDropZone(dropdata)

Source:

Display the component dropzone.

Parameters:
Name Type Description
dropdata Object

the accepted drop data

showDropZone()

Source:

Display the component dropzone.

showFavouriteIcon(root, courseId)

Source:

Show the favourite icon.

Parameters:
Name Type Description
root Object

The course overview container.

courseId Number

Course id number.

showFooter()

Source:

Show the footer element.

standardFunctionalityCurry() → {function}

Source:

The default functionality of fetching paginated courses without special handling.

Returns:
Type
function

stateReady()

Source:

Reactive module will call this method when the state is ready.

Component can override this method to update/load the component HTML or to bind listeners to HTML entities.

stateReady()

Source:

Initial state ready method.

This method will add all the necessary event listeners to the component depending on the parent methods.

  • Add drop events to the element if the parent component has validateDropData method.
  • Configure the elements draggable if the parent component has getDraggableData method.

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the state data

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the state data.

stateReady()

Source:

Initial state ready method.

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the initial state

stateReady()

Source:

Initial state ready method.

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the initial state

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the course state.

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the state data

(async) stateReady(state)

Source:

Initial state ready method.

This stateReady to be async because it loads the real courseindex.

Parameters:
Name Type Description
state object

the initial state

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the initial state

stateReady(state)

Source:

Initial state ready method.

Parameters:
Name Type Description
state Object

the initial state

stop()

Source:

Stop the timer, if it is running.

submitTagCreateUpdateForm(questionId, contextId, formdata) → {promise}

Source:

Submit the form data for the question tags form.

Parameters:
Name Type Description
questionId Number
contextId Number
formdata string

The URL encoded values from the form

Returns:
Type
promise

toggleGroup(item)

Source:

Toggle a group item.

Parameters:
Name Type Description
item JQuery

the jQuery object

unlockAll(stateManager)

Source:

Unlock all course elements.

Parameters:
Name Type Description
stateManager StateManager

the current state manager

unregister()

Source:

Unregister the component from the reactive module.

This method will disable the component logic, event listeners and watchers but it won't remove any HTML created by the component. However, it will trigger the destroy hook to allow the component to clean parts of the interface.

unregisterComponent(component) → {object}

Source:

Unregister a component and its watchers.

Parameters:
Name Type Description
component object

the object instance to unregister

Returns:

the deleted component

Type
object

update()

Source:

Function to update the clock with the current time left.

updateButtonAriaLabel()

Source:

Set the correct aria label on the menu toggle button to be read out by screen readers. The message will indicate the state of the unread notifications.

updatePreferences(filter, value)

Source:

Update the user preference for the block.

Parameters:
Name Type Description
filter String

The type of filter: display/sort/grouping.

value String

The current preferred value.

validateDropData(dropdata) → {boolean}

Source:

Validate if the drop data can be dropped over the component.

Parameters:
Name Type Description
dropdata Object

the exported drop data.

Returns:
Type
boolean

validateDropData(dropdata) → {boolean}

Source:

Validate if the drop data can be dropped over the component.

Parameters:
Name Type Description
dropdata Object

the exported drop data.

Returns:
Type
boolean

validateDropData(dropdata) → {boolean}

Source:

Validate if the drop data can be dropped over the component.

Parameters:
Name Type Description
dropdata Object

the exported drop data.

Returns:
Type
boolean

validateDropData(dropdata) → {boolean}

Source:

Validate if the drop data can be dropped over the component.

Parameters:
Name Type Description
dropdata Object

the exported drop data.

Returns:
Type
boolean

Type Definitions

description

Source:
Properties:
Name Type Attributes Description
eventName string

the custom event name used for state changed events

eventDispatch function

the state update event dispatch function

target Element <optional>

the target of the event dispatch. If not passed a fake element will be created

mutations Object <optional>

an object with state mutations functions

state Object <optional>

an object to initialize the state.

The component descriptor data structure.

Type:
  • object

descriptor

Source:
Properties:
Name Type Attributes Description
reactive Reactive

an optional reactive module to register in

element DOMElement

all components needs an element to anchor events

selectors object <optional>

an optional object to override query selectors

The component descriptor data structure.

This structure is used by any component and init method to define the way the component will interact with the interface and whith reactive instance operates. The logic behind this object is to avoid unnecessary dependancies between the final interface and the state logic.

Any component interacts with a single main DOM element (description.element) but it can use internal selector to select elements within this main element (descriptor.selectors). By default each component will provide it's own default selectors, but those can be overridden by the "descriptor.selectors" property in case the mustache wants to reuse the same component logic but with a different interface.

Type:
  • object