Source language: Translate to:

Report with random data.

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Report with random data.

Postby sghosh » Fri Jan 20, 2012 7:29 pm

I have an access database where one field contains questions([qts.lm.question]) and four other fields contain four alternative answers([Ans1], [Ans2],[Ans3],[Ans4]. This is an MCQ database from where 20 questions along with four alternative answers will be picked up randomly for a specified number of students[n]". In each case the Question paper would be different with scrambled question. I achieved the same by using filewrite and loop actions as below.
Code: Select all
Loop "1" "[num]" "[y]"
FileWrite "[pubdir]test.txt" "Append" "[caption]. Full Marks [fm]  Time  [min] minutes"
FileWrite "[pubdir]test.txt" "Append" "Roll No : [x]  - [DateShort]"
FileWrite "[pubdir]test.txt" "Append" ".........................................."
Loop "1" "20" "[x]"
Random "[qts.lm.$RecCount]" "[ran]"
dbpGotoRecord "qts" "LM" "[ran]"
Setvar "[rec[ran]]" "[qts.lm.question]"
Setvar "[Ans1[ran]]" "[qts.lm.Ans1]"
Setvar "[Ans2[ran]]" "[qts.lm.Ans2]"
Setvar "[Ans3[ran]]" "[qts.lm.Ans3]"
Setvar "[Ans4[ran]]" "[qts.lm.Ans4]"
FileWrite "[pubdir]Test.txt" "Append" "[x]. [rec[ran]]"
FileWrite "[pubdir]Test.txt" "Append" "[Ans1[ran]]"
FileWrite "[pubdir]Test.txt" "Append" "[Ans2[ran]]"
FileWrite "[pubdir]Test.txt" "Append" "[Ans3[ran]]"
FileWrite "[pubdir]Test.txt" "Append" "[Ans4[ran]]"
endloop
endloop

I was trying to figure out the same thing using NeoBookDBPro, but not getting the proper way to fit the same for DBPro that can generate different sets of questions for a specified number of students.
I am pleading the gurus to intervene.
Regds.
S.Ghosh :wink:
User avatar
sghosh
 
Posts: 8
Joined: Fri Oct 10, 2008 9:11 pm
Location: India

Got it...

Postby sghosh » Sun Jan 22, 2012 10:26 am

Just got it through web search:
dbpExecSQL "qts" "SELECT TOP 20 * FROM LM ORDER BY RND(ID)" ""
Thanks
S.Ghosh
User avatar
sghosh
 
Posts: 8
Joined: Fri Oct 10, 2008 9:11 pm
Location: India

About questions

Postby carlos torres » Tue Jan 24, 2012 11:57 am

Dear sghosh

If you have a database with questions (I f¡gure out that your structure could be: ID, statement, options, Right_Answer, lesson_unit_number, dificult_level and so on)

Select a randon number using this routine:
Code: Select all
:ArrayRnd
...///put the random number in a ListBox
Loop "1" "[SelTotal]" "[c]"
:Repeat
   Random "[Total]" "[Num]"
   If "[Num]" "=" "0"
       GoToLine "Repeat"
   EndIf

   ListBoxFindItem "ListBox1" "[Num]" "[Pos]"
   
   If "[Pos]" ">" "0"
       GoToLine "Repeat"
   EndIf

   ListBoxAddItem "ListBox1" "0" "[Num]"

   SetVar "[Array[c]]" "[Num]"
.   Setvar "[txt]"  "![txt] - [Array[c]]"

EndLoop

Return


Where Array[c] has the number of the random questions to select.

Then you can build a temporal table to keep the estudent's answers, do marks, reports and so on all based on this temporal table.

I hope it will help you

Regards
carlost
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia

Thanks for your reply.

Postby sghosh » Wed Jan 25, 2012 9:52 am

Dear carlost
Although the dbpExecSQL was working fine, I was unable to serialize the question from 1-20 using SQL script.

Thank you for your direction towards the goal. Achieved successfully.
Made a function named randompick
Code: Select all
.Randomization
ListBoxDeleteItem "ListBox1" "ALL"
:ArrayRnd
 ...///put the random number in a ListBox
 Loop "1" "20" "[c]"
 :Repeat
    Random "22" "[Num]"
    If "[Num]" "=" "0"
        GoToLine "Repeat"
    EndIf
    ListBoxFindItem "ListBox1" "[Num]" "[Pos]"
    If "[Pos]" ">" "0"
        GoToLine "Repeat"
    EndIf
    ListBoxAddItem "ListBox1" "0" "[Num]"
    SetVar "[Array[c]]" "[Num]"
 .   Setvar "[txt]"  "![txt] - [Array[c]]"
 EndLoop
 Return

A Button object code follows:
Code: Select all
Call "randompick"
..///////////////////////////////////////..
..Question Generation..
dbpDeleteAll "qts" "LM_Tmp"
ListBoxSize "ListBox1" "[lsize]"
Loop "1" "[lsize]" "[result]"
ListBoxGetItem "ListBox1" "[result]" "[linetext]"
dbpGotoRecord "qts" "LM" "[linetext]"
dbpAddRecord "qts" "LM_tmp"
setvar "[qts.lm_tmp.ID]" "[result]"
setvar "[qts.lm_tmp.question]" "[qts.lm.question]"
setvar "[qts.lm_tmp.Ans1]" "[qts.lm.Ans1]"
setvar "[qts.lm_tmp.Ans2]" "[qts.lm.Ans2]"
setvar "[qts.lm_tmp.Ans3]" "[qts.lm.Ans3]"
setvar "[qts.lm_tmp.Ans4]" "[qts.lm.Ans4]"
endloop
..Report Viewing
dbpPreviewReport "qts" "[Pubdir]test.dbr" "DisplayMode=FitPage;InitialPage=1"


Working as desired. Twenty questions are always being picked up randomly with serial sequence.
Thank you again.
S.Ghosh
User avatar
sghosh
 
Posts: 8
Joined: Fri Oct 10, 2008 9:11 pm
Location: India


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 1 guest