Class: nomenclatureController

nomenclatureController

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

nomenclatureController is the javascript class responsible for running the interface for the nomenclature JSOCLO.

Cookie values are used in this function and application. cookies are used to determine if..

  1. This is the first time the page is being loaded. (no Cookies present).
  2. This is a browser reload. (cookies present) and the question is not locked.
  3. This is a browser reload. (cookies present) and the question is not locked.
In each case the action is slightly different. Locked means the question is 'in progress'; is not yet completed and the max number of attempts has not been reached.

Locked questions disable the users ability to change the question or category. Reloading the page with the browser will not unlock a a locked question.

The category array contains the list of categories and the number of questions in each category. It is defined in /json/orgnom.json and is loaded into the application via getCategoryArray().

See the admin utilities for functionality that can generate the JSON to use as the contents of /json/orgnom.json.

new nomenclatureController()

Source:

Members

<inner> attempts

the number of attempts made on this question
Source:

<inner> categoryArray

built in getCategoryArray()
Source:

<inner> categoryQuestionMap

maps category names to the number of questions in the category. Is built in getCategoryArray()
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:
used to populate the hidden div. It is not currently used in this application.
Source:

<inner> previousAnwers

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

Methods

<inner> adjustCSS()

Adjusts the css on the page based on the size the Menu div turned out to be after the menu was generated.
Source:

<inner> changeCategories(value)

Resets the page to the selected category and chooses question number 1.
Parameters:
Name Type Description
value the category chosen from the right-hand side menu.
Source:

<inner> checkComplete() → {Boolean}

checks to see if the question number in the cookie 'queston' has been completed since the time we changed categories.
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. (since the category was selected).
Parameters:
Name Type Description
answer The answer that was submitted.
Source:
Returns:
Can you guess what true means?
Type
Boolean

<inner> createMenu()

Creates and uses the Cateogry Array to set the menu up. The menu is created as an unordered list and uses CSS and Javascript to work as links
Source:

<inner> createScoreString() → {String}

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

<inner> fillContent(data, status)

AJAX callback handler for the SJAX request made in getOtherContent()
Parameters:
Name Type Description
data
status
Source:

<inner> getcategoryArray()

Uses Ajax (in a synchronous mode) to retrieve /json/orgnom.json and uses it to instantiate the category array. side effect, builds question map which maps the category name to the number of questions in the category.
Source:
Returns:
the category Array

<inner> getHelp()

Opens a new window/tab using the link found in the @link section of the question file, or, alerts a no help message to the user if no link was in the file.
Source:

<inner> getOtherContent(page)

Not currently used in this application
Parameters:
Name Type Description
page page is the URL to load into the hidden div.
Source:

<inner> loadNewQuestion()

callback handler for when a new question number has been selected from the drop-down select box or via the next and previous buttons
Source:

<inner> nextQuestion()

Moves to the next question in the category. End of questions behaviour is configured using jsocloconfig 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 jsocloconfig CYCLE_NEXT_PREV value.
Source:

<inner> setDefaults()

Sets default values on page load based on the 'category' cookie value.
Source:

<inner> solution()

If the question has been completed then it alerts the answer. If the question has not been completed then it asks for confirmation, warning of question forfeit before alerting the answer and giving zero for the question
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.
Source: