Ignore:
Timestamp:
07/27/12 14:36:59 (12 years ago)
Author:
pharms
Message:
  • added further text entry based evaluation rule
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/TextInputStatisticsRule.java

    r477 r496  
    6060    checkTextInputRatio(statistics, results); 
    6161    checkTextFieldEntryRepetitions(statistics, results); 
     62    checkTextFieldNoLetterOrDigitInputs(statistics, results); 
    6263  } 
    6364 
     
    8889    } 
    8990    else if (ratio > 0.5) 
     91    { 
     92      severity = UsabilityDefectSeverity.LOW; 
     93    } 
     94    else if (ratio > 0.3) 
    9095    { 
    9196      severity = UsabilityDefectSeverity.INFO; 
     
    180185   * TODO: comment 
    181186   * 
     187   * @param statistics 
     188   * @param results 
     189   */ 
     190  //----------------------------------------------------------------------------------------------- 
     191  private void checkTextFieldNoLetterOrDigitInputs(TextInputStatistics       statistics, 
     192                                                   UsabilityEvaluationResult results) 
     193  { 
     194    int allCharactersCount = 0; 
     195    int noLetterOrDigitCount = 0; 
     196 
     197    for (int i = 0; i < statistics.getNoOfTextFieldInputs(); i++) 
     198    { 
     199      String[] fragments = statistics.getTextFieldInputFragments(i); 
     200      for (String fragment : fragments) 
     201      { 
     202        String effectiveFragment = fragment.trim(); 
     203        for (int j = 0; j < effectiveFragment.length(); j++) 
     204        { 
     205          if (!Character.isWhitespace(effectiveFragment.charAt(j))) 
     206          { 
     207            if (!Character.isLetterOrDigit(effectiveFragment.charAt(j))) 
     208            { 
     209              noLetterOrDigitCount++; 
     210            } 
     211            allCharactersCount++; 
     212          } 
     213        } 
     214      } 
     215    } 
     216     
     217    float ratio = (float) noLetterOrDigitCount / (float) allCharactersCount; 
     218     
     219    UsabilityDefectSeverity severity = null; 
     220    if (ratio > 0.1) // every 10th sign 
     221    { 
     222      severity = UsabilityDefectSeverity.HIGH; 
     223    } 
     224    else if (ratio > 0.05) // every 20th sign 
     225    { 
     226      severity = UsabilityDefectSeverity.MEDIUM; 
     227    } 
     228    else if (ratio > 0.02) // every 50th sign 
     229    { 
     230      severity = UsabilityDefectSeverity.LOW; 
     231    } 
     232    else if (ratio > 0.01) // every 100th sign 
     233    { 
     234      severity = UsabilityDefectSeverity.INFO; 
     235    } 
     236     
     237    if (severity != null) 
     238    { 
     239      Map<String, String> parameters = new HashMap<String, String>(); 
     240      parameters.put("noLetterOrDigitRatio", allCharactersCount + " entered characters of " + 
     241                     "which " + noLetterOrDigitCount + " were no letter or digit"); 
     242 
     243      results.addDefect 
     244        (new UsabilityDefect 
     245           (severity, UsabilityDefectDescription.TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO, parameters)); 
     246    } 
     247  } 
     248 
     249  //----------------------------------------------------------------------------------------------- 
     250  /** 
     251   * TODO: comment 
     252   * 
    182253   * @param taskTree 
    183254   * @param statistics 
Note: See TracChangeset for help on using the changeset viewer.