Generating Random questions

Hi
I am trying to get random questions which are stored in the database. I used the following code but questions are not unique.
public void loadQuestion(){
int len = qs.size();
Random r = new Random();
int[] rint = new int[6];
for (int i =0;i!=6;i++){
rint[i] =r.nextInt(len);               
}

public void loadQuestion(){
int len = qs.size();
System.out.println("Length: " + len);
Random r = new Random();
int[] rint = new int[6];
for (int i =0;i < 6;i++){
rint[i ] =r.nextInt(len);     
System.out.println("Number: " + rint[ i ]);     
}NOTE: when posting here you have to put a space in [ i ], otherwise
the forum software thinks its an italics tag.
Dont get clever with constructs like i != 6 its i < 6
Use lots of verbose debugging lines like the 2 i added.
Post the results you get.

Similar Messages

  • Generating random questions without duplication

    I have 10 questions in my java program,
    I can get them randomly generated but how can I do without duplication ?
    Any help much appreciated

    My approach would be, when you first generate the questions put them in a List. Then use java.util.Collections.shuffle(List) to randomize the List.
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#shuffle(java.util.List)
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html

  • Some random questions about integration features

    Greetings,
    after working for a few weeks with Autovue's ISDK (web server) and having some sucess with its integration with our custom CMS, I have a few random questions about what can be done and what can't be done. So, instead of opening many new threads, I'll post them here together.
    1) Translation. We are localised in Russia, and its translation is incomplete. I have found a tra_en.properties file in AutoVue/bin, and a description about how to create a properties file for custom actions. But no information about how to translate to other languages - and russian translation appears to be packed within the jar of the applet. Is there a clean way to translate, or refine the current translation, so we don't get a mix of russian and english commands in the applet? Because my tries using EXTRABUNDLES have failed, as I don't want to add a bundle for extra actions, but to replace it for existing ones.
    2) Attachments in markups. Markups allow to attach other files, but since our CMS is custom, we only get the option to attach files from our local drives. We did no browse integration with the CMS, as people with different levels of permission will have different access to files there, and we considered unnecessary to provide that level of integration. We are considering to remove this action from the GUI, but before that I'd like to evaluate how hard would it be to generate an upload file action, so the attached file would be stored in the custom CMS and linked to it so the whole thing worked. My guess is "it will be hard and time consuming", so for now, we are considering to delete this feature in our integration.
    3) Is there a way to resize the Open markup dialog? We have several properties displayed, and fit well within a standard screen, but the dialog is small and you have to scroll the table to see all properties.
    Thanks for any assistance with these issues

    As always, thanks for the fast answer, Artash.
    Yes, now I see attachments are stored inside the markup file. The problem is, when I open markup mode for the attachment, since the attachment uses some kind of default access method, my url's from the integration with the background CMS are broken completely. I believe the ideal state here would be to make some kind of inner markup for the attachment, maybe stored within the original markup file along the attached file. Or maybe it works that way, and I need to access it with the default gui action instead of my custom one. If that is the case, is there any way to tell the gui file how to differentiate a standard opened file from an attached one? If so, the issue has solution. If not... Well, then maybe something escapes me.
    Edited by: Jordi Bosch on Apr 6, 2012 12:27 AM

  • [captivate 3] random question slide doesn't work

    hello,
    I'm noob in Captivate.
    I use Captivate demo (in french).
    I want to make a quizz for my students.
    So, I create a "question pool manager" with 1 pool project
    "reseau_locaux".
    This pool project have 13 questions.
    Then I click "slides" on the filmstrip, I add a "Random
    question slide" and I click on the "Question pool menu" to select
    my pool project "reseau_locaux"
    After generating project, I have only 1 question from my
    question pool project.
    I read the help guide but it's not help me.
    It gets me crazy...
    I hope you understand my english.
    thanks

    Welcome to our community, Anthony
    Basically you are doing everything right. I'm a bit unclear
    on what you were expecting to see. Perhaps it will help you if I
    explain how the Question Pools and Random Questions work.
    You define a pool of questions using the Question Pools
    Manager. You advise you have done that. So far so good.
    You then insert a Random Question Slide. When you insert one
    of these, you point the slide at a Question Pool. You advise that
    you have done that too.
    I'm guessing here that perhaps you expected that by inserting
    a single Random Question Slide you would end up presenting all 13
    questions from the pool. Just in random order?
    If so, that's not how it was designed to work. What happens
    is that a single random question from the pool is presented. If you
    desire to see all 13 of your questions, but in random order, you
    need to insert 13 Random Question Slides and point them at your
    Question Pool.
    You may wonder at this point if you do this, will it would be
    possible to see perhaps question 2 multiple times. And the answer
    to that is no. Once a question has been presented, it is removed
    from consideration in the pool. So after the first one is
    presented, Captivate randomizes from what remains in the pool.
    Hopefully that helps better explain it.
    Cheers... Rick

  • How to generate Random Coupon Codes

    Hi, Is there an app that works with numbers to create a listing of coupon codes?
    Message was edited by: tupper501

    I don't know what your actual question is.
    The subject line is about generating random coupon codes. That could probably be worked out with the use of RANDBETWEEN with it generating UNICODE codes that correspond to numbers and letters.
    Creating a listing of coupon codes is a totally different thing. This requires having a list of actual working codes, not generating random ones. I know of no app that "works with Numbers" to create a list of coupon codes.

  • How To generate random activation code

    Hi Guys
    It might be a very simple question for most of you. I've seen many websites when you register, they send you an email with an activation code.
    It kind of looks like : XA432G2DGR343
    How do we generate something like this in Java. I know we can generate random numbers? Any tips on how to go about it.
    Thanks

    gubloo wrote:
    It might be a very simple question for most of you. I've seen many websites when you register, they send you an email with an activation code.
    How do we generate something like this in Java. So let me see if I have this straight. You are asking us to help you create a program, one that allows you randomly generate activation codes, and with these codes you will try to crack into websites where you haven't registered for or where you possibly haven't paid some entrance fee? Is this correct or am I missing some basic element of logic here? If I'm wrong, please correct my mistake. If I'm right, then you can go to h&#101;ll.

  • How to generate random integer?

    What is the func to generate random integer (at most 4-5 digits). Thanks.

    Luckily you asked an amazingly popular question - just take a peek at the answers found in this very forum:
    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A31&qt=Generate+Random+Integer

  • Anyone know how to generate random midi in real time?

    Hi this is my first post so if this is obvious please forgive me
    I'm a John Cage fan and interested in chance generated working methods.
    What i'd like to know is if there is a way to generate random midi events (pitch and velocity) in logic pro or mainstage from an incoming midi signal e.g. any incoming note trigger could trigger any midi note randomly within a user defined range in real time?
    Also is it possible to generate random midi events by just letting something run in the background?
    NB i know i can randomise events after the fact using the transform window - i just can't work out how to randomise in real time.
    sorry if this was a dumb question but any help would be greatly appreciated
    thanks in advance

    christianobermaier wrote:
    Random notes are difficult because a MIDI Note actually consists of two events, Note On and Note Off a while later. If you transform either to something random, you'd get hanging notes all over the place especially when doing it live.
    You are quite right Christian, but I still think there are some ways to solve that in the Environment. For some reason I created such a tool in the pass ( it was a Logic custom offer or something like that ... ). I just converted this old LSO to L8 project. Here is a short description of the Macro "Elements" below:
    *INPUT NOTE RANDOMIZER - ELEMENTS*
    1."On/Off" CC# Assign box - you can set any CC# 0-127 here to control the Global ON/OFF Macro button(2) externally.
    2.Global ON/OFF Macro button - switches the Macro ON/OFF. In OFF mode the macro is bypassed.
    3.Note Pitch Low Randomization range box - determines the low range randomization value.
    4.Note Pitch Top Randomization range box - ( determines the top range randomization value ).
    5."Panic" CC# Assign box - you can set any CC# 0-127 here to control the "Panic" button (6) externally.
    6.Panic Button - resets any playing or hanging notes in both Macro ON/OFF modes.
    7.Note Velocity Low Randomization range box - determines the low range randomization value.
    8.Note Velocity Top Randomization range box - ( determines the top range randomization value ).
    Note: +There is a Stand Alone Macro layer in the template project so the macro tool can be easy imported as an Environment layer into other Logic projects. The tool is Polyphonic ( no Voice Limiter is applied ) so you can use it to generate random chords playing same chord rhythmically etc.+
    Also is it possible to generate random midi events by just letting something run in the background?
    I think so - something like Arpeggiator object may do the job as a Note generator in a combination with some Enviro gear or Macro...
    *Live Input Logic Note Randomizer v1.0* - [DOWNLOAD|http://audiogrocery.com/files/innote_randv1.0.zip]
    !http://img59.imageshack.us/img59/699/innoterand.gif!
    !http://img59.imageshack.us/img59/4967/aglogo45.gif!

  • Anyone know how to generate random midi in real time? part 2

    anyone know how to generate random midi in real time?
    http://discussions.apple.com/thread.jspa?messageID=11342321
    This article was archive so I can't reply to this, but I wanted to bring this back up.
    As Christian pointed out on converting your notes to P-Press, then random DataByte 1 then convert back to a Note...
    I used this approached but was able to add in a macro I created to save the generated random DataByte 1 so that when the Note OFF message came around, I can apply that saved random DataByte 1 to the Note OFF in question.
    One thing I did notice when working this out was there's 2 differences in processing the messages when it comes to using a MIDI Input Device or a MIDI Performance (midi file).
    After I was able to figure this out, now I can randomize on notes using either of the 2 Inputs.
    While randomize notes probably won't sound nice to the ear, I apply another macro I created and I'm still adding too, and that's Music Scales.
    So while I randomize notes, when applied to this last macro, the random notes now get mapped to notes in a music scale of your choosing.
    This link shows what I did.
    http://www.digimixstudios.net/RandomizeNotesUseScales/
    I'm currently in the process of creating video tutorials in breaking down the whole process but I wanted to share what I have and see if there's any interested in this.
    Remember, this is just one approach and I hope it gives others ideas to work off of.

    anyone know how to generate random midi in real time?
    When I used to drink a lot... this was no problem at all!
    pancenter-

  • Generating random text for placeholders in Pages

    In the templates that come with Pages the text placeholders are all in Latin, which I think looks quite professional. My question is: how can I generate random Latin text, like in the templates?
    Thanks
      Mac OS X (10.4.7)  

    You can also use the nifty freeware MacLorem, which will generate random Latin text with various specifiable qualities (and can produce mock text for various other "languages").

  • When I attempt to sign up for the Samsung website using Firefox on my macbook, it returns an error that the random question answer is wrong

    I was attempting to create a user at this site:
    http://www.samsunggalaxys3forum.com/forum/register.php?do=addmember
    It asks a "random" questions "Floors are horizontal, walls are ___?" When I hit submit, it returns an error that the answer was wrong. I tried several times using my macbook running firefox.
    I get to work, where I am using an intel based machine running Windows 7, IE 9 and am able to register on the site and answer the question with no problem.
    I have had the same problem on sites that use captcha - I cannot get past inputting the captcha phrase, as it returns an error every time, while using IE9 is problem free.
    Is there something wrong with my setup of Firefox?

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • Two random questions

    hey guys.. i have two random questions..
    1) when you recalibrate your battery... after you drain the computer and leave it for 5 hours.. when you RECHARGE IT (before its fully recharged) are you allowed to use it? or are you only allowed to use the macbook AFTER it's recharged... (because in the instructions it only talks about using it for the 2 hours AFTEr it's rechaarged)
    2) also... i always wondered if there was a better alternative between amc the ripper and handbrake (since mac the ripper apparently can rip different region coded dvds)... but ir ealised mac the ripper does FULL dvd rips whilst handbrake converts it into like mp4 and stuff... is that true? (as in.. u cant do vice versa on each?)
    thanks a buncho everybody! go the mac..

    2) I use handbrake if I am planning on watching the
    DVD on my ipod etc and Mac the Ripper to copy
    (Backup) full DVDs. Obviously I do this in America as
    it's illegal for some reason in the UK.
    It is illegal in the US too. Seems "fair use" does not apply to DVDs and disabling the copy protection (which you do when you rip your DVD via mac the ripper or handbrake) is against the law.

  • Publishing w/ Random Questions

    Hi,
    I am using random questions in one of my programs and about
    to send it off to the client. This client has Captivate and would
    like for me to send the CP files. My question is, if I send the CP
    file for the program, will the random questions in the pool go with
    it? If not, how do I get them there?
    Many thanks for your help!

    Hi gbcvette
    Yes, your random questions would be contained inside the .CP
    file.
    Cheers... Rick

  • HTML random question score incorrect.  SWF works fine

    Version 8.0.1.242
    Question pool 25 questions. Random Question slides inserted. All questions set to score 1.  24 are multichoice, all standard.
    Published as HTML
    Score reported is 1 out of x. 
    I have tested with 3, 5 and 25 random questions from the pool.  But the score is always 1 out of x
    Published as SWF
    Works correctly
    I really need the HTML version.
    Closed, reloaded.  Saved as - retested. Turned it off and turned it back on. Sacrificed a mouse...
    Andy

    Correct questions
    ....Should be same as total points scored anyway as there is 1 point for
    each question.

  • Random question slide not shown when FP 8 or FP 9 output

    Hi everyone
    I've just begun to use Captivate a month ago, so it is not
    that much experience I can contribute with by now.
    One thing I have recognized is that I get some problems with
    random questions slides made from different question pools when
    using Flash Player 8 or 9 in the output otions.
    When using Flash Player 7 everything works as supposed: one
    random question is shown for every random question slide using one
    distinct question pool for each random question slide.
    When using one of the two others some of my random question
    slides are not shown. There are slides that are played - meaning
    that the player shows an empty slide for the time of 3 seconds -
    but the content is not shown. This happens only for some of the
    random question slides, and those are the same question slides each
    time, I publish - but when working or dragging around with the
    random question slides and publish again, the problem would come
    with some other random question slides, not positioned the same
    place as before, but showing the same problem in each published
    version.
    As written before each question pool is only used once. The
    different question slides used in the question pools are all
    duplicates, naturally with adjusted content.
    Does anyone has experienced something like that before? Could
    there be any other trouble with the content when using Flash Player
    7 in the output options, like quiz not playing in newly updated
    Flash Players ore something like that? Anything?
    I appreciate your suggestions or comments! Thanks in advance
    and kind regards,
    Lars

    Some more info - and a working solution...
    I have worked on this topic a bit more - and found out, that
    I have a problem with output option set to Flash Player 7, too.
    When I delete every other navigation option than the "next
    question" (what is it called in english?) button, I get this
    problem:
    The quiz now "freezes" randomly, not every time, but again
    and again. The quiz has both random slides from question pools and
    simple question slides.
    I have found out, that putting the simple question slides
    into question pools and then showing a random slide from those
    question pools fixes the problem.
    Has anyone experienced problems like that? Other solutions?
    Kind regards
    Lars
    Maybe someone has a similar problem.

Maybe you are looking for

  • Can't run (Media Encoder or Encore) and Premiere Pro

    I finished a sequence, started up Media Encoder, then began editing a new sequence with Premierer. The result was that after a while, Media Encoder "Not Responding". I started Media Encoder again and this time I left the room to watch TV. Media Encod

  • Help need to recover corrupted ipad backup

    I need help recovering a corrupted ipad backup. I was unable to restore my ipad from the backup when upgrading to ios 4.2. Does anyone know of a program that will allow me to decrypt the data from this backup?? Any hints or help would be greatly appr

  • Stop auto load of account information on Skype new...

    How do I stop my info from auto loading on a skype reinstall[ New ] Options  2 minutes ago I am selling my laptop - I have installed Skype and installed it fresh. Unfortunately every time I go thru the process, the re-installed Skype also includes my

  • Creating Aggregate devices

    I cannot create aggregate devices with audio/midi setup. Every time I click a component to use it unchecks as fast as it checked. Im at a loss, without hte ability to make ag devices I cannot record at all, but there seems to be no documentation on t

  • Hi new phone iphone3 will not let me send pictures keeps failing?

    Hi new phone i phone3 will not let me send pictures keeps failing?