Rule-based Dialog

We use the rule-based system Drools Expert for our experiments.

The experiments try to generalise ISAC's behaviour from a reactive system to an active system: At certain situations during stepwise problem solving ISAC shall take the initiative. One such situation is already clear: when the learner gets stuck, then the system shall offer help. Some early considerations about such help can be found here.

At the present Drools Expert is implemented in 'src/java/isac/wsdialog/WorksheetDialogRLB.java'. This implementation is parallel to WorksheetDialog.java and is able to run some tests in 'src/java-tests/isac/wsdialog/TestSolve.java'. The tests show that still some effort is required to replace WorksheetDialog by WorksheetDialogRLB.

Notes from experiences gained so far:

Debug Drools
Decomment the following lines in 'src/java/isac/wsdialog/WorksheetDialogRLB.java':

/* LOGGING RULE APPLICATION */ ksession_.addEventListener(new DebugAgendaEventListener); ksession_.addEventListener(new DebugWorkingMemoryEventListener); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession_, "./LOGFILE_Worksheetdialog" );

/* LOGGING RULE APPLICATION */ logger.close; With these settings there is plenty output on the console, but little in './LOGFILE'. The latter does not accept a '~' in the path.

Be careful with identifiers and references in rules
/* ATTENTION use the right class, e.g. 'WorksheetDialogRLB' and ruleset 'RlbLearnRLB' */ rlb_ = new RlbBuilder(WorksheetDialogRLB.class, "RlbLearnRLB.drl"); For further sources of errors compare 'src/java/isac/wsdialog/RlbLearnRLB.drl' and 'RlbLearn.drl'

Replace WorksheetDialog with WorksheetDialogRLB
rlb_ = new RlbBuilder(WorksheetDialogRLB.class, "RlbLearnRLB.drl"); with rlb_ = new RlbBuilder(WorksheetDialog.class, "RlbLearn.drl");
 * $ mv WorksheetDialog.java WorksheetDialog-SAVE.java
 * $ mv WorksheetDialogRLB.java WorksheetDialog.java
 * $ rename identifieres of class and constructors
 * replace

Logging Drools Expert
see WorksheetDialogRLB.java

Coding standards for rules
The language for dialog-authors is under construction. The following coding standards establish a pseudo code which tries to simplify things as much as possible while ensuring precision. These are the preliminary standards:
 * 1) Java-specific details like ";" are omitted, "{}" are indicated by indentation, etc.
 * 2) Instance variables in WorksheetDialog have an ending underscore, for instance error_pattern_ in the example below. These variables can be dereferenced and updated from all rules.
 * 3) Variables local to a rule do not have an ending underscore.
 * 4) ME# indicates a method calling the MathEngine. So, for instance, a method IToCalc#method (see Dialog_Architecture) is ME#appendFormula (which is described in src/java/isac/interfaces/IToCalc.java).
 * 5) WS# indicates a method calling the Worksheet.
 * 6) DG# indicates a method calling the DialogGuide.
 * 7) For CalcEvent the specialised CalcChanged and CalcMessage are used only.
 * 8) Methods calls like CalcEvent.getErrorPattern address existing code.
 * 9) Functions like foundErrorPattern (CalcEvent) are used for not yet existing code.
 * 10) local variables use underscores to separate words, like in

This is an example: rule "show a hint-page if an error-pattern is detected" when CalcMessage == "error-pattern#...#" then error_pattern_ = CalcEvent.getErrorPattern DG#showHintPage (error_pattern_) DG#error_counter (error_pattern_) ++ help_counter_ = 0 WS#addHelpButton WS#removeNextAndAutoButtonForWorksheet end

Variables for rules TODO --> Java-code
Instance variables in src/java/isac/wsdialog/WorksheetDialog.java; these variables exist separately for each Worksheet, so no side-effects are to be expected:
 * err_patt_: is initalised as "". If the ME detects an error-pattern, then this variable is assigned the identifier of the pattern. Then the  button is set and , buttons removed, and also hint-pages, fill-forms, etc can be shown. GOON !!!!!!!!!!!!!!!!!!!!!!

Methods of the DialogGuide; these methods are used by all WorksheetDialogs:
 * EPcounter(error_pattern) are reset at the beginning of a Session to 0, incremented by +1 for each occurrence of an error_pattern individually and all stored at the end of a Session
 * errorPatternsToCheck: returns a list of identifiers for error-patterns (EP); can be used for specific dialog phases which try to check, if a learner inclines to one or several EPs in this list. The list is set according to Handling_of_Errorpatterns

Collections of rules
The first rule collection is src/java/isac/wsdialog/RlbLearn.drl; it is called by notifyUserAction, see Figure on Dialog_Architecture.

Further collections of rules will follow.