Class: specController

specController

specController() is called via jQueries document.ready function which appears in spectroscopy.html. It is called each time the page is loaded or the browser is refreshed.

specController is the javascript class responsible for running the interface for the spectroscopy JSOCLO.

Category is not used in Spectroscopy so we must set the category cookie to the empty string when we initialize.

new specController()

Source:
Tutorials:
See:

Members

<inner> attempts

the number of attempts made on this quesiton
Source:

<inner> completedQuestions

Keeps track of the the completed questions so that scoring works properly. Is reset when the category changes. The array is stringified with Json and stored as a cookie.
Source:

<inner> jsmeDivCount

used to give unique div ID's to jsme instances in the response div. Used by createJsmeDiv()
Source:

<inner> previousAnwers

we keep track of all previous answers in submitAnswer()
Source:

<inner> questionMax

The number of questions in the series. Set by getNumberOfQuestions() used by next and prev quesiton
Source:

<inner> toggleHints

after 3 attempts hints are allowed this controls showing them all at once.
Source:

Methods

<inner> checkComplete() → {Boolean}

checks to see if the question number in the cookie 'queston' has been completed.
Source:
Returns:
true if the question is complete, false otherwise.
Type
Boolean

<inner> checkForDuplicates(answer) → {Boolean}

Called from submitAnswer() to check if the answer was previously given.
Parameters:
Name Type Description
answer The answer that was submitted.
Source:
Returns:
Can you guess what true means?
Type
Boolean

<inner> createJsmeDiv()

Creates the string for a div to be populated with a JSME applet. Returns an object with the div string and its unique id.
Source:

<inner> createScoreString() → {String}

Uses the values in the cookies to create a string showing the average (as a %) over x number of questions.
Source:
Returns:
Type
String

<inner> display(what, popup)

Displays a popup window or new tab
Parameters:
Name Type Description
what String what is the rleative URL to display
popup Boolean true and the window will be a popup false and it will be in a new tab.
Source:

<inner> getNumberOfQuestions()

Uses Ajax (in a synchronous mode) to retrieve /json/spectroscopy.json and uses it determine the number of questions for spectroscopy. If you add a question you must update /json/spectroscopy.json accordingly
Source:
Returns:
the number of questions

<inner> loadCSS(href)

Used by initializeSpectroscopy to load the CSS file.
Parameters:
Name Type Description
href
Source:

<inner> loadJS(src)

Used by initializeSpectroscopy to load javascript files it depends on. JSME and JQuery must already be loaded (from the html page).
Parameters:
Name Type Description
src
Source:

<inner> loadNewQuestion()

callback handler for when a new question number has been selected from the next and previous buttons
Source:

<inner> nextQuestion()

Moves to the next question. End of questions behaviour is configured using CYCLE_NEXT_PREV value.
Source:

<inner> numberOfCompleteQuetions() → {Number}

Source:
Returns:
number of complete questions in the category since the category was selected.
Type
Number

<inner> prevQuestion()

Moves to the previous question in the category. Beginning of questions behaviour is configured using config CYCLE_NEXT_PREV value.
Source:

<inner> showHint()

Alerts or displays a hint. Handler for the hint button. Behaviour is configured via config SPEC_UNLOCK_ALL_QUESTIONS and config ALERT_HINTS_MSGS
Source:

<inner> submitAnswer()

Submits to the analyzer and updates the page attributes and values based on the analyzer responses.
Source:

<inner> unlockQuestion()

unlocks the question so that the solution can be viewed and the question or category changed. Also allows duplicate answers to be submitted.
Source: