org.activemath.tutor
Class TaskUtil

java.lang.Object
  extended by org.activemath.tutor.TaskUtil

public class TaskUtil
extends Object

Parse the taskList.xml once and provide an interface for other compoent with the information gained from the xml file. In taskList.xml there are all the type of tasks defined. For each type of task there are many information like \ for pedagogical Object and and \ for giving the information: on which kind of content the Task/pedagogical Objective can be applicable.(e.g. illustration is applicable on definition but not on example) The taskList.xml will be only parsed once, so we let the class be a singelton.


Field Summary
protected static Logger log
           
 
Method Summary
 List checkPreConditionOf(String pedaObj, String mbaseIds, String userId)
          Check if the precondition can be satisfied by mediator.
 List getAllTaskIds()
          Return all the Tasks in a List of TaskId.
 List getApplicableTasksForItemMenu(String contentId, String userId)
          Return a list of appropriate task/pedagogical Objective, which can be applied on the item and derived by given contentId.
 String getConditionOf(String pedaObj)
          Get the precondition of a pedagogical object from the xml file.
 Map getDescriptionMap(String pedaObj)
          Currently we don't use this method.
 String getDescriptionOfPedaObj(String pedaObj, String lang)
          Get the appropriate description for certain language and particular pedagogical Objective(task as String).
 org.jdom.Element getElementOfPedaObj(String pedaObj)
          Return the Element which contains all information for given pedagogical objective.
static TaskUtil getInstance()
           
 String getPhraseKey(String pedaObj)
          Return the found PhraseKey as String or null if not found.
 Map getPhraseKeyMap()
          Return a Map of "phrase key "<-> "pedaObj id" pairs, so that the description can be fetched by phrase.
 String getTaskDefinitionDTDAdress()
           
 String getTaskDefinitionXMLAdress()
           
 List getTasksForItemMenu()
          Return all the tasks, which is used for Item Menu.
 List getTasksForSenario()
          Return all the tasks, which is used for Senario.
 URL getXMLFile()
           
 boolean isApplicableOn(org.jdom.Element currentElement, String omdocTag)
          Check if given currentElement is applicable on given omdocTag.
 boolean isForItemMenu(String pedaObj)
          Check whether the give objective can be used in the item menu.
 boolean isForScenario(String pedaObj)
          Check if given pedaObj is used for Scenario.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger log
Method Detail

getInstance

public static TaskUtil getInstance()

getApplicableTasksForItemMenu

public List getApplicableTasksForItemMenu(String contentId,
                                          String userId)
Return a list of appropriate task/pedagogical Objective, which can be applied on the item and derived by given contentId. Here we have two ways to compute the information: 1. is to analyse the omdocTag on a very simply way, that is, only to see if it is a conceptName(core concept) or just a satellite item. For the core concept we say simply all the task can be applied and for satellite none. 2. is to analyse the omdocTag w.r.t. a xml file, where we've defined which kind of Item can each Task apply on. This is also why we need this class for interpreting the static xml file at the compiling time and then use those information to make decision. In this Method, we will first check if the if the

Parameters:
contentId -
Returns:
null if no appropriate Tasks found, otherwise a list of such tasks, so to say "pedaObj"(String).

getAllTaskIds

public List getAllTaskIds()
Return all the Tasks in a List of TaskId.

Returns:
tasks (List of String)

isApplicableOn

public boolean isApplicableOn(org.jdom.Element currentElement,
                              String omdocTag)
Check if given currentElement is applicable on given omdocTag. Check if the currentElement contains such \ same to omdocTag If there's no such child element, return false, if there are such children, but none of them has the same attribute name like omdocTag, return false, otherwise return true.

Parameters:
currentElement -
omdocTag -
Returns:
see above

getConditionOf

public String getConditionOf(String pedaObj)
Get the precondition of a pedagogical object from the xml file. The returned string is only a Mediator query mask, still need to be modified.

Parameters:
pedaObj -
Returns:
string (mask for query to Mediator

getElementOfPedaObj

public org.jdom.Element getElementOfPedaObj(String pedaObj)
Return the Element which contains all information for given pedagogical objective.

Parameters:
pedaObj -
Returns:
Element for given pedaObj

checkPreConditionOf

public List checkPreConditionOf(String pedaObj,
                                String mbaseIds,
                                String userId)
Check if the precondition can be satisfied by mediator. This method can be used by tutorail Control for faster decision.

Parameters:
pedaObj -
mbaseIds - string with white space as separator for different mbase Ids like "mbase://sdfsdfsdf mbase://asdfasdf ... mbase://asdfasdf"
userId -
Returns:
an empty list if there's no precondition for such task defined null if mediator return null or found nothing the result list which mediator returned

getTasksForItemMenu

public List getTasksForItemMenu()
Return all the tasks, which is used for Item Menu.

Returns:
list of pedagogical Objectives (String)

getTasksForSenario

public List getTasksForSenario()
Return all the tasks, which is used for Senario.

Returns:
list of pedagogical Objectives (String)

isForItemMenu

public boolean isForItemMenu(String pedaObj)
Check whether the give objective can be used in the item menu. True, if its result type equal "section", and its one of the distinguished (hard coded) tasks.

Parameters:
pedaObj -
Returns:
true if the given pedagogical objective can be applied for ItemMenu. otherwise false.

isForScenario

public boolean isForScenario(String pedaObj)
Check if given pedaObj is used for Scenario. First find the Element which has the pedaObj attribute, then check if the Element is used for scenario by calling method isForScenario with Element as parameter.

Parameters:
pedaObj -
Returns:
true if the given pedaObj is used for Senario. Otherwise false.

getDescriptionOfPedaObj

public String getDescriptionOfPedaObj(String pedaObj,
                                      String lang)
Get the appropriate description for certain language and particular pedagogical Objective(task as String).

Parameters:
pedaObj -
lang - (language like "en", "de" etc.)
Returns:
the appropriate description as String or null if no such one can be found in taskList.xml.

getDescriptionMap

public Map getDescriptionMap(String pedaObj)
Currently we don't use this method. Return a Map of "phrase key "<-> "pedaObj id" pairs, so that the description can be fetched by phrase. Here we write such method explicit, because in case the language part is tranported to other standalone component, only this method need to be modified. With a given Element task, we can return a Map of description.

Parameters:
pedaObj - String
Returns:
a Map of "phrase key "<-> "pedaObj id" pairs.

getPhraseKeyMap

public Map getPhraseKeyMap()
Return a Map of "phrase key "<-> "pedaObj id" pairs, so that the description can be fetched by phrase.

Returns:
Map, or null

getPhraseKey

public String getPhraseKey(String pedaObj)
Return the found PhraseKey as String or null if not found.

Parameters:
pedaObj -
Returns:
String or null

getXMLFile

public URL getXMLFile()
               throws Exception
Throws:
Exception

getTaskDefinitionXMLAdress

public String getTaskDefinitionXMLAdress()

getTaskDefinitionDTDAdress

public String getTaskDefinitionDTDAdress()