Compod#notifyObjectResult part 1
authorwneuper
Wed, 11 Feb 2009 16:19:39 +0100
changeset 391775c4cd19f086
parent 3916 f7ef89789f0b
child 3918 0417a220729b
Compod#notifyObjectResult part 1
src/java/isac/browserdialog/BrowserDialog.java
src/java/isac/browserdialog/ExampleDialog.java
src/java/isac/session/CompodDummy.java
src/java/isac/session/ICompod.java
src/java/isac/session/Session.java
src/java/isac/users/UserLogger.java
     1.1 --- a/src/java/isac/browserdialog/BrowserDialog.java	Tue Nov 18 16:34:39 2008 +0100
     1.2 +++ b/src/java/isac/browserdialog/BrowserDialog.java	Wed Feb 11 16:19:39 2009 +0100
     1.3 @@ -307,7 +307,7 @@
     1.4                      e.printStackTrace();
     1.5                  }
     1.6                  // start the first example ...
     1.7 -                session_.getExampleDialog().notifySomeExampleFinished();
     1.8 +                session_.getExampleDialog().notifyStartFirstExample();
     1.9                  return;// --------------------------------------------->
    1.10              } else if (command.equals("COMMAND_STOP_ASSESSMENT")) {
    1.11                  try {
     2.1 --- a/src/java/isac/browserdialog/ExampleDialog.java	Tue Nov 18 16:34:39 2008 +0100
     2.2 +++ b/src/java/isac/browserdialog/ExampleDialog.java	Wed Feb 11 16:19:39 2009 +0100
     2.3 @@ -171,14 +171,13 @@
     2.4      }
     2.5  
     2.6      /**
     2.7 -     * triggers the ExampleBrowser to ask Compod for an example to be started
     2.8 -     * next.
     2.9 +     * triggers the ExampleBrowser to ask Compod for a first example
    2.10       * 
    2.11 -     * @deprecated made Compod run quick and dirty
    2.12 +     * @deprecated WN made Compod run quick and dirty
    2.13       * 
    2.14       * better involve the UserModel !!!
    2.15       */
    2.16 -    public void notifySomeExampleFinished() {
    2.17 +    public void notifyStartFirstExample() {
    2.18          String user_name = super.session_.getUser().getUsername();
    2.19          String[] next_objects;
    2.20          try {
    2.21 @@ -192,4 +191,40 @@
    2.22              e.printStackTrace();
    2.23          }
    2.24      }
    2.25 +
    2.26 +    /**
    2.27 +     * triggers the ExampleBrowser to ask Compod for an example to be started
    2.28 +     * next.
    2.29 +     * 
    2.30 +     * @param exp_id
    2.31 +     *            the unique identifier in the database of examples for the
    2.32 +     *            example just finished; required for Compod (and later on for
    2.33 +     *            UserLogger)
    2.34 +     * @param success_info
    2.35 +     *            0.0 | 1.0 (TODO.WN090111 isac.users.successInfo instead)
    2.36 +     * 
    2.37 +     * @deprecated WN08 made Compod run quick and dirty
    2.38 +     * 
    2.39 +     * better involve the UserModel !!!
    2.40 +     */
    2.41 +    public void notifySomeExampleFinished(String exp_id, float success_info) {
    2.42 +        String user_name = super.session_.getUser().getUsername();
    2.43 +        String[] next_objects;
    2.44 +        try {
    2.45 +            if (SessionState.ACTIVE == super.getCompod().getSessionState(
    2.46 +                    user_name)) {
    2.47 +                if (success_info == 0.0)
    2.48 +                    super.getCompod().notifyObjectResult(user_name, exp_id,
    2.49 +                            false);
    2.50 +                else
    2.51 +                    super.getCompod().notifyObjectResult(user_name, exp_id,
    2.52 +                            true);
    2.53 +                next_objects = super.getCompod().getNextObjects(user_name);
    2.54 +                // always take the first object
    2.55 +                openWorksheetFromExample(next_objects[0]);
    2.56 +            }
    2.57 +        } catch (Exception e) {
    2.58 +            e.printStackTrace();
    2.59 +        }
    2.60 +    }
    2.61  }
    2.62 \ No newline at end of file
     3.1 --- a/src/java/isac/session/CompodDummy.java	Tue Nov 18 16:34:39 2008 +0100
     3.2 +++ b/src/java/isac/session/CompodDummy.java	Wed Feb 11 16:19:39 2009 +0100
     3.3 @@ -203,7 +203,7 @@
     3.4  		// TODO write data in a file (or on the console)
     3.5  		
     3.6  		// update and prepare for getNextObjects
     3.7 -		objectindex_++;
     3.8 +		// WN090111 objectindex_++; only in getNextObjects
     3.9  		
    3.10  		// stop if no more objects are available
    3.11  		int objectnumber = objects_.length;
     4.1 --- a/src/java/isac/session/ICompod.java	Tue Nov 18 16:34:39 2008 +0100
     4.2 +++ b/src/java/isac/session/ICompod.java	Wed Feb 11 16:19:39 2009 +0100
     4.3 @@ -44,6 +44,8 @@
     4.4   * 
     4.5   * @author Alexander Nussbaumer (AN) 
     4.6   *    alexander.nussbaumer@uni-graz.at, alnuss@gmx.net
     4.7 + *    
     4.8 + * WN090109 calls from UserLogger as much as possible
     4.9   */
    4.10  public interface ICompod {
    4.11  
    4.12 @@ -185,7 +187,7 @@
    4.13       * (step 6) Accepts information if an isac object has solved
    4.14       * correctly.
    4.15       *
    4.16 -     * ###isac-call-location: worksheetdialog
    4.17 +     * ###isac-call-location: WorksheetDialog | ExampleDialog for end of exp
    4.18       * 
    4.19       * @param username
    4.20       *            The user (unique name) for whom the action has to be
     5.1 --- a/src/java/isac/session/Session.java	Tue Nov 18 16:34:39 2008 +0100
     5.2 +++ b/src/java/isac/session/Session.java	Wed Feb 11 16:19:39 2009 +0100
     5.3 @@ -112,6 +112,7 @@
     5.4          wsid_map_example_ = new HashMap<String, KEStoreKey>();
     5.5  
     5.6          user_logger_.setExampleDialog(example_dialog_);
     5.7 +        user_logger_.setSession(this);
     5.8      }
     5.9  
    5.10      /**
    5.11 @@ -371,7 +372,7 @@
    5.12          case UI_OPEN_WORKSHEET:
    5.13              ws_dialog_manager_.openWSDialog();
    5.14              break;
    5.15 -        case UI_STOP_SESSION:{
    5.16 +        case UI_STOP_SESSION: {
    5.17              UserManager.getInstance().logout(this);
    5.18              System.out.println("####### Session: UI_STOP_SESSION #######");
    5.19              break;
    5.20 @@ -402,11 +403,16 @@
    5.21          return user_logger_;
    5.22      }
    5.23  
    5.24 -    /** @deprecated because quick and dirty for startind Compod */
    5.25 +    /** @deprecated WN08 because quick and dirty for starting Compod */
    5.26      public User getUser() {
    5.27          return user_;
    5.28      }
    5.29  
    5.30 +    /** @deprecated WN090111 because quick and dirty for starting Compod */
    5.31 +    public KEStoreKey getExampleId(String ws_id) {
    5.32 +        return wsid_map_example_.get(ws_id);
    5.33 +    }
    5.34 +
    5.35      public ICompod getCompod() {
    5.36          return compod_;
    5.37      }
     6.1 --- a/src/java/isac/users/UserLogger.java	Tue Nov 18 16:34:39 2008 +0100
     6.2 +++ b/src/java/isac/users/UserLogger.java	Wed Feb 11 16:19:39 2009 +0100
     6.3 @@ -11,6 +11,7 @@
     6.4  
     6.5  import isac.browserdialog.ExampleDialog;
     6.6  import isac.interfaces.ICalcIterator;
     6.7 +import isac.session.Session;
     6.8  import isac.useractions.EUIElement;
     6.9  import isac.useractions.IUIAction;
    6.10  import isac.useractions.IUserAction;
    6.11 @@ -21,6 +22,7 @@
    6.12  import isac.util.ObjectManagerPaths;
    6.13  import isac.util.formulae.CalcHead;
    6.14  import isac.util.formulae.Formula;
    6.15 +import isac.util.formulae.KEStoreKey;
    6.16  
    6.17  /**
    6.18   * Records steps of the user. There is one instance per session. WN070908 the
    6.19 @@ -48,12 +50,19 @@
    6.20  
    6.21      private Connection connection_ = null;
    6.22  
    6.23 -    private String session_id_;
    6.24 -
    6.25      private User user_;// FIXME.WN071011 user_name_ would be sufficient
    6.26  
    6.27      /**
    6.28 -     * @deprecated quick and dirty made Compod run ...
    6.29 +     * @deprecated WN 090111 quick and dirty made Compod run ...
    6.30 +     * 
    6.31 +     * is needed to get KEStoreKey of Worksheet for ICompod.notifyObjectResult
    6.32 +     */
    6.33 +    private Session session_;
    6.34 +
    6.35 +    private String session_id_;
    6.36 +
    6.37 +    /**
    6.38 +     * @deprecated WN08 quick and dirty made Compod run ...
    6.39       */
    6.40      private ExampleDialog exp_dialog_;
    6.41  
    6.42 @@ -65,14 +74,21 @@
    6.43      private UserRecord current_step_ = new UserRecord();
    6.44  
    6.45      // private HashMap<String, UserRecord> worksheet_map_user_;
    6.46 +    // There is one SuccessInfo per Worksheet.
    6.47 +    // private HashMap<String, SuccessInfo> worksheet_map_success_;
    6.48 +    // WN090111 ^^ worse than getSession !?!
    6.49  
    6.50 -    /** There is one SuccessInfo per Worksheet. */
    6.51 -    // private HashMap<String, SuccessInfo> worksheet_map_success_;
    6.52 +    /**
    6.53 +     * @param session_id
    6.54 +     *            and additionally session_, because session_ has NOT proper
    6.55 +     *            value when constructor is called
    6.56 +     */
    6.57      public UserLogger(String session_id, User user) {
    6.58          session_id_ = session_id;
    6.59          user_ = user;
    6.60          // worksheet_map_user_ = new HashMap<String, UserRecord>();
    6.61          // worksheet_map_success_ = new HashMap<String, SuccessInfo>();
    6.62 +        // WN090111 ^^ worse than getSession !?!
    6.63  
    6.64          log_to_database_enabled_ = ObjectManagerPaths.LOGGER_DATABASE_ENABLED;
    6.65  
    6.66 @@ -231,10 +247,10 @@
    6.67                      "worksheet", isac.useractions.EUIElement.LO_STOP_EXAMPLE,
    6.68                      null, null);
    6.69              current_step_.setResult(worksheet_id, null, null, null, new Float(
    6.70 -                    0.0));
    6.71 +                    0.0));// TODO use SuccessInfo not 0.0
    6.72              currentStepToDatabase();
    6.73              current_step_.reset();
    6.74 -            this.exp_dialog_.notifySomeExampleFinished();
    6.75 +            this.exp_dialog_.notifySomeExampleFinished((session_.getExampleId(worksheet_id)).toString(), new Float(0.0));
    6.76          }
    6.77          current_step_.setAction(user_.getUsername(), session_id_, "worksheet",
    6.78                  isac.useractions.EUIElement.UI_CLOSE_WORKSHEET, null, null);
    6.79 @@ -301,7 +317,7 @@
    6.80              current_step_.setResult(worksheet_id, null, null, null, new Float(
    6.81                      1.0));// TODO use SuccessInfo not 1.0
    6.82              currentStepToDatabase();
    6.83 -            this.exp_dialog_.notifySomeExampleFinished();
    6.84 +            this.exp_dialog_.notifySomeExampleFinished((session_.getExampleId(worksheet_id)).toString(), new Float(1.0));
    6.85          }
    6.86      }
    6.87  
    6.88 @@ -359,4 +375,11 @@
    6.89      public void setExampleDialog(ExampleDialog exp_dialog) {
    6.90          exp_dialog_ = exp_dialog;
    6.91      }
    6.92 +
    6.93 +    /**
    6.94 +     * @deprecated quick and dirty made Compod run.
    6.95 +     */
    6.96 +    public void setSession(Session session) {
    6.97 +        session_ = session;
    6.98 +    }
    6.99  }