2:- module(evaluation,[initEval/0,
    3                      incAttempted/0,
    4                      incCompleted/0,
    5                      reportEval/0]).    6
    7
    8/*========================================================================
    9    Declare Dynamic Predicates
   10========================================================================*/
   11
   12:- dynamic attempted/1, completed/1.   13
   14
   15/*========================================================================
   16    Initialise
   17========================================================================*/
   18
   19initEval:-
   20   retractall(attempted(_)), 
   21   retractall(completed(_)),
   22   assert(attempted(0)), 
   23   assert(completed(0)).
   24
   25
   26/*========================================================================
   27   Increase Completed
   28========================================================================*/
   29
   30incCompleted:-
   31   retract(completed(Co1)), 
   32   Co2 is Co1 + 1, 
   33   assert(completed(Co2)), !.
   34
   35
   36/*========================================================================
   37   Increase Attempted
   38========================================================================*/
   39
   40incAttempted:-
   41   retract(attempted(Co1)), 
   42   Co2 is Co1 + 1, 
   43   assert(attempted(Co2)), !.
   44
   45
   46/*========================================================================
   47   Report
   48========================================================================*/
   49
   50reportEval:-
   51   attempted(At), At > 0, !,
   52   completed(Co),
   53   Percentage is (100*Co/At),
   54   format(user_error,
   55          'Attempted: ~p. Completed: ~p (~2f%).~n',
   56          [At,Co,Percentage]).
   57
   58reportEval