org.problets.domain.template
Class Template

java.lang.Object
  extended by org.problets.domain.template.Template
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
TemplateWithContext

public class Template
extends java.lang.Object
implements java.lang.Cloneable

Template To hold the template being used for the current problem Author: Amruth Kumar


Constructor Summary
Template(int inTemplateNumber, java.lang.String inAntecedent, java.lang.String inIfCorrect, java.lang.String inIfWrong, java.lang.String inInstructions, java.lang.String inTemplate, java.lang.String inProblemType, int inHardness)
          Constructor currently used only for testing purposes in BatchTester - Retained for its ease of use
Template(Template parameter)
          Constructor used by TemplateWithContext class
Template(java.util.Vector contentVector)
          Constructor that extracts the template components from a vector of strings.
 
Method Summary
 java.lang.Object clone()
          Method makes a deep copy of the template's various string members
 java.lang.String getAntecedent()
          Returns the antecedent of the template
 java.lang.String getCompleteTemplate()
          Returns the template including any optional declarations upfront
static java.util.Vector getConjuncts(java.lang.String antecedent)
          Returns a vector of all the conjuncts in an antecedent.
static java.util.Vector getDisjuncts(java.lang.String antecedent)
          Returns a vector of all the disjuncts in an antecedent.
 int getHardness()
          Returns the hardness of this problem, i.e., the percentage of problems the students must have gotten correct on this particular topic before the student is not served this problem any more, e.g., 100 means the problem is always in play and 25 means if the student got even 25% of the problems correct so far, this template will not be used because it is too easy
 java.lang.String getIfCorrect()
          Returns the learning objectives to be credited if the student answered the question correctly
 java.lang.String getIfWrong()
          Returns the learning objectives to be credited if the student answered the question incorrectly
 java.lang.String getInstructions()
          Returns any optional instructions provided for this problem
 java.lang.String getProblemType()
          Returns the problem type: Code/Debug/Output
 java.lang.String getTemplate()
          Returns the template string
 int getTemplateNumber()
          Returns the template number of this template
static void main(java.lang.String[] args)
           
static boolean match(java.lang.String lhs, java.lang.String rhs)
          Matches the left and right hand sides.
static boolean matchConjuncts(java.lang.String antecedent, java.lang.String learnObj)
          Takes a dot-separated antecedent, and a Vector of string tokens.
static boolean matchDisjuncts(java.lang.String antecedent, java.lang.String learnObj)
          Matches disjuncts NOT enclosed in braces: e.g., a,b,c not {a,b,c}.
 void print()
           
 void setInstructions(java.lang.String inInstructions)
          Sets the instructions for this Template object
 void setTemplate(java.lang.String inTemplate)
          Sets the template string for this Template object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Template

public Template(int inTemplateNumber,
                java.lang.String inAntecedent,
                java.lang.String inIfCorrect,
                java.lang.String inIfWrong,
                java.lang.String inInstructions,
                java.lang.String inTemplate,
                java.lang.String inProblemType,
                int inHardness)
Constructor currently used only for testing purposes in BatchTester - Retained for its ease of use


Template

public Template(Template parameter)
Constructor used by TemplateWithContext class


Template

public Template(java.util.Vector contentVector)
Constructor that extracts the template components from a vector of strings. Assumes the following format: # Template number Learning objective/Antecedent ? ifCorrect : ifWrong > "Instructions" Template string > Type: problem type Hardness: problem hardness

Method Detail

clone

public java.lang.Object clone()
Method makes a deep copy of the template's various string members

Overrides:
clone in class java.lang.Object

getTemplateNumber

public int getTemplateNumber()
Returns the template number of this template


getAntecedent

public java.lang.String getAntecedent()
Returns the antecedent of the template


getTemplate

public java.lang.String getTemplate()
Returns the template string


getCompleteTemplate

public java.lang.String getCompleteTemplate()
Returns the template including any optional declarations upfront


getIfCorrect

public java.lang.String getIfCorrect()
Returns the learning objectives to be credited if the student answered the question correctly


getIfWrong

public java.lang.String getIfWrong()
Returns the learning objectives to be credited if the student answered the question incorrectly


getInstructions

public java.lang.String getInstructions()
Returns any optional instructions provided for this problem


getProblemType

public java.lang.String getProblemType()
Returns the problem type: Code/Debug/Output


getHardness

public int getHardness()
Returns the hardness of this problem, i.e., the percentage of problems the students must have gotten correct on this particular topic before the student is not served this problem any more, e.g., 100 means the problem is always in play and 25 means if the student got even 25% of the problems correct so far, this template will not be used because it is too easy


match

public static boolean match(java.lang.String lhs,
                            java.lang.String rhs)
Matches the left and right hand sides. Preprocesses to convert everything into lower case Lhs is expected to be the antecedent of the rule. In the future, could strip spaces around comma and braces


matchDisjuncts

public static boolean matchDisjuncts(java.lang.String antecedent,
                                     java.lang.String learnObj)
Matches disjuncts NOT enclosed in braces: e.g., a,b,c not {a,b,c}. Use this instead of matchConjuncts() for the general case.


matchConjuncts

public static boolean matchConjuncts(java.lang.String antecedent,
                                     java.lang.String learnObj)
Takes a dot-separated antecedent, and a Vector of string tokens. If the first token in the vector matches the start of the dot.separated antecedent, calls itself recursively for the rest. Otherwise, returns false. Use matchDisjuncts() instead of matchConjuncts) to handle general cases.


getDisjuncts

public static java.util.Vector getDisjuncts(java.lang.String antecedent)
Returns a vector of all the disjuncts in an antecedent. The parameter does NOT include the open and close brace. The returned disjuncts are fully expanded, i.e., they do not themselves contain nested disjuncts. Use getDisjuncts() instead of getConjuncts() for the general case.


getConjuncts

public static java.util.Vector getConjuncts(java.lang.String antecedent)
Returns a vector of all the conjuncts in an antecedent. For a general antecedent, call getDisjuncts() rather than getConjuncts() so that disjuncts are properly handled.


setInstructions

public void setInstructions(java.lang.String inInstructions)
Sets the instructions for this Template object


setTemplate

public void setTemplate(java.lang.String inTemplate)
Sets the template string for this Template object


print

public void print()

main

public static void main(java.lang.String[] args)