One of the programs I support use a random anonymous peer to peer evaluation. It is currently done using word with an excel randomizer attached so the students cannot select who the student is. Does anyone know a way I can accomplish this in Forms or Workflow? If you need more information please let me know. Thank you in advance for getting back to me with this information.
Question
Question
Replies
Could use a SQL stored procedure.
CREATE PROCEDURE GenerateRandomNumber
@min_value INT,
@max_value INT,
@random_number INT OUTPUT
AS
BEGIN
-- Ensure min_value is less than or equal to max_value
IF @min_value > @max_value
BEGIN
DECLARE @temp INT;
SET @temp = @min_value;
SET @min_value = @max_value;
SET @max_value = @temp;
END
-- Generate a random number within the specified range
SELECT @random_number = FLOOR(RAND() * (@max_value - @min_value + 1)) + @min_value;
END;
If you can sequentially number your rows, then you can create a Randomizer Formula rule to return a random row. Use the following syntax for the rule with a Min and Max input assigned. Then query the top row in your table before calling the rule to set the correct max row count value.
FLOOR(%(Min) + (((((DAY(NOW()) * 86400 + HOUR(NOW()) * 3600 + SECOND(NOW())) * 9301 + 49297) - FLOOR(((DAY(NOW()) * 86400 + HOUR(NOW()) * 3600 + SECOND(NOW())) * 9301 + 49297) / 233280) * 233280) / 233280) * (%(Max) - %(Min) + 1)))
If you're using on-prem Workflow, you could use a Script activity to write this pretty easily.
If you're using Cloud Workflow, you could use a Script rule (with Workflow's Run Rule activity) to do something similar.
If you don't know programming, you could probably use AI to generate the code for you--just be sure to test it thoroughly!
In addition to randomly assigning a peer, I would guess there are other conditions too, like "don't assign yourself to be the reviewer". Those are important instructions to include if using AI to generate the code.
Generating a random number to determine a reviewer for each member of the group will only work if it is acceptable that some members will be selected to review more than one peer and some may not be selected to review at all. If it is a requirement that the assignment is 1-1, then the assignments cannot be performed independently.
This is a common requirement though, so solutions are not hard to find. Googling "secret Santa list" brings up some ideas. The general process will be to first generate a random shuffle. By this, I mean a 1-1 assignment where it's not impossible for a person to be assigned to themselves. If you were writing this in code, it goes by the name "Fisher-Yates shuffle". If you are doing it in sql, you could make a table with the values 1...N, a column with a random guid, and use the sort position by the guid to determine the assignment. Then, check if anyone is assigned to themselves. If so, throw this assignment away and start over. The math works out that only about 2 in 3 random assignments will have someone assigned to themselves, so it's not a lot of extra work to start over. You wouldn't want to use this "rejection sampling" approach in the first stage, since generating random numbers is almost guaranteed to have duplicates.