home *** CD-ROM | disk | FTP | other *** search
- class com.argosy.ui.SummaryViewer extends com.argosy.ui.baseUI
- {
- var activity_mode;
- var correct_count;
- var content_mc;
- var mask;
- var question_items;
- var scroll_bar;
- var summary_style;
- var reset_button;
- var top_feedback;
- var bg;
- var dispatchEvent;
- function SummaryViewer()
- {
- super();
- }
- function clearContent()
- {
- this._visible = false;
- }
- function setContent(act_mode, question_array)
- {
- trace("Summary: setContent");
- this._visible = true;
- this.activity_mode = act_mode;
- this.correct_count = 0;
- this.content_mc = this.createEmptyMovieClip("content_mc",3);
- this.content_mc.setMask(this.mask);
- this.content_mc._y = this.mask._y;
- this.question_items = [];
- var _loc3_ = 0;
- while(_loc3_ < question_array.length)
- {
- var _loc2_ = this.content_mc.createEmptyMovieClip("item_" + _loc3_,1 + _loc3_);
- _loc2_.question_object = question_array[_loc3_];
- _loc2_.isOpen = false;
- _loc2_.bg = _loc2_.createEmptyMovieClip("bg",1);
- _loc2_.image_button = _loc2_.attachMovie("folder_arrow","image_button",300);
- _loc2_.image_button._x = 10 + _loc2_.image_button._width / 2;
- _loc2_.image_button._y = 10 + _loc2_.image_button._height / 2;
- _loc2_.image_button.onPress = ascb.util.Proxy.create(this,this.toggle_image,_loc2_);
- _loc2_.label_tf = this._createTextField(_loc2_,"label_tf",100,30,10,this.width - this.scroll_bar._width - 50,20,this.summary_style,"");
- _loc2_.label_tf.multiline = true;
- _loc2_.label_tf.wordWrap = true;
- _loc2_.label_tf.autoSize = true;
- if(question_array[_loc3_].isCorrect)
- {
- this.correct_count = this.correct_count + 1;
- _loc2_.label_tf.htmlText = "<p><title>Problem " + (_loc3_ + 1) + ": </title> <summary_right>Correct</summary_right></p>";
- }
- else
- {
- _loc2_.label_tf.htmlText = "<p><title>Problem " + (_loc3_ + 1) + ": </title> <summary_wrong>Incorrect</summary_wrong></p>" + this.buildSummaryText(question_array[_loc3_]);
- }
- _loc2_.label_tf.htmlText += "<p align =\'right\'>" + (_loc3_ + 1) + " out of " + question_array.length + "</p>";
- _loc2_.image_button._visible = question_array[_loc3_].image != undefined;
- this.draw_item(_loc2_);
- _loc2_.image_bitmap = question_array[_loc3_].image;
- this.question_items.push(_loc2_);
- _loc3_ = _loc3_ + 1;
- }
- this.layout_items();
- if(this.activity_mode == "Lab Practical")
- {
- this.reset_button = this.attachMovie("take_exam_again_button","reset_button",10);
- }
- else
- {
- this.reset_button = this.attachMovie("take_quiz_again_button","reset_button",10);
- }
- this.reset_button.onRelease = ascb.util.Proxy.create(this,this.reset_button_press);
- this.reset_button._x = 10 + this.reset_button._width / 2;
- this.reset_button._y = this.mask._y + this.mask._height + this.reset_button._height / 2 + 10;
- if(this.correct_count == question_array.length)
- {
- this.top_feedback.htmlText = "<p><topfeedback>You answered all <summary_right>" + question_array.length + "</summary_right> questions correctly.</topfeedback></p>";
- }
- else
- {
- this.top_feedback.htmlText = "<p><topfeedback>You answered <summary_wrong>" + this.correct_count + "</summary_wrong> out of <summary_right>" + question_array.length + "</summary_right> questions correctly.</topfeedback></p>";
- }
- this.scroll_bar.position = 0;
- }
- function buildSummaryText(current_question)
- {
- var _loc3_ = current_question.isCorrect;
- var _loc4_ = "";
- switch(current_question.type)
- {
- case "fill_in":
- if(_loc3_ == false || _loc3_ == null)
- {
- if(current_question.user_input == undefined || current_question.user_input == "")
- {
- _loc4_ = "<p>The correct answer was: <summary_right>" + current_question.answers[0] + "</summary_right></p>";
- }
- else
- {
- _loc4_ = "<p>You said: <summary_wrong>" + current_question.user_input + "</summary_wrong> but the correct answer was: <summary_right>" + current_question.answers[0] + "</summary_right></p>";
- }
- }
- break;
- case "multi_choice":
- if(_loc3_ == false || _loc3_ == null)
- {
- if(current_question.answer_text == undefined)
- {
- var _loc2_ = 0;
- while(_loc2_ < current_question.options.length)
- {
- if(current_question.options[_loc2_].correct)
- {
- current_question.answer_text = current_question.options[_loc2_].label;
- break;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- if(_loc3_ == false || _loc3_ == null)
- {
- if(current_question.user_input == undefined)
- {
- _loc4_ = "<p>The correct answer was: <summary_right>" + current_question.answer_text + "</summary_right></p>";
- }
- else
- {
- _loc4_ = "<p>You said: <summary_wrong>" + current_question.user_input + "</summary_wrong> but the correct answer was: <summary_right>" + current_question.answer_text + "</summary_right></p>";
- }
- }
- }
- break;
- case "true_false":
- var _loc5_ = current_question.answer.split("");
- _loc5_[0] = _loc5_[0].toUpperCase();
- var _loc6_ = _loc5_.join("");
- if(_loc3_ == false || _loc3_ == null)
- {
- _loc4_ = "<p>The correct answer was: <summary_right>" + _loc6_ + "</summary_right></p>";
- }
- break;
- case "matching":
- if(_loc3_ == false)
- {
- _loc4_ = "<p>You matched <summary_wrong>" + current_question.correct_count + "</summary_wrong> out of <summary_right>" + current_question.question_count + "</summary_right> correctly.</p>";
- }
- else if(_loc3_ == undefined || _loc3_ == null)
- {
- _loc4_ = "<p>You matched <summary_wrong>0</summary_wrong> out of <summary_right>" + current_question.questions.length + "</summary_right> correctly.</p>";
- }
- break;
- case "flag":
- case "pin":
- if(_loc3_ == false)
- {
- _loc4_ = "<p>You labeled <summary_wrong>" + current_question.correct_count + "</summary_wrong> out of <summary_right>" + current_question.question_count + "</summary_right> correctly.</p>";
- }
- else if(_loc3_ == undefined || _loc3_ == null)
- {
- _loc4_ = "<p>You labeled <summary_wrong>0</summary_wrong> out of <summary_right>" + current_question.hotspot_array.length + "</summary_right> correctly.</p>";
- }
- }
- return _loc4_;
- }
- function draw_item(mc)
- {
- if(mc.isOpen)
- {
- mc.image = mc.createEmptyMovieClip("image",200);
- mc.image.attachBitmap(mc.image_bitmap,1,true,true);
- mc.image._xscale = mc.image._yscale = 90;
- mc.image._y = mc.label_tf._y + mc.label_tf._height + 10;
- mc.image._x = (this.width - this.scroll_bar._width - 20) / 2 - mc.image._width / 2;
- var _loc4_ = mc.image._y + mc.image._height + 20;
- }
- else
- {
- mc.image.removeMovieClip();
- _loc4_ = mc.label_tf._y + mc.label_tf._height;
- }
- var _loc3_ = 2;
- mc.bg.clear();
- mc.bg.lineStyle(0,0,0);
- mc.bg.beginFill(9543123,20);
- com.drawing.drawUtil.drawRect(mc.bg,_loc3_,_loc3_,this.width - this.scroll_bar._width - _loc3_ - 10,_loc4_ - _loc3_,10);
- mc.bg.endFill();
- }
- function toggle_image(image_mc)
- {
- image_mc.isOpen = !image_mc.isOpen;
- image_mc.image_button._rotation = !image_mc.isOpen ? 0 : 90;
- image_mc.image._visible = image_mc.isOpen;
- this.draw_item(image_mc);
- this.layout_items();
- }
- function layout_items()
- {
- trace("layout_items");
- var _loc2_ = 0;
- while(_loc2_ < this.question_items.length)
- {
- if(_loc2_ == 0)
- {
- this.question_items[_loc2_]._y = 0;
- }
- else
- {
- this.question_items[_loc2_]._y = this.question_items[_loc2_ - 1]._y + this.question_items[_loc2_ - 1].bg._height + 2;
- }
- _loc2_ = _loc2_ + 1;
- }
- this.set_scroll(this.question_items[this.question_items.length - 1]._y + this.question_items[this.question_items.length - 1].bg._height + 10);
- }
- function init()
- {
- trace("INIT::SummaryViewer");
- this.summary_style = new TextField.StyleSheet();
- this.summary_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#000000",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
- this.summary_style.setStyle("topfeedback",{display:"inline",fontFamily:"Frutiger Bold",fontSize:"18",color:"#000000"});
- this.summary_style.setStyle("title",{display:"inline",fontFamily:"Frutiger Bold",fontSize:"14",color:"#000000"});
- this.summary_style.setStyle("summary_right",{display:"inline",fontFamily:"Frutiger Bold",color:"#009900"});
- this.summary_style.setStyle("summary_wrong",{display:"inline",fontFamily:"Frutiger Bold",color:"#990000"});
- super.init();
- this.clearContent();
- }
- function set_scroll(h)
- {
- var _loc2_ = this.content_mc._height;
- if(_loc2_ > this.mask._height)
- {
- this.scroll_bar.setReferenceSize(_loc2_,this.mask._height);
- this.scroll_bar._visible = true;
- this.scroll_bar.position = (this.mask._y - this.content_mc._y) / (this.content_mc._height - this.mask._height);
- }
- else
- {
- this.scroll_bar.setReferenceSize(this.mask._height,this.mask._height);
- this.scroll_bar._visible = false;
- }
- }
- function scroll_event(evt)
- {
- this.content_mc._y = this.mask._y - (this.content_mc._height - this.mask._height) * evt.value;
- }
- function createChildren()
- {
- this.top_feedback = this._createTextField(this,"top_feedback",100,0,0,10,20,this.summary_style,"");
- this.top_feedback.autoSize = true;
- this.bg = this.createEmptyMovieClip("bg",1);
- this.mask = this.createEmptyMovieClip("mask",2);
- this.scroll_bar = this.attachMovie("ScrollBar","scroll_bar",4);
- this.scroll_bar.addEventListener("onScroll",this,"scroll_event");
- }
- function reset_button_press()
- {
- trace("reset");
- this.dispatchEvent({type:"reset_activity",target:this});
- }
- function layout()
- {
- this.bg.clear();
- this.bg.lineStyle(0,16777215,100);
- this.bg.beginFill(16777215,0);
- this.bg.lineTo(this.width,0);
- this.bg.lineTo(this.width,this.height);
- this.bg.lineTo(0,this.height);
- this.bg.lineTo(0,0);
- this.bg.endFill();
- this.mask._y = 30;
- this.mask.clear();
- this.mask.lineStyle(0,16711680,0);
- this.mask.beginFill(16711680,0);
- this.mask.moveTo(0,0);
- this.mask.lineTo(this.width - this.scroll_bar._width,0);
- this.mask.lineTo(this.width - this.scroll_bar._width,this.height - 60);
- this.mask.lineTo(0,this.height - 60);
- this.mask.lineTo(0,0);
- this.mask.endFill();
- this.scroll_bar._y = this.mask._y;
- this.scroll_bar._x = this.mask._width;
- this.scroll_bar.height = this.mask._height;
- }
- }
-