ctad_included("txtmulti_feedback.js");ctad_require("functions.js");ctad_require("persist.js");var TXTMULTI_ATTEMPTS=2;function feedback_popup(activity_name,question_name,image_path,page_number,width,height){if(!image_path){image_path="../../../images";}
if(!activity_name||!question_name){ctad_error("feedback_popup called without activity name and/or question name");return;}
var question=document.ctad.current_module.Activitys[activity_name].Questions[question_name];var result=question.mark();if(result!="i"){check_answer("none",page_number,question.$name,activity_name);return;}
var ar_user_data=question.user_data.split(question.$answer_delimiter);var ar_answer=question.answer.split(question.$answer_delimiter);var ar_html=new Array();var ar_wrong=new Array();var score=0;for(var i=0;i<ar_answer.length;i++){var is_correct=(ar_answer[i]==ar_user_data[i]);var hint_text=feedback_get_hint(question,i,is_correct);ar_html[i]=make_feedback_html(ar_user_data[i],is_correct,image_path,hint_text);if(is_correct){score++;}else{ar_wrong[ar_wrong.length]=String.fromCharCode(i+97);}}
var max_score=i;var sentence=document.getElementById("txtmulti_text").innerHTML;sentence=sentence.replace(/<label.[^<]*<\/label>/gi,"");sentence=sentence.replace(/<option[^<]*<\/option>/gi,"");var j=0;var ar_text=sentence.split(/<select[^<]*<\/select>/i);var replaced_html="";for(var j=0;j<ar_text.length;j++){replaced_html+=ar_text[j];if(ar_html[j]){replaced_html+=ar_html[j];}}
window.popup_html=replaced_html;window.popup_score=score;window.popup_max_score=max_score;window.popup_feedback=get_incorrect_feedback(question);if(window.popup_attempts){window.popup_attempts++;if(window.popup_attempts>TXTMULTI_ATTEMPTS){window.popup_show_model=true;}}else{window.popup_attempts=1;}
check_answer("none",page_number,question.$name,activity_name,width,height);for(var i=0;i<ar_wrong.length;i++){document.forms[activity_name]["q"+question.$name+ar_wrong[i]].selectedIndex=0;}}
function make_feedback_html(user_data,is_correct,image_path,hint_text){if(is_correct){return(user_data+"&nbsp;<img src=\""+image_path+"tick_yellow.gif\" title=\"correct\" border=\"0\" >");}else{return(user_data+"&nbsp;<img src=\""+image_path+"cross_yellow.gif\" title=\""+hint_text+"\" border=\"0\" >");}}
function feedback_get_hint(question,dropdown_index,is_correct){if(is_correct){var return_value="correct";}else{var return_value="incorrect";}
if(!(hints&&hints[question.$name])){return(return_value);}
var dropdown=question.elements[dropdown_index];var answer_index=dropdown.selectedIndex-1;var hints_for_question=hints[question.$name];var ar_hints_for_question=hints_for_question.split("^");if(!ar_hints_for_question[dropdown_index]){return(return_value);}
return(ar_hints_for_question[dropdown_index]);}
function get_incorrect_feedback(question){if(typeof(incorrect_feedback)!="undefined"&&incorrect_feedback[question.$name]){return(incorrect_feedback[question.$name]);}}
