How to reset Option Buttons in Group Box control in Impress?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Lucnes
Posts: 1
Joined: Tue Oct 21, 2008 9:36 am

How to reset Option Buttons in Group Box control in Impress?

Post by Lucnes »

Hello everyone!
I am new of OpenOffice.org 3.0 and unfortunately I don’t know the Basic language :(
I have found on Internet an article that illustrates like creating interactive forms with OpenOffice.org Writer that consists of a series of multiple choice questions. Here it is in detail:
I have created a Group Box containing Option Buttons with the defined answers. Then in order to make the form interactive, I have added some simple macro associated with Option Button to inform me whether the selected answer is correct or no. I have also created a Reset button that clears all the answers by means of its macro (ResetControls). Here it is the code:

Sub CorrectAnswer
Message="The answer is correct!"
MsgBox Message
End Sub

Sub IncorrectAnswer
Message="The answer is incorrect!"
MsgBox Message
End Sub

Sub ResetControls
oDoc = thisComponent
oDrawPage = oDoc.getDrawPage()
oForms = oDrawPage.getForms()
oForm = oForms.getByName("Standard")
oForm.Reset()
End Sub

It works very well on Writer, but when I copy the code into OpenOffice.org Impress it does not completely work… only two macro work, that is CorrectAnswer and IncorrectAnswer, but no ResetControls… Why?
I am really trying to use this system in Impress by means of OpenCards extension in order to make it an interactive tool with the multiple choice questions by means of Option Buttons: only one of possible answers is correct and it is selectable through its Option Button.
I use slide-title as flashcard front on which I write the correct answer, and the slide-content as its back on which I write both question and five possible answers with their Option Button.
During last-minute learning session OpenCards shows both question and its answers in the slide-content, and on this event it would need a macro, said ResetControls, to reset any Option Button automatically without having to click some Reset-button (like in the Writer example), so that no answer is selected. I would not want to implement a Reset button.
At this point I select an answer and then click on the Complete Shows Card-button in the Choose Action window. During this event OpenCards shows correct answer written in the slide-title, but it changes current selected answer (in Option Button) with previous chosen answer. It would need another macro, said MaintainAnswer, in order to continue to show the current selected answer that it is confronted with correct answer written in the slide-title. If the answer is corrected then Perfectly-button is clicked, otherwise Not at all-button is clicked, and OpenCards shows next slide. The cycle is closed and it newly begins from head with ResetControls macro that it resets any answer-Option Button, and so on…

Can someone realize these macros and share them with all community?

P.S. I have attached an example file without macro:
Multiple choice questions.odp
(13.19 KiB) Downloaded 330 times
Thanks very much for your help!! :)
Greetings
Luca
OOo 3.0.X on Ms Windows XP
User avatar
Bhikkhu Pesala
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

Re: How to reset Option Buttons in Group Box control in Impress?

Post by Bhikkhu Pesala »

I removed the green tick from your post, otherwise people might think that you solved the problem yourself already.
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
Post Reply