Question
I have been asked to create a search that returns a list of topics
but randomizes their order each time the list is rendered. Does anyone have any ideas how this could be done?
I've looked at
RandomTopicPlugin and
RandomReplacePlugin but these don't quite do what I need. Perhaps one could utilize the
$RAND attribute in
SpreadSheetPlugin in some way...?
Any suggestions appreciated!
Environment
--
LynnwoodBrown - 06 Jun 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
As you mention, the
SpreadSheetPlugin already has a
$RAND(). However, I do not think that it helps since you need to randomize a list. The Plugin has already many list functions, what you need is a new
$LISTRAND() function that randomizes a list.
--
PeterThoeny - 06 Jun 2006
I did something similar to work recently, though it wasn't pretty. Check it out if you like:
link
- Make sure that whatever you are searching has a
%CALC{"$RAND()"}% somewhere identifiable.
- When generating your table of results, make sure each result has the random number as one of its columns (you'll probably have to use
$pattern in a formatted search).
- Make sure the TablePlugin is installed. Precede your search results with
%TABLE{sort="on" initsort="1"}% where 1 is the column with the random number.
The main problem with this method is that it doesn't look pretty, as you have a column with some huge random number. Also, in your case, it might be a problem to put a random number in your selected pages.
I would be very grateful if there were a
$LISTRAND() function or something similar.
--
ChadBoulay - 07 Jun 2006
The
$LISTRAND() option for
SpreadSheetPlugin sounds interesting, but how would one apply this to a list generated by a search (particularly a FormattedSearch)? What about a new
order="random" option for
VarSEARCH?
--
LynnwoodBrown - 07 Jun 2006
On
TWikiIRC,
MartinCleaver pointed me to this
perl program to randomize lists
. Looking at the order functions in
search.pm , it appears to me that something like this would be pretty easy to incorporate. Any comments from someone that actually knows perl?
--
LynnwoodBrown - 07 Jun 2006
CPAN:Algorithm::Numerical::Shuffle
--
WillNorris - 07 Jun 2006
A search result returned in a random order is a border case, I believe it is better not to take this into the core search, and to enhance CALC with a
$LISTRAND(). With this it is easy to display a list of topics in random order: In the SEARCH add the topic name to a list, saved by
$SET(). After the SEARCH use a
$LISTRAND() to shuffle the list.
--
PeterThoeny - 07 Jun 2006
Could that approach be (easily) used to shuffle a highly formatted result from a search?
--
LynnwoodBrown - 07 Jun 2006
No, for this you'd need a hash variable feature in the SpreadSheetPlugin. Or, alternatively a SEARCH enhancement with a
order="random" option. Thinking this over, it would be OK to enhance the SEARCH even though it is an esoteric case. This is because it is a small change, and because it is out of the way from normal use.
--
PeterThoeny - 08 Jun 2006
I've submitted a
FeatureRequest to get further feedback:
RandomSearchOrder.
--
LynnwoodBrown - 08 Jun 2006