I'm wrestling with an issue that I thought some of you may have also experienced. I'm building an app to deploy to Android and iOS. It has a card where a user evaluates a student, giving various items a score from 1 to 4. I've set these items as grouped rows where the scores are also groups. By pressing "1", for example, that group gets selected and the other numbered groups are deselected. mouseUp here also performs a few handlers to do some calculations. Here's the relevant code:
For each of the 4 "buttons":
Code: Select all
// app color scheme
global gColor1, gColor2, gColor3, gColor4, gColor5, gColor6, gColor7, gColor8, gColor9
global gScoreButtonSelected, gBehaviorScores, gStudentDriveBehaviorScores, gObjectiveSelected,gDriveBehaviors, gReadOnly
on mouseUp
   lock screen
   if gReadOnly is true then
      exit mouseUp
      else
   if gScoreButtonSelected is not 1 then
      resetScoreButtons
      set the backgroundColor of graphic "scoreCircle" of me to gColor4
      put 1 into gScoreButtonSelected
      put field "behaviorButtonNumber" of me into tBehaviorButtonNumber
      put 1 into field "behaviorScore" of group ("behaviorButton" & tBehaviorButtonNumber) of card "assessment"
   else
      set the backgroundColor of graphic "scoreCircle" of me to gColor2
      put empty into gScoreButtonSelected
      put field "behaviorButtonNumber" of me into tBehaviorButtonNumber
      put empty into field "behaviorScore" of group ("behaviorButton" & tBehaviorButtonNumber) of card "assessment"
end if
generateStudentDriveBehaviorScores
calculateObjectiveScore
end if
unlock screen
end mouseUp
Code: Select all
// app color scheme
global gColor1, gColor2, gColor3, gColor4, gColor5, gColor6, gColor7, gColor8, gColor9
on resetScoreButtons
   set the backgroundColor of graphic "scoreCircle" of the group "scoreButton1" of me to gColor2
   set the backgroundColor of graphic "scoreCircle" of the group "scoreButton2" of me to gColor2
   set the backgroundColor of graphic "scoreCircle" of the group "scoreButton3" of me to gColor2
   set the backgroundColor of graphic "scoreCircle" of the group "scoreButton4" of me to gColor2
end resetScoreButtonsCode: Select all
on generateStudentDriveBehaviorScores
   put empty into gStudentDriveBehaviorScores
   set itemDel to tab
   repeat with x = 1 to the number of lines of gDriveBehaviors
      put item 6 of line x of gDriveBehaviors into tBehaviorButtonNumber
      if field "behaviorScore" of group ("behaviorButton" & tBehaviorButtonNumber) of card "assessment" is not empty then
         put item 2 of line x of gDriveBehaviors after gStudentDriveBehaviorScores
         put tab & field "behaviorScore" of group ("behaviorButton" & tBehaviorButtonNumber) of card "assessment" after gStudentDriveBehaviorScores
         put tab & item 7 of line x of gDriveBehaviors & return after gStudentDriveBehaviorScores
         end if
   end repeat
end generateStudentDriveBehaviorScoresCode: Select all
on calculateObjectiveScore
   set itemDel to tab
   put 0 into tTotalBehaviorsToScore
   put 0 into tRunningObjectiveScore
   
   repeat with x = 1 to the number of lines of gStudentDriveBehaviorScores
      put item 3 of line x of gStudentDriveBehaviorScores into tObjectiveSequence
      
      if tObjectiveSequence = gObjectiveSelected then
         put item 2 of line x of gStudentDriveBehaviorScores into tBehaviorScore
         add tBehaviorScore to tRunningObjectiveScore
         add 1 to tTotalBehaviorsToScore
         end if
      end repeat
      if tTotalBehaviorsToScore is not 0 then
         
put tRunningObjectiveScore / tTotalBehaviorsToScore into tTotalObjectiveScore
if tTotalObjectiveScore <= 1.25 then
   // 4 stars
   repeat with x = 1 to 4
      set the visible of image ("star" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
      set the visible of image ("halfstar" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   end repeat
else if tTotalObjectiveScore > 1.25 and tTotalObjectiveScore <= 1.75 then
   // 3 1/2 stars
      repeat with x = 1 to 3
      set the visible of image ("star" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
      set the visible of image ("halfstar" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   end repeat
   set the visible of image "halfstar4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
   
else if tTotalObjectiveScore > 1.75 and tTotalObjectiveScore <= 2.25 then
   // 3 stars
         repeat with x = 1 to 3
      set the visible of image ("star" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
      set the visible of image ("halfstar" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   end repeat
   set the visible of image "star4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
      set the visible of image "halfstar4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   
else if tTotalObjectiveScore > 2.25 and tTotalObjectiveScore <= 2.75 then
   // 2 1/2 stars
 set the visible of image "star1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
 set the visible of image "halfstar1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
  set the visible of image "star2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
  set the visible of image "halfstar2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "star3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "halfstar3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
    set the visible of image "star4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
      set the visible of image "halfstar4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   
else if tTotalObjectiveScore > 2.75 and tTotalObjectiveScore <= 3.25 then
   // 2 stars
    set the visible of image "star1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
 set the visible of image "halfstar1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
  set the visible of image "star2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
  set the visible of image "halfstar2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "star3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "halfstar3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    set the visible of image "star4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    set the visible of image "halfstar4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    
else if tTotalObjectiveScore > 3.25 and tTotalObjectiveScore <= 3.75 then
   // 1 1/2 stars
    set the visible of image "star1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
 set the visible of image "halfstar1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
  set the visible of image "star2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
  set the visible of image "halfstar2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "star3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "halfstar3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    set the visible of image "star4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    set the visible of image "halfstar4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    
else if tTotalObjectiveScore > 3.75 then
   // 1 star
    set the visible of image "star1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to true
 set the visible of image "halfstar1" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
  set the visible of image "star2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
  set the visible of image "halfstar2" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "star3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   set the visible of image "halfstar3" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    set the visible of image "star4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
    set the visible of image "halfstar4" of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
 end if
   else
    // no score
   repeat with x = 1 to 4
      set the visible of image ("star" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
      set the visible of image ("halfstar" & x) of group ("objectiveButton" & gObjectiveSelected) of card "assessment" to false
   end repeat
end if
end calculateObjectiveScoreAny suggestions on how to make the "buttons" more responsive would be most appreciated!
Regards,
Sean
