Display a questionnaire's answers in real time
Challenge
In order to keep track of real time response for a questionnaire
As a system consultant
I want to create a portal element showing 2 different answers of a question in every 30 seconds
Solution
- Create a questionnaire cache containing data of the questionnaire
- Create a user-defined portal element with script
- Connect to registered DCS web service to retrieve the data
- Change answers after every 30 seconds
Code
1 var MovieclipViewer3 =
2 {
3 onInit: function(clip, element, linkText)
4 {
5 MovieclipViewer3.flash = CGFlashPlayers.initialize("cgflash", "http://fire.catglobe.com/Script/CGFlashPlayer/CGFlashPlayer.swf", 298,265);
6 MovieclipViewer3.flash.appendTo(element);
7
8 var p = $("<p>");
9 $(p).append($("<u>" + linkText + "</u>").css("cursor","pointer").css("font-style", "italic").click(
10 function()
11 {
12 getPlayList();
13 }
14 ));
15 $(element).append($("<br/>"));
16 $(element).append($(p));
17 $(element).append($("<br/>"));
18
19 MovieclipViewer3.flash.visiblePlaylistButton(false);
20 MovieclipViewer3.flash.visibleControlBar(false);
21 MovieclipViewer3.flash.registerEvent(CGFlashPlayers.Events.OnPlayListReady, MovieclipViewer3.onPlayListReady);
22 MovieclipViewer3.flash.registerEvent(CGFlashPlayers.Events.OnStop, MovieclipViewer3.onStop);
23
24 // Prepare the play list
25 MovieclipViewer3.flash.openPlayList(clip);
26 },
27
28 onPlayListReady: function()
29 {
30 MovieclipViewer3.flash.play();
31 },
32 onStop: function()
33 {
34 getPlayList();
35 }
36 }
37
38 var _this;
39
40 //get the play list
41 function getPlayList()
42 {
43 _this.set_title("Main list");
44 var clipLinks = new Array();
45 clipLinks[0] = "http://fire.catglobe.com/Attachments/GetAttachment.aspx?id=369842";
46 clipLinks[1] = "http://fire.catglobe.com/Attachments/GetAttachment.aspx?id=369843";
47 clipLinks[2] = "http://fire.catglobe.com/Attachments/GetAttachment.aspx?id=369844";
48 clipLinks[3] = "http://fire.catglobe.com/Attachments/GetAttachment.aspx?id=369845";
49 clipLinks[4] = "http://fire.catglobe.com/Attachments/GetAttachment.aspx?id=369846";
50
51 var clipNames = new Array();
52 clipNames[0] = "Clip 1";
53 clipNames[1] = "Clip 2";
54 clipNames[2] = "Clip 3";
55 clipNames[3] = "Clip 4";
56 clipNames[4] = "Clip 5";
57
58 var content = _this.get_contentDiv();
59 content.innerHTML = "";
60 var p = $("<p>").css("padding-bottom", "5");
61 var ul = $("<ul>");
62
63 $(content).append($(p));
64 $(p).append($(ul));
65
66 for(var i= 0; i<clipLinks.length; i++)
67 {
68 $(ul).append($("<li>").text(clipNames[i]).css("cursor","pointer").css("font-style", "italic").val(i)
69 .click(
70 function()
71 {
72 _this.set_title(clipNames[this.value]);
73 MovieclipViewer3.onInit(clipLinks[this.value], content, "<<< Back to main list");
74 }
75 )
76 )
77 }
78 }
79
80 this.onload = function()
81 {
82 _this = this;
83 //play a default clip
84 _this.set_title("Intro");
85 //MovieclipViewer3.onInit("http://fire.catglobe.com/Attachments/GetAttachment.aspx?id=369836", _this.get_contentDiv(), "Skip >>");
86 getPlayList();
87 }