السلام عليكم
حملت احد المشاريع المفتوحة
و نطلع لي رسالة كما في الصورة التالية
https://f.top4top.net/p_721kinko1.png
حملت احد المشاريع المفتوحة
و نطلع لي رسالة كما في الصورة التالية
https://f.top4top.net/p_721kinko1.png
--################################################################################################## --## This function is used on the Radiobutton to select the clicked item as the choosen answer --################################################################################################## function RBSelect(sRBName) --Get the number of the radio button nA = String.ToNumber(String.Right(sRBName, 1)); --Get the checked state if RadioButton.GetChecked(sRBName) then --If checked then set the xml path for the answer to selected XML.SetAttribute(strXMLPath.."/answer:"..nA, "selected", "y"); Paragraph.SetProperties("Answer"..nA, {FontWeight=700,BorderStyle=1}); --Remove the selected option from the other answers --as only one item should be selected at a time. for x = 1,4 do if nA ~= x then XML.RemoveAttribute(strXMLPath.."/answer:"..x, "selected"); Paragraph.SetProperties("Answer"..x, {FontWeight=400,BorderStyle=0}); end end end end --################################################################################################## --## This function is used on the CheckBox to select the clicked item as the choosen answer --################################################################################################## function CBSelect(sCBName) --Get the number of the Checkbox nA = String.ToNumber(String.Right(sCBName, 1)); --Get the checked state if CheckBox.GetChecked(sCBName) then --If checked then set the xml path for the answer to selected XML.SetAttribute(strXMLPath.."/answer:"..nA, "selected", "y"); --set color for the border. FFFFFF = white 0000FF = blue --this is used to visually distinguish which items were selected nBColor = Math.HexColorToNumber("0000FF"); Paragraph.SetProperties("Answer"..nA, {FontWeight=700,BorderColor=nBColor}); --If the CheckBox is not checked then perform the following actions --These actions will reset the answer to it's default state elseif not CheckBox.GetChecked(sCBName) then XML.RemoveAttribute(strXMLPath.."/answer:"..nA, "selected"); Paragraph.SetProperties("Answer"..nA, {FontWeight=400,BorderColor=0}); end end --################################################################################################## --## This function is used to populate the question and answer fields in the quiz --################################################################################################## function PopulateQuiz(nQuesNum) local nCQ = tbRnd[nQuesNum] -- set the path for the question including the question number strXMLPath = "quiz/items/item:".. nCQ; --Extract the first question local sQuestion = XML.GetValue(strXMLPath .."/question"); Paragraph.SetText("P-Question", "السؤال "..nQuesNum.." من :"..nQtA.."\r\n"..sQuestion); --Extract the question type local sQType = XML.GetAttribute(strXMLPath .."/question", "type"); --Reset the answer objects as well as the CheckBoxes and Radio Buttons on the page. for x = 1,4 do RadioButton.SetVisible("RadioButton"..x, false); RadioButton.SetChecked("RadioButton"..x, false); CheckBox.SetVisible("CheckBox"..x, false); CheckBox.SetChecked("CheckBox"..x, false); Paragraph.SetVisible("Answer"..x, false); Paragraph.SetProperties("Answer"..x, {Text="",FontWeight=400,BorderStyle=1,BorderColor=0}); end --Check the question type so we kwow if we should use the --Check boxes or Radio buttons if sQType == "ms" then ---Show and populate the appropriate objects if the question is Multi-select for x = 1,XML.Count(strXMLPath, "answer") do CheckBox.SetVisible("CheckBox"..x, true); Paragraph.SetVisible("Answer"..x, true); Paragraph.SetText("Answer"..x, XML.GetValue(strXMLPath.."/answer:"..x)); end ---Show and populate the appropriate objects if the question is Multiple Choice or True/False elseif sQType == "mc" or sQType == "tf" then ---Show and populate the appropriate objects for x = 1,XML.Count(strXMLPath, "answer")) do RadioButton.SetVisible("RadioButton"..x, true); Paragraph.SetVisible("Answer"..x, true); Paragraph.SetText("Answer"..x, XML.GetValue(strXMLPath.."/answer:"..x)); end end end --################################################################################################## --## This function is used to score the quiz. --## This function will return a table containing the number of correct answers --## and the users score as a numerical percentage. --################################################################################################## function ScoreQuiz(tbQuiz) --by loading the table that contains the list of questions asked in the quiz --we will use that same table to step through the loaded XML file to --score the quiz local nCorrect = 0; local tbReturn = {}; --Use a for loop to step through each question asked and score if correct. for i,v in pairs(tbQuiz) do --get the path to the question local strXMLPath = "quiz/items/item:".. v; --Set boolean variable to a default of true local bCorrect = true --Step through each answer to see if they were answered correctly --If any answer was incorrectly selected then bCorrect will be set to false for x = 1,XML.Count(strXMLPath, "answer") do --Check to see if the answer was correctly selected --The correct attribute for the answer should match the selected attribute inorder to be correct if XML.GetAttribute(strXMLPath.."/answer:"..x, "correct") ~= XML.GetAttribute(strXMLPath.."/answer:"..x, "selected") then --If they don't match then mark this answer as incorrect and break out of the loop bCorrect = false break; --This will break out of the for loop end end --If all the answers were correctly selected then increment nCorrect by one. if bCorrect then nCorrect = nCorrect+1; end end --Populate the tbReturn table to be exported for this function tbReturn.Correct = nCorrect; tbReturn.Score = Math.Round((nCorrect/Table.Count(tbQuiz))*100,0); return tbReturn; end --################################################################################################## --## This function is used to perform a page clickobject when the answer is clicked on the page --################################################################################################## function ClickSelect(nObj) -- If the checkbos is visible perform the following actions if CheckBox.IsVisible("CheckBox"..nObj) then --The following actions will toggle the state of the checkbox if CheckBox.GetChecked("CheckBox"..nObj) then CheckBox.SetChecked("CheckBox"..nObj, false); else CheckBox.SetChecked("CheckBox"..nObj, true); end --After setting the state of the checkbox this action will then click on the object Page.ClickObject("CheckBox"..nObj); else --The following action will check the radio box and then click on the object. RadioButton.SetChecked("RadioButton"..nObj, true); Page.ClickObject("RadioButton"..nObj); end end ------------------------------------------------------------------------------ تحريك الصور ---------------- --Enter global declarations and functions here... --Like Worm's Function only with some additional features function HitTestEx() local mi local mtblPos local mObject local mtblObj local mtblPos = nil local mtblDimension = nil local mtblHits = {} local mType mtblObj = Page.EnumerateObjects() for mi, mObject in pairs (mtblObj) do mObjType = Page.GetObjectType(mObject) ------ if mObjType == OBJECT_IMAGE then mtblPos = Image.GetPos(mObject) mtblDimension = Image.GetSize(mObject) end if mtblPos then mX=String.ToNumber(DLL.CallFunction("AutoPlay\\Docs\\mouse.dll", "GetMouseX", Application.GetWndHandle(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)) mY=String.ToNumber(DLL.CallFunction("AutoPlay\\Docs\\mouse.dll", "GetMouseY", Application.GetWndHandle(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)) if (mtblPos.X <= mX) and (mX <= (mtblPos.X + mtblDimension.Width)) then if (mY >= mtblPos.Y) and (mY <= (mtblPos.Y + mtblDimension.Height)) then mtblHits[Table.Count(mtblHits) + 1] = {Type = mObjType, Name = mObject, Xpos=mtblPos.X, Ypos=mtblPos.Y}; end end end end return mtblHits; end --This Functions moves any object function MoveObject(strObName,nObType,nXPos,nYPos) if nObType == OBJECT_IMAGE then mtblPos = Image.SetPos(strObName,nXPos,nYPos); end end ----- ----- -----
--################################################################################################## --## this function is used on the radiobutton to select the clicked item as the choosen answer --################################################################################################## function rbselect(srbname) --get the number of the radio button na = string.tonumber(string.right(srbname, 1)); --get the checked state if radiobutton.getchecked(srbname) then --if checked then set the xml path for the answer to selected xml.setattribute(strxmlpath.."/answer:"..na, "selected", "y"); paragraph.setproperties("answer"..na, {fontweight=700,borderstyle=1}); --remove the selected option from the other answers --as only one item should be selected at a time. For x = 1,4 do if na ~= x then xml.removeattribute(strxmlpath.."/answer:"..x, "selected"); paragraph.setproperties("answer"..x, {fontweight=400,borderstyle=0}); end end end end --################################################################################################## --## this function is used on the checkbox to select the clicked item as the choosen answer --################################################################################################## function cbselect(scbname) --get the number of the checkbox na = string.tonumber(string.right(scbname, 1)); --get the checked state if checkbox.getchecked(scbname) then --if checked then set the xml path for the answer to selected xml.setattribute(strxmlpath.."/answer:"..na, "selected", "y"); --set color for the border. Ffffff = white 0000ff = blue --this is used to visually distinguish which items were selected nbcolor = math.hexcolortonumber("0000ff"); paragraph.setproperties("answer"..na, {fontweight=700,bordercolor=nbcolor}); --if the checkbox is not checked then perform the following actions --these actions will reset the answer to it's default state elseif not checkbox.getchecked(scbname) then xml.removeattribute(strxmlpath.."/answer:"..na, "selected"); paragraph.setproperties("answer"..na, {fontweight=400,bordercolor=0}); end end --################################################################################################## --## this function is used to populate the question and answer fields in the quiz --################################################################################################## function populatequiz(nquesnum) local ncq = tbrnd[nquesnum] -- set the path for the question including the question number strxmlpath = "quiz/items/item:".. Ncq; --extract the first question local squestion = xml.getvalue(strxmlpath .."/question"); paragraph.settext("p-question", "السؤال "..nquesnum.." من :"..nqta.."\r\n"..squestion); --extract the question type local sqtype = xml.getattribute(strxmlpath .."/question", "type"); --reset the answer objects as well as the checkboxes and radio buttons on the page. For x = 1,4 do radiobutton.setvisible("radiobutton"..x, false); radiobutton.setchecked("radiobutton"..x, false); checkbox.setvisible("checkbox"..x, false); checkbox.setchecked("checkbox"..x, false); paragraph.setvisible("answer"..x, false); paragraph.setproperties("answer"..x, {text="",fontweight=400,borderstyle=1,bordercolor=0}); end --check the question type so we kwow if we should use the --check boxes or radio buttons if sqtype == "ms" then ---show and populate the appropriate objects if the question is multi-select for x = 1,xml.count(strxmlpath, "answer") do checkbox.setvisible("checkbox"..x, true); paragraph.setvisible("answer"..x, true); paragraph.settext("answer"..x, xml.getvalue(strxmlpath.."/answer:"..x)); end ---show and populate the appropriate objects if the question is multiple choice or true/false elseif sqtype == "mc" or sqtype == "tf" then ---show and populate the appropriate objects for x = 1,xml.count(strxmlpath, "answer")) do radiobutton.setvisible("radiobutton"..x, true); paragraph.setvisible("answer"..x, true); paragraph.settext("answer"..x, xml.getvalue(strxmlpath.."/answer:"..x)); end end end --################################################################################################## --## this function is used to score the quiz. --## this function will return a table containing the number of correct answers --## and the users score as a numerical percentage. --################################################################################################## function scorequiz(tbquiz) --by loading the table that contains the list of questions asked in the quiz --we will use that same table to step through the loaded xml file to --score the quiz local ncorrect = 0; local tbreturn = {}; --use a for loop to step through each question asked and score if correct. For i,v in pairs(tbquiz) do --get the path to the question local strxmlpath = "quiz/items/item:".. V; --set boolean variable to a default of true local bcorrect = true --step through each answer to see if they were answered correctly --if any answer was incorrectly selected then bcorrect will be set to false for x = 1,xml.count(strxmlpath, "answer") do --check to see if the answer was correctly selected --the correct attribute for the answer should match the selected attribute inorder to be correct if xml.getattribute(strxmlpath.."/answer:"..x, "correct") ~= xml.getattribute(strxmlpath.."/answer:"..x, "selected") then --if they don't match then mark this answer as incorrect and break out of the loop bcorrect = false break; --this will break out of the for loop end end --if all the answers were correctly selected then increment ncorrect by one. If bcorrect then ncorrect = ncorrect+1; end end --populate the tbreturn table to be exported for this function tbreturn.correct = ncorrect; tbreturn.score = math.round((ncorrect/table.count(tbquiz))*100,0); return tbreturn; end --################################################################################################## --## this function is used to perform a page clickobject when the answer is clicked on the page --################################################################################################## function clickselect(nobj) -- if the checkbos is visible perform the following actions if checkbox.isvisible("checkbox"..nobj) then --the following actions will toggle the state of the checkbox if checkbox.getchecked("checkbox"..nobj) then checkbox.setchecked("checkbox"..nobj, false); else checkbox.setchecked("checkbox"..nobj, true); end --after setting the state of the checkbox this action will then click on the object page.clickobject("checkbox"..nobj); else --the following action will check the radio box and then click on the object. Radiobutton.setchecked("radiobutton"..nobj, true); page.clickobject("radiobutton"..nobj); end end ------------------------------------------------------------------------------ تحريك الصور ---------------- --enter global declarations and functions here... --like worm's function only with some additional features function hittestex() local mi local mtblpos local mobject local mtblobj local mtblpos = nil local mtbldimension = nil local mtblhits = {} local mtype mtblobj = page.enumerateobjects() for mi, mobject in pairs (mtblobj) do mobjtype = page.getobjecttype(mobject) ------ if mobjtype == object_image then mtblpos = image.getpos(mobject) mtbldimension = image.getsize(mobject) end if mtblpos then mx=string.tonumber(dll.callfunction("autoplay\\docs\\mouse.dll", "getmousex", application.getwndhandle(), dll_return_type_long, dll_call_stdcall)) my=string.tonumber(dll.callfunction("autoplay\\docs\\mouse.dll", "getmousey", application.getwndhandle(), dll_return_type_long, dll_call_stdcall)) if (mtblpos.x <= mx) and (mx <= (mtblpos.x + mtbldimension.width)) then if (my >= mtblpos.y) and (my <= (mtblpos.y + mtbldimension.height)) then mtblhits[table.count(mtblhits) + 1] = {type = mobjtype, name = mobject, xpos=mtblpos.x, ypos=mtblpos.y}; end end end end return mtblhits; end --this functions moves any object function moveobject(strobname,nobtype,nxpos,nypos) if nobtype == object_image then mtblpos = image.setpos(strobname,nxpos,nypos); end end ----- ----- -----
تعليق