Source language: Translate to:

Password required to access a section of a publication

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Password required to access a section of a publication

Postby dcaqu » Wed Dec 20, 2006 12:32 pm

Hi,
We're developing a participant guide for a training course which we want participant's to be able to access a section only when the instructor allows (by giving out a simple code). We've tried a couple of simple scripts but none of them work well. Anyone done anything like this before?

:D Thanks
Dave
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.

Postby Gaev » Wed Dec 20, 2006 12:54 pm

Dave:

Perhaps you can provide some more details of your deployment of this NeoBook application ...

a) Define "section" ... a single page ? ... a number of (contiguous) pages ?

b) Can participants normally surf from page to page via the Page Down and Page Up keys ?

c) Re: when the instructor allows (by giving out a simple code) ... would that be communicated verbally or via email or some other extrernal means ? ... and the participant would be required to enter the code in a given TextEntry Box ?

d) Are the codes identical for all participants ?

e) Do you have it so the codes are "hard-coded" in the applications at compile time ... or can they be downloaded from your website ?

Perhaps you can also describe the jist of ... We've tried a couple of simple scripts but none of them work well ... so others can investigate any defects.

If you prefer, you can send a Private Message to me on this forum.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dcaqu » Wed Dec 20, 2006 1:44 pm

Hi Gaev,
Answers.
a) A section is a number of contiguous pages.
b) Yes page up/down is planned to be active, however we could disable it.
c) Verbally, this will be a classroom event. The reason for the password is to prevent participants reading ahead.
d) Codes are identical.
e) Codes are okay to be hard coded.

We tried a script based on a input box/if statement in the PageExit tab of the last page of the current section which either went to the next page or kept the user on the current page. Unfortunately when it didn't work we dumped it. However it created a run time error that said the GotoPage action could not be used in this script and when we tried a work round we just ended up in the next section anyway after the alert box script told us our password was invalid. Guess we need to spend a little more time working on this, we we're just trying to prevent re-inventing the wheel by contacting the forum.

Dave
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.

Postby Sam Cox » Wed Dec 20, 2006 2:06 pm

Something like this might work. When a user tries to access a page in any manner (e.g., pressing a button, PageUp/PageDown, etc.), the PageChange code is executed. If in that code we change the value of [PageChangeName], we can thwart or divert the attempt if the conditions are not right.

Create the "PageToEnterCode" page which has a code entry box. When a code is entered in the box, append it to the variable "[Codes.Entered]" and exeute Goto "[TargetPage]". Your user will get to the "PageToEnterCode" page when they try to access a section for the first time. The code in PAGE CHANGE SECTION will divert them to the code entering page when appropriate.

Haven't actually tried it.
Code: Select all
.CODE IN STARTUP

SetVar "[Section1.Code]" "7710"
SetVar "[Section2.Code]" "aaab"
SetVar "[Section3.Code]" "dkjfkjdkjfkjdkjfkjdkjfkjd" .just kidding
etc.
SetVar "[SectionPageList]" "Section1,Section2,Section3"

.CODE IN PAGE CHANGE SECTION

SearchStr "[PageChangeName]" "[SectionPageList]" "[X]"
If "[X]" ">" "0"
  SearchStr "[[PageChangeName].Code]" "[Codes.Entered]" "[X]"
  If "[X]" "=" "0"
    SetVar "[PageChangeName]" ""
    -or-
    SetVar "[TargetPage]" "[PageChangeName]"
    SetVar "[PageChangeName]" "PageToEnterCode"
  Endif
Endif
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby dcaqu » Wed Dec 20, 2006 2:19 pm

Thanks Sam,
We'll give it a try.

Merry Xmas
Dave
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.

Postby Gaev » Wed Dec 20, 2006 2:29 pm

Dave:

I believe you can accomplish your goal by utilizing the Page Change event section of NeoBook ... which you can get to in Design Mode by pressing the F12 key and then selecting the Page Change section tab.

From the Help file ...
Page Change: These actions are executed whenever the reader attempts to navigate to another page. Optionally, the page change can be redirected or canceled by altering the value of the global [PageChangeName] variable. To redirect the reader to a different page, insert the new page’s title into the variable. For example:

SetVar "[PageChangeName]" "ErrorPage"

You can also cancel the page change by setting the variable to any empty title. For example:

If "[PageChangeName]" "=" "Goodies"

If "[User]" "<>" "Register User"

AlertBox "Sorry" "Only registered users can view that page."

SetVar "[PageChangeName]" ""

EndIf

EndIf
... so, let us say that the user has a TextEntry Box on the last page of Section B of your application ... call it TextEntry7 ... with the user's input being stored in variable [TextEntry7] ... although I like to name my objects and variables to meaningful names like PassCodeSectionB.

And you would have a button next to it .. whose Click section would have something like ...
Code: Select all
GotoPage "StartOfSectionC"
... or ...
GotoNextPage
... with similar TextEntry Boxes and Buttons on the last pages of each of the sections.

Your "control and command center" would be the Page Change section of NeoBook ... with sets of commands like ...
Code: Select all
If "[PageChangeName]" "=" "StartOfSectionC"

  If "[TextEntry7]" "<>" "asd45bnm"

    AlertBox "Sorry" "You do not have the correct Password to view that page."

    SetVar "[PageChangeName]" ""

  EndIf

EndIf
... where "asd45bnm" is the code they would need to continue to Section C of your NeoBook application ... you would need one set of these commands above for each Section/TextEntry Box/Password ... there are other more efficient ways of coding ... but this would be the simplest to understand ... if you have more than say 10 sections, let me know ... perhaps i can whip up something more efficient.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dcaqu » Thu Dec 21, 2006 12:19 am

Hi Gaev,
Many thanks, we'll script something using the ideas provided by you and Sam. Your help is much appreciated.

Have a great Xmas
Dave
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 3 guests

cron