mysql - Show random questions from a table without repetition -
i using moodle multitrack test developing career assessment test. want modify plugin show random questions, 1 question @ time. if there total of 10 questions should show first random question , after saved show random question remaining 9 questions , on. questions saved in table called 'magtest_question' fields are:
id(bigint), magtestid(bigint), questiontext(longtext), questiontextformat(mediumint), sortorder(bigint).
the questions sorted based on 'sortorder' column. tried changing query sort randomly.
select * {magtest_question} magtestid=? order rand()
but show same question again. want avoid questions attempted. how can achieve using sql query. please help.
query ids of 10 questions in random order, store ids in session in array in order returned query , retrieve questions one-by-one. way issue order rand()
query once , questions not repeated.
Comments
Post a Comment