Class: analyzerBase

analyzerBase

Base class for all inheriting analyzers. Provides common functionality and parsing of all question files. Children use the information and searchers populated here to provide application specific feedback. This class is not intended to be directly instantiated. It's children are.

new analyzerBase()

Super Contsructor to call in inheriting classes
Source:
Tutorials:
See:
Example
function subAnalyzer(){
		analyzerBase.call(this);

subAnalyzer specific members 
and methods 

}
subAnalyzer.prototype = new analyzerBase();
subAnalyzer.prototype.constructor = subAnalyzer; 

Members

category :String

The category of the question. Example: ethers for orgnom, or empty for spectroscopy. defaults to the 'category' cookie value
Type:
  • String
Source:

fclass :String

Functional Class of the Analyzer. Example: orgnom or spectroscopy,
used, in part, to determine the location of the question files. defaults to the 'fclass' cookie value
Type:
  • String
Source:

questionNum :String

The question number, from the category, being analyzed. defaults to the 'question' cookie value
Type:
  • String
Source:

<inner> answerURL :String

A constructed string using the config and fclass
Type:
  • String
Source:

<inner> commonSearchers :searcher

Used to analyze responses against the value from the question file for common wrong answers.
Type:
Source:

<inner> correctSearcher :searcher

Used to analyze responses against the values from the question file for correct answers.
Type:
Source:

<inner> difSrc :String

A constructed relative URL to the difficulty img for the question.
Type:
  • String
Source:

<inner> helpURL :String

The value from the question file for a help page link. Can be a relative or absolute URL.
Type:
  • String
Source:

<inner> hints :Array.<String>

Type:
  • Array.<String>
Source:

<inner> jme :String

The jme or SMILE String for the question. jme for orgnom, SMILE for spectroscopy
Type:
  • String
Source:

<inner> lSearcher :searcher

Used to analyze responses against the value from the question file for the number of loci. Used in orgnom
Type:
Source:

<inner> numberOfHints :Number

Type:
  • Number
Source:

<inner> questionCompleted :Boolean

Type:
  • Boolean
Source:

<inner> score :Number

The running total average score for the category
Type:
  • Number
Source:

<inner> searchers :Array.<searcher>

Used to analyze responses against the values from the question file for strings to search for in the answer.
Type:
Source:

<inner> spectroSearchers :Object

Contains searchers based on the spectroscopy question file format. Is populated by the parse methods of this class.
Type:
  • Object
Source:
Tutorials:
Example
 
{
"mw"		: 	molecularWeightSearcher
"stereo"	:	searcher, 
"typesC"	: 	numTypesCarbonSearcher,
"typesH"	: 	numTypesHydrogenSearcher, 
"numC"	:	numCarbonSearcher,
"numH"	:  	numHydrogenSearcher,
"charge" 	: 	chargeSearcher,
"rings" 	:	ringsSearcher,
"molF"	: 	molecularFormulaSearcher,
"fGroups"	: 	functionalGroupsSearcher
}
  
  

<inner> that :analyzerBase

Used in private members called from the constructor
Type:
Source:

<inner> typeMessage :String

The type found in the question file for the question. used in orgnom
Type:
  • String
Source:

Methods

<abstract, protected> checkSyntax(answer)

This method should be implemented by children of this class to provide meaningful syntax validation It is provided as a default to facilitate design for new presentations using analyzers.
Parameters:
Name Type Description
answer string
Source:
Throws:
String

<protected> clearComplete()

Clear the complete flag for the question.
Source:

<protected> getAnswerURL() → {String}

Source:
Returns:
the URL to the question File
Type
String

<protected> getCommonSearcher() → {searcher}

Source:
Returns:
The first common searcher in the array of common searchers or null if no common searchers are present.
Type
searcher

<protected> getCommonSearchers() → {searcher}

Source:
Returns:
[] The array of common searchers or null if no common searchers are present.
Type
searcher

<protected> getCorrectAnswer() → {String}

Source:
Returns:
for the reqular expression
Type
String

<protected> getCorrectMsg() → {String}

Source:
Returns:
the Message from the question file for a correct answer.
Type
String

<protected> getDifficulty() → {String}

Source:
Returns:
representing the relative path to the image to use for the difficulty img on the question page. The path is built based on the difficulty value in the question file.
Type
String

<abstract, protected> getFeedback(answer)

This method should be implemented by children of this class to provide meaningful feedback. It is provided as a default to facilitate design for new presentations using analyzers.
Parameters:
Name Type Description
answer string
Source:
Throws:
String

getHelpURL() → {String}

Getter for the Help URL from the question file.
Source:
Returns:
the help URL
Type
String

getJme()

Source:
Returns:
the JME string found in the question file. access protected

<protected> getLociSearcher() → {lociSearcher}

Source:
Returns:
the loci searcher for the question
Type
lociSearcher

<protected> getMaxAttempts()

Source:
Returns:
the maximum attempts for this question. Used to determine when to show the solution and allow another question to be selected.

<protected> getQuestionFile()

AJAX (made globally Synchronous) to get the question file. we have to do synchronous because the jsmeonLoand function needs this.jme to be set and available before it(jsmeOnloand) is called. This method should be called from the children of analyzerBase in their constructors. After construction, children should only use the loadQuestionFile(qClass, category,qnum) method.
Source:
See:

<protected> getScore() → {Number}

Source:
Returns:
the Question Score if the question was completed zero otherwise.
Type
Number

<protected> getSearchers() → {Array.<searcher>}

Source:
Returns:
the array of Searchers other than common, correct and loci.
Type
Array.<searcher>

<protected> getType() → {String}

Source:
Returns:
the type message from the question file.
Type
String

<protected> isCompleted() → {Boolean}

Source:
Returns:
Type
Boolean

<protected> isCorrect(answer) → {Boolean}

checks that answer is an exact case insensitive match with any one of the acceptable answers found in the question file.
Parameters:
Name Type Description
answer String a string trimmed of leading and trailing whitespace prior to calling this method.
Source:
Returns:
true if it is an exact match.
Type
Boolean

<protected> loadError()

Global AJAX callback for failed AJAX requests. Most likely cause of the failure would be file not found.
Source:
Throws:
  • config.AF_LOAD_ERROR;
    Type
    String
  • 'File Not Fund Error'

<protected> loadQuestionFile(qClass, category, qnum)

Reloads the analyzer with a new questiod, based on functional class, category and qnum. Resets the the cookies for each parameter if the parameter is not NUll. If this method is called with all Null parameters it will reload the current question file.
Parameters:
Name Type Description
qClass string
category string
qnum string
Source:

<protected> reset()

Called by loadQuestion file. Resets the class in preperation to make a call to getQuestionFile so that parseQuestionFile will populate the searchers and other information properly from the new question file information.
Source:

<protected> setCategory(value)

Sets the Category
Parameters:
Name Type Description
value String
Source:

<protected> setComplete()

Set the complete flag for the question.
Source:

<protected> setfclass(value)

Sets the Functional Class
Parameters:
Name Type Description
value String
Source:

<protected> setQuestionNum(value)

Sets the question number (for the cateory)
Parameters:
Name Type Description
value String
Source:

<protected> setScore(value)

Set the question score. Used by inheriting classes.
Parameters:
Name Type Description
value Number
Source:

<protected> setURL(value)

Sets the URL for the question file location. Use with caution
Parameters:
Name Type Description
value String
Source:

<private, inner> getSectionLines(section, regExp) → {Array.<String>}

Helper method that splits the section into lines, except for parseCommon. Relies on each line being separate. (splits on newlines).
Parameters:
Name Type Description
section String the section from the question file to split into lines.
regExp the reqular expression used to split the first line from the remaining lines
Source:
Returns:
each element is a line, delimited by \n in the section.
Type
Array.<String>

<private, inner> parseCharge(section)

Parses the charge section from the question file and stores the result in spectroSearchers.charge
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseCommon(section)

Parses the common section from the question file and creates a searcher from the result.

The common section is different in that the string common does not appear at the beginning of the section like the other section names do. Common appears last on the first line of the section. This is the only way we can tell it is a common section, but the question files seem consistent in doing this.

Parameters:
Name Type Description
section the common section from the question file.
Source:
Throws:
'parseCommon' on error

<private, inner> parseCorrect(section)

Parses the correct section from the question file and creates a searcher from the result
Parameters:
Name Type Description
section correct section of question file.
Source:
Throws:
'parseCorrect' on error

<private, inner> parseDifficulty(section)

Sets the img src string based on the difficulty of the question.
Parameters:
Name Type Description
section the difficulty section from the question file.
Source:
Throws:
'parseDifficulty' on error

<private, inner> parseFunctionalGroups(section)

Parses the functional Group section from the question file and stores the result in spectroSearchers.fGroups
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseHint(section)

Parses the hintN section(s) from the question file and adds the result to the hints array
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseHintNum(section)

Parses the hint section from the question file and stores the result in numberOfHints.
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseJme(section)

Sets the SMILE string of the question.
Parameters:
Name Type Description
section the JME section from the question file.
Source:
Throws:
'parseJME' on error
Parses the help link section from the question file and stores the result in this.helpURL
Parameters:
Name Type Description
section the link section from the question file.
Source:
Throws:
'parsLink' on error

<private, inner> parseLoci(section)

Parses the loci section from the question file and creates a lociSearcher from the result.
Parameters:
Name Type Description
section the loci section from the question file.
Source:
Throws:
'parseLoci' on error

<private, inner> parseMolecularFormula(section)

Parses the mf section from the question file and stores the result in spectroSearchers.molF
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseMolecularWeight(section)

Parses the mw section from the question file and stores the result in spectroSearchers.mw
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseNumberCarbons(section)

Parses the c section from the question file and stores the result in spectroSearchers.numC
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseNumberHydrogens(section)

Parses the h section from the question file and stores the result in spectroSearchers.numH
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseNumberTypesCarbons(section)

Parses the typec section from the question file and stores the result in spectroSearchers.typeC
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseNumberTypesHydrogens(section)

Parses the typeh section from the question file and stores the result in spectroSearchers.typeH
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseQuestionFile(data, status)

The callback handler for the AJAX call to obtain the question file. It splits the file into sections, delimited by '@', then passes the section to a section specific parser.

It does all question file parsing.

Parameters:
Name Type Description
data value returned from AJAX
status value returned from AJAX
Source:
Tutorials:
  • Tutorial: QuestionFileFormatNomenclature
  • Tutorial: QuestionFileFormatSpectroscopy
Throws:
a parse error if any of the section parsers throw an exception

<private, inner> parseRings(section)

Parses the ring section from the question file and stores the result in spectroSearchers.rings
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseSearch(section)

Parses a search section from the question file, creates a searcher for it and adds it to the searchers array.
Parameters:
Name Type Description
section a search section from the question file.
Source:
Throws:
'parseSection' on error

<private, inner> parseStereo(section)

Parses the stereo section from the question file and stores the result in spectroSearchers.stereo
Parameters:
Name Type Description
section the link section from the question file.
Source:

<private, inner> parseType(section)

Sets the type message string of the question.
Parameters:
Name Type Description
section the type section from the question file.
Source:
Throws:
'parseType' on error