Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently January 15th, 2025, 12:15 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Blockbusters
PostPosted: March 5th, 2005, 5:58 pm 
Offline

Joined: November 3rd, 2004, 8:05 pm
Posts: 22
Opus: Pro 9
OS: Windows 10 Home 64-bit
System: HP Spectre x360 Intel Core i7-8550U CPU @ 1.80GHz, 16Gb Ram
Hi,

Have been trying to put together an educational quiz based upon the format of the TV quiz show "Blockbusters".

Would like to be able to randomize the letters on the board each time the game is played. Would also like to randomize the questions that are generated for each letter when it is selected.

Could someone point me in the right direction?

Thanks

_________________
Adrian Murray
https://www.businesssed.co.uk
Supporting Business Education


For this message staffam has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Show Random
PostPosted: March 6th, 2005, 5:28 pm 
Offline

Joined: November 3rd, 2004, 4:48 pm
Posts: 20
Location: Sheffield, UK
Adrian

This URL will take you to the topic that discusses how to do what you require:

viewtopic.php?t=34

Download the Opus file and examine the script. It shows random numbers on a line of blocks that you can adapt to your purpose.

Good luck :D

Paul


For this message amethyst has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 7th, 2005, 6:46 pm 
Offline

Joined: November 3rd, 2004, 8:05 pm
Posts: 22
Opus: Pro 9
OS: Windows 10 Home 64-bit
System: HP Spectre x360 Intel Core i7-8550U CPU @ 1.80GHz, 16Gb Ram
Paul,

Thanks for that. Will see if I can get it working.

Much appreciated,

Adrian

_________________
Adrian Murray
https://www.businesssed.co.uk
Supporting Business Education


For this message staffam has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 8th, 2005, 1:28 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi,

Thank you for your enquiry.

Please find attached an example publication which should assist you in setting up the basic mechanics of this game.

I have created an array containing all of the letters of the alphabet and have then used a series of looping actions to shuffle the characters into random order.

Once this process is complete, another series of looping actions takes each character from the resulting array and inserts it into each of the twenty text objects on the page.

I have also added identical script actions to each text object which determine the name of the currently-selected text object, truncate this to the number of the text object, then retrieve the corresponding index from the letters array. This is then set to a variable named 'cell' and displayed on the page. In the completed publication, this 'cell' variable would used to determine which question should be asked.

I hope this helps. Please do not hesitate to contact me if you have any further queries.

Kind regards,


You do not have the required permissions to view the files attached to this post.

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 8th, 2005, 7:56 pm 
Offline

Joined: November 3rd, 2004, 8:05 pm
Posts: 22
Opus: Pro 9
OS: Windows 10 Home 64-bit
System: HP Spectre x360 Intel Core i7-8550U CPU @ 1.80GHz, 16Gb Ram
Robin,

You are an absolute star! Not only have you saved me hours of work - but I'm also slowly beginning to understand the art of scripting.

Your assistance is really appreciated. Thank you.

Best wishes,

Adrian

_________________
Adrian Murray
https://www.businesssed.co.uk
Supporting Business Education


For this message staffam has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Back again!
PostPosted: April 6th, 2005, 7:24 pm 
Offline

Joined: November 3rd, 2004, 8:05 pm
Posts: 22
Opus: Pro 9
OS: Windows 10 Home 64-bit
System: HP Spectre x360 Intel Core i7-8550U CPU @ 1.80GHz, 16Gb Ram
Thanks to Robin I have been developing a database of questions for use in the Blockbusters game. I have linked the database to the gameboard - but can't figure out how to pick a random question for each letter from the database.

In effect this means that at present players would be faced with the same questions everytime they played!

Sorry to be a pain - but could anyone point me in the right direction again?

Thanks

_________________
Adrian Murray
https://www.businesssed.co.uk
Supporting Business Education


For this message staffam has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: April 7th, 2005, 2:37 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi,

Thank you for your enquiry.

This is possible to achieve, but you will need to use database script functions. I have attached an updated version of my original sample along with a database to demonstrate how this can be achieved. I have tried to annotate the script functions as clearly as possible, but please let me know if you have any queries.

Please note that my database only includes questions whose answers begin with A, so this is the only cell you can click on at the moment. If you click on any other cell, a 'No questions found starting with' message appears, followed by the chosen letter. As the cell letters are displayed at random, you may find that the letter A is not available to test. If this is the case, simply exit and preview the publication again until you can see a cell containing the letter A. Of course, once you have set up a database containing questions of every letter, you may want to remove this error functionality, which you can achieve by deleting the following lines from the ShowQuestion() function:

Code:
//if no records have been returned (i.e; no questions exist for this letter)
if (num == 0) {
//select the entire contents of the Question_Text object
Question_Text.SetSelection(0,-1)
//replace selection with error message plus the chosen letter
Question_Text.ReplaceSelection("No questions found starting with " + cell)
//if records have been returned (i.e; questions do exist for this letter)
} else {


The function should now assume that questions exist for all letters and go straight ahead with the retrieval of a random question.

If you are unsure how to connect to a database using script, the following procedure should hopefully be of use:

- First, copy your existing Access .mdb file to the Desktop
- Launch Opus and create a blank new publication
- Click File > Save As... and save the project to the Desktop with a filename of your choice
- Right-click on the page and select Edit Actions
- Select the Triggers tab and open the Synchronisation group of triggers
- Double-click on the On Show trigger to apply it to the page
- Select the Actions tab and open the Database group of actions
- Double-click on the Database Query action to apply it to the page
- Click the Select button to display the list of available DSN files
- Click the New... button to create a new DSN
- Select Microsoft Access Driver (*.mdb) from the list of ODBC drivers and click Next
- Click the Browse button to open the Save As dialog
- Open the Save in drop-down list and select the Desktop from the top of the list
- In the File name field, type test
- When you are happy with the file name, click Save
- Click Next, then Finish. The ODBC Microsoft Access Setup dialog should now be displayed
- Click the Select button. As the dialog defaults to the current location of the DSN file, you should see your .mdb file in the left-hand list
- Click on the .mdb file to highlight it, then click OK, OK and OK again to return to the Database Query settings
- If you minimise all open windows to display the Desktop, you will see that the test.dsn file has been created on the Desktop
- Go back into Opus, highlight the On Show trigger you applied to the page and press the Delete key on the keyboard to delete this trigger and its associated Database Query action
- Click OK to return to the main Opus workspace
- Now click Insert > Script Object
- In the script window, type the following:

Code:
myDB = new Database("FILEDSN=C:\\Documents and Settings\\USERNAME\\Desktop\\test.dsn;")


where USERNAME is your Windows logon name. You can double-check this by opening Windows Explorer, navigating to the root of the C: drive and double-clicking on the Documents and Settings folder. A list of folders should appear corresponding to all of the users who are set up on the machine. Look for the folder which corresponds to your logon and make a note of the folder name (ensuring that you note any capitalisation or punctuation). Now go back into Opus and replace USERNAME with the folder name you have noted.

On the second line of the script object, type:

Code:
records = myDB.ExecuteSQL("SELECT * FROM table;")


where table is the name of the table in your database from which you wish to retrieve the records. To confirm this, double-click on your .mdb file to open it into Microsoft Access and make a note of the table name which appears below the three Create table... options (ensuring that you note any capitalisation or punctuation). Now go back into Opus and replace table with this table name.

Now type the following two lines:

Code:
num_records = records.GetNumberofRecords()
Debug.trace(num_records)


Now preview the publication. A Script Debug window should pop up as soon as the page is displayed and display the number of records which have been retrieved from the database. This should match the number of rows you have added to your database in Microsoft Access.

All being well, go back into your script object, delete the Debug.trace() function and start coding your required SQL queries and actions.

You may notice that I have not included a DSN file with my publication and database. This is because I have 'embedded' the DSN information into the publication by clicking Publication > Publication Properties > Database, selecting the DSN in the list and enabling the Don't update data source option. This tells the publication to stop looking for a DSN file and instead locate the database within the directory from which it is running.

If you have any queries

Kind regards,


You do not have the required permissions to view the files attached to this post.

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Thanks!
PostPosted: April 7th, 2005, 6:05 pm 
Offline

Joined: November 3rd, 2004, 8:05 pm
Posts: 22
Opus: Pro 9
OS: Windows 10 Home 64-bit
System: HP Spectre x360 Intel Core i7-8550U CPU @ 1.80GHz, 16Gb Ram
Robin,

Once again I am in your debt. Many thanks for taking the time to help

Adrian

_________________
Adrian Murray
https://www.businesssed.co.uk
Supporting Business Education


For this message staffam has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group