<commit_before>/**
 * $Id$
 * $URL$
 * SetupEvalBean.java - evaluation - Mar 18, 2008 4:38:20 PM - azeckoski
 **************************************************************************
 * Copyright (c) 2008 Centre for Applied Research in Educational Technologies, University of Cambridge
 * Licensed under the Educational Community License version 1.0
 * 
 * A copy of the Educational Community License has been included in this 
 * distribution and is available at: http://www.opensource.org/licenses/ecl1.php
 *
 * <NAME> (<EMAIL>) (<EMAIL>) (<EMAIL>)
 */

package org.sakaiproject.evaluation.tool;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import org.sakaiproject.evaluation.logic.EvalEvaluationService;
import org.sakaiproject.evaluation.logic.EvalEvaluationSetupService;
import org.sakaiproject.evaluation.logic.externals.EvalExternalLogic;
import org.sakaiproject.evaluation.logic.externals.ExternalHierarchyLogic;
import org.sakaiproject.evaluation.logic.model.EvalHierarchyNode;
import org.sakaiproject.evaluation.model.EvalAssignHierarchy;
import org.sakaiproject.evaluation.model.EvalEvaluation;
import org.sakaiproject.evaluation.tool.locators.EvaluationBeanLocator;
import org.sakaiproject.evaluation.utils.ArrayUtils;
import org.sakaiproject.evaluation.utils.EvalUtils;

import uk.org.ponder.messageutil.TargettedMessage;
import uk.org.ponder.messageutil.TargettedMessageList;


/**
 * This action bean helps with the evaluation setup process where needed,
 * this is a pea
 * 
 * @author <NAME> (<EMAIL>)
 */
public class SetupEvalBean {

   /**
    * This should be set to true while we are creating an evaluation
    */
   public boolean creatingEval = false;
   /**
    * This should be set to the evalId we are currently working with
    */
   public Long evaluationId;

   // These are for the Assign screen, which is now bound by UIBoundBooleans
   public Map<String, Boolean> selectedEvalGroupIDsMap = new HashMap<String, Boolean>();
   public Map<String, Boolean> selectedEvalHierarchyNodeIDsMap = new HashMap<String, Boolean>();

   // TODO are these still needed?
// public String[] selectedEvalGroupIds;
// public String[] selectedEvalHierarchyNodeIds;


   private EvalEvaluationService evaluationService;
   public void setEvaluationService(EvalEvaluationService evaluationService) {
      this.evaluationService = evaluationService;
   }

   private EvalExternalLogic externalLogic;
   public void setExternalLogic(EvalExternalLogic externalLogic) {
      this.externalLogic = externalLogic;
   }

   private ExternalHierarchyLogic hierarchyLogic;
   public void setExternalHierarchyLogic(ExternalHierarchyLogic logic) {
      this.hierarchyLogic = logic;
   }

   private EvalEvaluationSetupService evaluationSetupService;
   public void setEvaluationSetupService(EvalEvaluationSetupService evaluationSetupService) {
      this.evaluationSetupService = evaluationSetupService;
   }

   private EvaluationBeanLocator evaluationBeanLocator;
   public void setEvaluationBeanLocator(EvaluationBeanLocator evaluationBeanLocator) {
      this.evaluationBeanLocator = evaluationBeanLocator;
   }

   private TargettedMessageList messages;
   public void setMessages(TargettedMessageList messages) {
      this.messages = messages;
   }

   private Locale locale;
   public void setLocale(Locale locale){
      this.locale=locale;
   }


   DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
   public void init() {
      df = DateFormat.getDateInstance(DateFormat.LONG, locale);
   }

   
   // Action bindings

   /**
    * Handles removal action from the remove eval view
    */
   public String removeEvalAction(){
      EvalEvaluation eval = evaluationService.getEvaluationById(evaluationId);
      evaluationSetupService.deleteEvaluation(evaluationId, externalLogic.getCurrentUserId());
      messages.addMessage( new TargettedMessage("controlevaluations.delete.user.messagee",
            new Object[] { eval.getTitle() }, TargettedMessage.SEVERITY_INFO));
      return "success";
   }


   // NOTE: these are the simple navigation methods
   // 4 steps to create an evaluation: 1) Create -> 2) Settings -> 3) Assign -> 4) Confirm/Save

   /**
    * Completed the initial creation page where the template is chosen
    */
   public String completeCreateAction() {
      evaluationBeanLocator.saveAll();
      return "evalSettings";
   }

   /**
    * Updated or initially set the evaluation settings
    */
   public String completeSettingsAction() {
      EvalEvaluation eval = evaluationService.getEvaluationById(evaluationId);
      evaluationBeanLocator.saveAll();

      String destination = "controlEvals";
      if (creatingEval) {
         destination = "evalAssign";
      } else {
         messages.addMessage( new TargettedMessage("evalsettings.updated.message",<commit_msg>http://jira.sakaiproject.org/jira/browse/EVALSYS-485 Fixed invalid message key<commit_after>/**
 * $Id$
 * $URL$
 * SetupEvalBean.java - evaluation - Mar 18, 2008 4:38:20 PM - azeckoski
 **************************************************************************
 * Copyright (c) 2008 Centre for Applied Research in Educational Technologies, University of Cambridge
 * Licensed under the Educational Community License version 1.0
 * 
 * A copy of the Educational Community License has been included in this 
 * distribution and is available at: http://www.opensource.org/licenses/ecl1.php
 *
 * <NAME> (<EMAIL>) (<EMAIL>) (<EMAIL>)
 */

package org.sakaiproject.evaluation.tool;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import org.sakaiproject.evaluation.logic.EvalEvaluationService;
import org.sakaiproject.evaluation.logic.EvalEvaluationSetupService;
import org.sakaiproject.evaluation.logic.externals.EvalExternalLogic;
import org.sakaiproject.evaluation.logic.externals.ExternalHierarchyLogic;
import org.sakaiproject.evaluation.logic.model.EvalHierarchyNode;
import org.sakaiproject.evaluation.model.EvalAssignHierarchy;
import org.sakaiproject.evaluation.model.EvalEvaluation;
import org.sakaiproject.evaluation.tool.locators.EvaluationBeanLocator;
import org.sakaiproject.evaluation.utils.ArrayUtils;
import org.sakaiproject.evaluation.utils.EvalUtils;

import uk.org.ponder.messageutil.TargettedMessage;
import uk.org.ponder.messageutil.TargettedMessageList;


/**
 * This action bean helps with the evaluation setup process where needed,
 * this is a pea
 * 
 * @author <NAME> (<EMAIL>)
 */
public class SetupEvalBean {

   /**
    * This should be set to true while we are creating an evaluation
    */
   public boolean creatingEval = false;
   /**
    * This should be set to the evalId we are currently working with
    */
   public Long evaluationId;

   // These are for the Assign screen, which is now bound by UIBoundBooleans
   public Map<String, Boolean> selectedEvalGroupIDsMap = new HashMap<String, Boolean>();
   public Map<String, Boolean> selectedEvalHierarchyNodeIDsMap = new HashMap<String, Boolean>();

   // TODO are these still needed?
// public String[] selectedEvalGroupIds;
// public String[] selectedEvalHierarchyNodeIds;


   private EvalEvaluationService evaluationService;
   public void setEvaluationService(EvalEvaluationService evaluationService) {
      this.evaluationService = evaluationService;
   }

   private EvalExternalLogic externalLogic;
   public void setExternalLogic(EvalExternalLogic externalLogic) {
      this.externalLogic = externalLogic;
   }

   private ExternalHierarchyLogic hierarchyLogic;
   public void setExternalHierarchyLogic(ExternalHierarchyLogic logic) {
      this.hierarchyLogic = logic;
   }

   private EvalEvaluationSetupService evaluationSetupService;
   public void setEvaluationSetupService(EvalEvaluationSetupService evaluationSetupService) {
      this.evaluationSetupService = evaluationSetupService;
   }

   private EvaluationBeanLocator evaluationBeanLocator;
   public void setEvaluationBeanLocator(EvaluationBeanLocator evaluationBeanLocator) {
      this.evaluationBeanLocator = evaluationBeanLocator;
   }

   private TargettedMessageList messages;
   public void setMessages(TargettedMessageList messages) {
      this.messages = messages;
   }

   private Locale locale;
   public void setLocale(Locale locale){
      this.locale=locale;
   }


   DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
   public void init() {
      df = DateFormat.getDateInstance(DateFormat.LONG, locale);
   }

   
   // Action bindings

   /**
    * Handles removal action from the remove eval view
    */
   public String removeEvalAction(){
      EvalEvaluation eval = evaluationService.getEvaluationById(evaluationId);
      evaluationSetupService.deleteEvaluation(evaluationId, externalLogic.getCurrentUserId());
      messages.addMessage( new TargettedMessage("controlevaluations.delete.user.message",
            new Object[] { eval.getTitle() }, TargettedMessage.SEVERITY_INFO));
      return "success";
   }


   // NOTE: these are the simple navigation methods
   // 4 steps to create an evaluation: 1) Create -> 2) Settings -> 3) Assign -> 4) Confirm/Save

   /**
    * Completed the initial creation page where the template is chosen
    */
   public String completeCreateAction() {
      evaluationBeanLocator.saveAll();
      return "evalSettings";
   }

   /**
    * Updated or initially set the evaluation settings
    */
   public String completeSettingsAction() {
      EvalEvaluation eval = evaluationService.getEvaluationById(evaluationId);
      evaluationBeanLocator.saveAll();

      String destination = "controlEvals";
      if (creatingEval) {
         destination = "evalAssign";
      } else {
         messages.addMessage( new TargettedMessage("evalsettings.updated.message",
{'fraction_non_alphanumeric': 0.09778708133971292, 'fraction_numerical': 0.004884370015948963, 'mean_word_length': 4.3338649654439125, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3402660', 'n_tokens_mistral': 2843, 'n_tokens_neox': 2661, 'n_words': 693}