Under the Hood with Learning Interactions


If you're feeling brave, and you don't mind getting your hands a little dirty, you can get under the hood to get information out of and further customize the Learning Interactions. However, before you work with the interactions, it's a good idea to know what information they're currently gathering. You can start by looking at the different variables .

Tip

How do you find out what variables a smart clip is using without getting into the code? Use the Debug function in the Test Movie mode. Choose Debug > List Variables.


Common Variables

Each Learning Interaction has an Assets movie clip. The Assets movie clip is where most of the action takes place. Many of these variables are initialized in the main timeline, but the useful values exist in the Assets movie clip.

These variables are common to all the Learning Interactions:

  • question. The value you entered in the Question field.

  • correctFeedback. The value entered in the Correct Feedback field.

  • incorrectFeedback. The value entered in the Incorrect Feedback field.

  • numOfTries. The value entered in the Tries field. It defaults to 1.

  • Interaction_ID. The value entered in the Interaction ID field.

  • feedback. Either On or Off, depending on whether you chose to give feedback.

  • resultsField. Either C for Correct or W for Wrong.

  • Tracking. Either On or Off, depending on whether you chose to track the answers.

  • navigation. Either Off, Next Button, or Auto GoTo Next Frame. Next Button is returned any time you have both Feedback and Tracking either On or Off. Auto GoTo Next Frame is returned only if Tracking is On and Feedback is Off.

  • maxTries. Same as numOfTries.

  • Type_Interaction. Returns one of the following:

    • F for Fill In The Blank

    • M for Drag And Drop

    • C for Hot Objects, Hot Spot, and Multiple Choice

    • T for True False

  • Weighting . The value entered in the Weighting field on the Tracking tab. It defaults to 1.

  • Objective_ID. The value entered in the Objective ID field on the Tracking tab.

  • now. New date object used to track the date.

  • year. The current year in YYYY format.

  • month. The current month in MM format.

  • day. The current day in DD format.

  • date. Concatenated date in YYYY/MM/DD format.

  • hours. The current hour in HH format.

  • minutes. The current minutes in MM format.

  • seconds. The current seconds in SS format.

  • time. The concatenated time in HH:MM:SS format.

  • sessionStart. 0.

  • feedbackState. True or False

With Knowledge Track selected, all Learning Interactions use these variables as well:

  • sessionStop. Gets the time the session ended from the timer.

  • elapsedTime. Total elapsed time.

  • 1_seconds. Number of seconds it took to complete a try.

  • 1_minutes. Number of minutes it took to complete a try.

  • 1_hours. Number of hours it took to complete a try.

  • Latency. Elapsed time for tries.

  • currentTry. The number of tries it took to complete an interaction.

  • Correct_Response. Returns a list of possible answers in

  • Correct. Returns a list of possible answers in answer1, answer2, answer3 format. {answer1,answer2,answer3} format.

  • submit. Returns the value of the answer submitted in answer format.

  • Student_Response. Returns the value of answer submitted in {answer} format.

  • Result. C for correct, W for wrong.

Each Learning Interaction also has its own specific variables.

Hot Spot and Hot Objects Variables

The Hot Spot and Hot Objects smart clips both use these variables:

  • object1object6. Correct or Incorrect.

  • objectn_value. Depends on which object has a value of correct or True.

  • object1_selectobject6_select. True or False; True for the selected object.

  • object1_resultsobject6_results. Returns Correct for a good choice and Incorrect for a wrong choice or blank.

  • object_1.freezeobject_6.freeze. On or Off.

  • Unlike the Hot Object and Hot Spot smart clips, the Drag And Drop smart clip has a completely unique set of variables.

Drag And Drop Variables

The variables specific to the Drag And Drop smart clip are as follows :

  • drag1drag3. On or Off. Objects set to Off do not show up on the Stage.

  • drag1_targetdrag3_target. The name of the target you're dragging to, target1target3.

  • initial_drag1Xinitial_drag3X. Initial X position of draggable object.

  • initial_drag1Yinitial_drag3Y. Initial Y position of draggable object.

  • drag1_choicedrag3_choice. The target to which the draggable object should be dragged: target1target3.

  • drag1_resultsdrag3_results. Correct or Incorrect.

  • drag_1.drag1_choice. The target on which you dropped drag1 (target1target3).

  • drag_1.drag1X. The X position where drag1 was dropped.

  • drag_1.drag1Y. The Y position where drag1 was dropped.

  • drag_2.drag2_choice. The target on which you dropped drag2 (target1target3).

  • drag_2.drag2X. The X position where drag2 was dropped.

  • drag_2.drag2Y. The Y position where drag2 was dropped.

  • drag_3.drag3_choice. The target on which you dropped drag3 (target1target3).

  • drag_3.drag3X. The X position where drag3 was dropped.

  • drag_3.drag3Y. The Y position where drag3 was dropped.

The next variable list is relatively short because the Fill In The Blank interaction is not as complex as the Drag And Drop interaction.

Fill In The Blank Variables

The variables specific to the Fill In The Blank smart clip are as follows:

  • Response1Response3. Possible responses to the question.

  • Response1_valueResponse3_value. Correct or Incorrect.

  • OtherResponses. Correct or Incorrect.

  • CaseSensitive. On or Off.

  • ExactMatch. On or Off.

  • Response1_resultsResponse3_results. Correct, Incorrect, and No Match.

The Multiple Choice variables have to capture all the values the user enters, regardless of whether they are correct.

Multiple Choice Variables

The variables specific to the Multiple Choice smart clip are as follows:

  • choice_achoice_g. The values you entered as possible answers.

  • answer_aanswer_g. True if the Correct radio button was selected, and blank otherwise .

  • value_avalue_g. Returns a number 17 for each possible choice AG.

  • totalAnswers. The total number of possible answers. Defaults to 2, and might be as high as 7.

  • check_acheck_e. True or blank, depending on whether the user selected this as an answer.

  • totalChecks. The number of answers the user chose, regardless of whether they're correct.

  • evaluation_aevaluation_g. Correct, incorrect, or blank, depending on whether the answer was correct.

The True False interaction is a simple one, so the variable list is short. The variables just need to capture which answer is correct versus the choice the user made.

True False Variables

The variables specific to the True False smart clip are as follows:

  • answer_a_value. Correct if A was selected as correct, and incorrect otherwise.

  • answer_b_value. Correct if B was selected as correct, and incorrect otherwise.

  • answer_a_results. Correct if A was selected and A was the correct answer, and incorrect otherwise.

  • answer_b_results. Correct if B was selected and B was the correct answer, and incorrect otherwise.

  • radio_false.radio_false_value. True if selected by the user, and blank otherwise.

  • radio_true.radio_true_value. True if selected by the user, and blank otherwise.

That's a lot of variables available for your use. Now that you know what variables you have access to, it's time to get busy and learn how to use them.

Working with the Variables

So, you don't have the option of hooking into an LMS. What to do? You improvise, you adapt, you overcome !

The first thing you need to know is that the variables captured by each Learning Interaction has what is known as a local scope , which means that the variables exist only while you're in that interaction, and then they're released. This occurs because the Learning Interactions use the Call function. That means that you need to capture the variables before you exit the movie clip. Fortunately, that's not too difficult to do, but it does require some coding on your part.

You can capture any or all the variables described in the earlier sections of this chapter, but for the sake of brevity, you'll just work with a few of those variables for now. What if you want to be able to give your students a final score as well as report how long it took them to complete the quiz? To do this, you'll need to capture the following variables for each interaction:

  • result

  • weighting

  • elapsedTime

You'll capture these values as unique variables at the root level of the movie clip, and then on the final frame of your movie, you'll perform the calculations you need for the final score.

Exercise 21.11 Setting Up the Learning Interactions to Capture Variables

The updated variable information is actually found in the asset movie clip of each interaction, not in the interaction's main timeline, but you want to send the data to the root of your movie so that it is available globally. You start by setting up a series of arrays to capture the data coming in from the Learning Interactions. Then you'll create a single ActionScript file that you'll include in each Learning Interaction. This makes it easy for you to add in or remove variables later; you need only edit one file and you're good to go.

  1. You still should be working in learn.fla or you can open learn6.fla from the Chapter 21/Assets folder on the CD.

  2. You're going to capture information about whether the student got the correct answer (results), the weighting for the question (weighting), and the time, in seconds, it took to answer each question (elapsedTime). Set up the arrays to hold this information by adding the following code to the Actions list in frame 1 of the Actions layer:

     totalScore = new Array();  totalWeighting = new Array();  totalElapsedTime = new Array(); 
  3. Now that the arrays are set up, it's time to send them some information. You want to push information from each of the Learning Interactions into the arrays at the root level. The push function will be the same for each interaction, so create an .as file that you can include in each interaction. In your text editor of choice (you also can do this in the Actions panel), enter the following code:

     //Add to the arrays in the root to track progress  _root.totalScore.push(result);  _root.totalWeighting.push(weighting);  _root.totalElapsedTim.push(elapsedTime); 
  4. Save the code you just entered as manage.as in the same directory as your Flash movie.

  5. Select the Learning Interaction in frame 1 of the main timeline. Double-click the interaction until you're inside the FB_Assets movie clip. Alternately, you can double-click the FB_Assets movie clip in the Library. Scroll down to the bottom layer named Scripts, and select the frame labeled Send Data (frame 65). (See Figure 21.22.)

    Figure 21.22. You'll be adding code to a frame that is used by the Call action to capture the data you need. For this interaction, you'll add code to frame 65.

    graphics/21fig22.gif

  6. If you aren't using an LMS, you can alter the code here to capture the data you need. Either remove or comment out the existing code and enter the following:

     #include "manage.as" 

    Notice that there is no semicolon at the end of this statement. If you add a semicolon, like you do for most statements, you cause a syntax error.

  7. Copy the code and paste it in the appropriate frames of the other Learning Interactions (comment out or delete the existing code). Remember that you need to be in the Assets movie clip of the Learning Interaction to make these changes. Double-clicking the interaction twice gets you where you need to be. You'll add the include statement to the following frames :

    Drag And Drop: frame 67

    Hot Objects: frame 53

    Hot Spot: frame 53

    Multiple Choice: frame 69

    True False: frame 30

  8. If you want to see whether you're getting any results, you can set up a series of Trace actions in the manage.as file to check both the variables and the array lengths. For example:

     trace("Result: " + result);  trace("Weighting: " + weighting);  trace("ElapsedTime: " + elapsedTime);  trace("ScoreLength: " + _root.totalScore.length);  trace("WeightingLength " + _root.totalWeighting.length);  trace("SecondsLength: " + _root.totalElapsedTime.length); 
  9. Save both your manage.as file and your Flash file and then test your movie. Make sure you're getting the results you expect from the Trace actions in the output window. If you're not, you need to start debugging; set as many Trace actions as you need in your file to help pinpoint the problem. You can always exclude them on export, so it doesn't add to the file weight.

Tip

If you're not getting any values in the Output window, go back and make sure that you checked Knowledge Track on the Tracking tab in the Clip Parameters panel for each interaction.


Now you're ready to start working with the variables you've captured.

Scoring the Interactions

Okay, now that you've figured out how to capture the variables you need, what are you going to do with them? The first issue to deal with is the scoring. You have six questions, all with a weighting of 1. You need to figure out how many questions the user got right. Because the questions could have different weightings (they don't in this case), you need to track the weighting to help figure out the final percent grade. Start with these two, and then you'll move into calculating the total elapsed time.

However, before you get into the calculations, set up a dynamic text box on the Stage to display the score.

Exercise 21.12 Setting Up the Dynamic Text Boxes to Display Your Output

To display a final score, you need to add a new frame and set up a couple dynamic text boxes to receive the values that you'll calculate.

  1. You still should be working in learn.fla or you can open learn7.fla from the Chapter 21/Assets folder on the CD.

  2. Select the Learning Interaction in frame 6 and open the Clip Parameters panel. Select the Navigation tab and change the navigation setting from None to Next Button.

  3. Select frame 7 in both layers of the main timeline and insert a blank keyframe (Insert > Blank Keyframe).

  4. Add a stop() action to frame 7 in the Actions layer.

  5. Select the Text tool, open the Character panel, and set the Font height to 22.

  6. Still in frame 7, select the Learn layer and type the following lines:

    Your score is:

    Total elapsed time is:

  7. Switch to the Text Options panel and change the following settings:

    Text Type: Dynamic Text

    Line Type: Single Line

    HTML: Not selected

    Border/BG: Selected

    Selectable: Not selected

  8. Draw a text box on the Stage large enough to hold several characters . Duplicate the text box you just drew, and align the two text boxes to the right of the text you placed on the Stage in Step 6 (see Figure 21.23).

    Figure 21.23. Align the static text and dynamic text boxes on the Stage.

    graphics/21fig23.gif

  9. Select the first text box and change the Variable setting on the Text Options panel to this:

    Variable: Score

    Change the variable setting for the second text box to this:

    Variable: finalElapsedTime

  10. Save your file.

Now you're ready to start the calculations.

Exercise 21.13 Calculating the Score

The final score is going to be a combination of the number of questions answered correctly against the weighting for each answer.

  1. You still should be working in learn.fla or you can open learn8.fla from the Chapter 21/Assets folder on the CD.

  2. Select frame 7 of the Actions layer in the main timeline and launch the Actions panel.

  3. You're going to be looping over the arrays you set up earlier and extracting values based on the array index. One of the values you'll need is the lengths of the arrays, which are all the same length. Pick one of the arrays and determine its length. In the Actions list, enter the following line of code after the stop() action:

     scoreLength = _root.totalScore.length; 
  4. Now you're ready to set up your loop. The for loop would be an effective choice here because you can automatically track an indexing variable, check it against the array length, and then increment the index. No muss, no fuss. Enter the following code after the scoreLength line:

     for (i=0; i < scoreLength; i++) { } 
  5. What do you need to track? The first thing you want to know is if the student answered the question correctly. If he or she did, you want to capture the weighting for that answer and add it to a variable. If he or she missed this question, you still need to keep track of the total of all the weightings. To track these values, enter the following code between the curly braces of the for loop:

     if (_root.totalScore[i]=="C") { final = final + _root.totalWeighting[i];  }  final_weighting = final_weighting + _root.totalWeighting[i]; 
  6. It's good programming practice to initialize your variables. Enter the following two lines of code right above your for loop (check Listing 21.1 if you need to):

     final = 0;  final_weighting = 0; 
  7. You're almost there. You've got all the information you need; now you just need to calculate the final score. Think back to that math class so many years ago you're going to take the weighting total for the questions the student got right (final) and divide that by the total possible weighting (final_weighting). Then you multiply that number by 100 and round it to get a nice even number. All you have to do is enter the following line after the last curly brace :

     _root.Score = math.round((final/final_weighting)*100); 

That's it! Save and test your file. After you answer all the questions, you should see your score. If you're having problems, check Listing 21.1 for the final code; make sure yours matches. Also make sure you assigned the correct variable name (Score) to the text box on the Stage.

Listing 21.1 The Final Code for Determining a Student's Score
 scorelength = _root.totalScore.length;  final = 0;  final_weighting = 0;  //set up the first loop  for (i=0; i < scoreLength; i++) {     if (_root.totalScore[i]=="C") {     final = final + _root.totalWeighting[i];      }      final_weighting = final_weighting + _root.totalWeighting[i];  }  _root.Score = math.round((final/final_weighting)*100); 

You also want to show the student how long it took him or her to answer all the questions. You've been capturing these values in an arraytotalElapsedTime[]. You need to cycle through the array and add all the values together. The easiest way to do this is to add them into the existing for loop. Getting the time to display in an understandable format is little bit of a trick, but not too scary.

The easiest way to make this clear is to plunge directly into the next exercise. Take a deep breath and go for it.

Exercise 21.14 Calculating and Formatting the Elapsed Time

The first thing you need to do is add a line of code in the for loop to add all the elapsed times. This would be a reasonable point to ask this question: Why not use the getTimer() function? You want to track only the time when the student is actually working on a particular exercise. The timing starts when the movie clip loads, and it ends when the student presses the Check Answer button. The getTimer() function tracks the total elapsed time from the moment the movie loads.

  1. You still should be working in learn.fla or you can open learn9.fla from the Chapter 21/Assets folder on the CD.

  2. With frame 7 of the Actions layer selected, enter the line of code between the asterisks into your Actions list:

     stop();  scoreLength = _root.totalScore.length;  final = 0;  final_weighting = 0;  for (i=0; i < scoreLength; i++) {     if (_root.totalScore[i]=="C") {         final = final + _root.totalWeighting[i];  //****************************************************************          elapsedTime = elapsedTime + _root.totalElapsedTime[i];  //****************************************************************      }  final_weighting = final_weighting + _root.totalWeighting[i];  }  _root.Score = math.round((final/final_weighting)*100); 
  3. That's all you need to add inside your loop; the rest of the code just formats the output for the elapsed time. You need to take the elapsedTime, which is in seconds, and convert it to minutes and seconds. For the sake of clarity, you'll add preceding zeros if either the minutes or seconds are less than zero. To set up the format for the time, add the following code after the last line of code in the Actions list:

     // Figure out and format elapsed time  //  totalSeconds = elapsedTime;  minutes = math.floor(elapsedTime/60);  if (number(minutes) < 10) {     minutes = "0" + minutes;  }  seconds = totalSeconds - (minutes*60);  if (number(seconds) < 10) {     seconds = "0" + seconds;  } 
  4. Finally, add a line after the last curly brace to send the output to the variable on the Stage:

     finalElapsedTime = minutes + ":" + seconds; 
  5. Save and test your file.

Take the test and see what your total score and elapsed time are. (See Figure 21.24.) If you're having any problems, check Listing 21.2. You also can check the learn_final.fla file in the Chapter_21/Assets folder. Make sure that your code matches! You don't need the commented lines in your version.

Figure 21.24. When you've completed the exercise, test your movie. After you've answered all the questions, you'll be able to see your final score and total elapsed time.

graphics/21fig24.gif

Listing 21.2 The Final Code for Determining Both the Student's Score and the Total Elapsed Time
 // initialize the variables  scorelength = _root.totalScore.length;  final = 0;  final_weighting = 0;  elapsedTime = 0;  // set up the first loop  for (i=0; i<scoreLength; i++) {     if (_root.totalScore[i] == "C") {         final = final+_root.totalWeighting[i];      }      final_weighting = final_weighting+_root.totalWeighting[i];      elapsedTime = elapsedTime + _root.totalElapsedTime[i];  }  _root.Score = math.round((final/final_weighting)*100);  //  // Figure out and format elapsed time  //  totalSeconds = elapsedTime;  minutes = math.floor(elapsedTime/60);  if (number(minutes) < 10) {     minutes = "0" + minutes;  }  seconds = totalSeconds - (minutes*60);  if (number(seconds) < 10) {     seconds = "0" + seconds;  }  finalElapsedTime = minutes + ":" + seconds; 

Who needs a Learning Management System? You're on the way to creating your own! Think about what the next logical step here would besending this information to a database. All you would have to do is use loadVariables and call a URL with the code in it to upload this information to a database. As you can see, with a little digging under the surface of the Learning Interactions, the sky is the limit.



Inside Flash
Inside Flash MX (2nd Edition) (Inside (New Riders))
ISBN: 0735712549
EAN: 2147483647
Year: 2005
Pages: 257
Authors: Jody Keating

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net