From ec86f91ef45e182460ceb82c20f80a940c7f87c5 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 15 Mar 2024 15:30:01 -0400 Subject: [PATCH] fix: Provide a sequence to random.sample The sample function used to automatically convert sets to sequences but that is no longer supported starting in 3.11 so we have to do it manually. Reference: https://docs.python.org/3/library/random.html#random.sample --- xmodule/library_content_block.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index 00321639a735..db10009c583c 100644 --- a/xmodule/library_content_block.py +++ b/xmodule/library_content_block.py @@ -233,7 +233,7 @@ def make_selection(cls, selected, children, max_count, mode): pool = valid_block_keys - selected_keys if mode == "random": num_to_add = min(len(pool), num_to_add) - added_block_keys = set(rand.sample(pool, num_to_add)) + added_block_keys = set(rand.sample(list(pool), num_to_add)) # We now have the correct n random children to show for this user. else: raise NotImplementedError("Unsupported mode.")