From 533cae0b792b1f487b4c7cec609c02a7aa791931 Mon Sep 17 00:00:00 2001 From: TropiiDev Date: Wed, 29 Jan 2025 21:31:20 -0500 Subject: [PATCH] Implement a geography theme --- commands/__pycache__/quiz.cpython-313.pyc | Bin 5003 -> 5172 bytes commands/quiz.py | 13 +- .../leaderboard_helper.cpython-313.pyc | Bin 1173 -> 1206 bytes lib/__pycache__/quiz_helper.cpython-313.pyc | Bin 7032 -> 9069 bytes lib/leaderboard_helper.py | 6 +- lib/quiz_helper.py | 192 ++++++++++++------ 6 files changed, 139 insertions(+), 72 deletions(-) diff --git a/commands/__pycache__/quiz.cpython-313.pyc b/commands/__pycache__/quiz.cpython-313.pyc index 6a7170da96ba832066bdfefba53cbf03b484c12e..2bae9bd7e3a4c8ef7426fa056b82d1b7cdfebdd0 100644 GIT binary patch delta 1583 zcmZ8hUrbw77(eH>w|{PX3-^{{E0jM4ifxb#DwzdF7!n+)Ot`CKTxadtyHf2RIW044 zvJs7@#1Y(%I@FgfF)BVN3qJT_qKhVm2SZ0<$<2Jwm>6G{IhJg`dCt9F2YyMvd%oZI z|9s!++nrxM#P9Mv2MDeG@?rYcRelWyoDhH^_#Tiz3}mTFBbhNy(`LL0oBQ_2hUWe^ z03=qjNLI-lHSP0kVwxR$Jn@nL$%tvIu^4fVF)?sb*!Y~noU?Cvds9gnYUKF{Hs<}Wxqf!-j$-9`Kf+vT{(z}}27rW> zXia;yGHcky@L$l=-}kRyo{@>IPBKlQQH(M4#@7vwJOe=9By$(?jd<8$o{E_y_F-b} z0ug4WjfR&jQ6_JW!D*KsWiOu=_DcFWW|rLsI@7Dw#r2tVM6%+iYwB8`BF#8J3rGVS zn6w`>orWRXB%-&B=xC7(|6u8<<5bI;M0P z*q?w5$x*X1ur%<_{L;|siET%4#}_D%E>G<6!iu~kuL|duo?Crwn-A~!+RLNoCw{LB zTz=%!{ww|4b=_tA4Wa(s;%XG1{aFZ>58n{Hm;4v~mtR>I)~Bv|)~#C|kA9o^E?W_# z^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R@K6W zzwm><@Q_F9!3R95*E;@^P+$`OV>PlGK6v@1lOn#`i%;^x-99fn-=cp=u^^0>1R2=g zA+utTYz~?xM`*mRb1=+!iwzX@lL*+s*c}i+(Z=BMN9b=(;*;EiW}ctKH#;_>C)T1T zwh>4V9V8lEt{cNa>h;VCdm%!IUhyc;IrrscfN5xR)f6H6jVFlr(0iV!R|Df08R#O- z1{55k5$~S;P9&02?8*4qqVM}Lu<7t$Z6KUe9W z{k)8jA21z diff --git a/commands/quiz.py b/commands/quiz.py index 691119d..54e4ded 100644 --- a/commands/quiz.py +++ b/commands/quiz.py @@ -5,6 +5,7 @@ from lib.quiz_helper import * class Select(discord.ui.Select): def __init__(self): + self.theme = None options = [ discord.SelectOption(label="History", emoji="1️⃣", description="Do you know your past?"), discord.SelectOption(label="Geography", emoji="2️⃣", description="Do you know your geography?"), @@ -16,10 +17,14 @@ class Select(discord.ui.Select): async def callback(self, interaction: discord.Interaction): if self.values[0] == "History": - questions = load_history_questions() - for i in range(len(questions)): - em = discord.Embed(title=f"Question {i + 1}", description=questions[i]) - await interaction.response.send_message(embed=em, view=load_history_view(i, questions)) + self.theme = "History" + elif self.values[0] == "Geography": + self.theme = "Geography" + + questions = load_questions(self.theme) + for i in range(len(questions)): + em = discord.Embed(title=f"Question {i + 1}", description=questions[i]) + await interaction.response.send_message(embed=em, view=load_view(i, questions, self.theme)) class SelectView(discord.ui.View): def __init__(self): diff --git a/lib/__pycache__/leaderboard_helper.cpython-313.pyc b/lib/__pycache__/leaderboard_helper.cpython-313.pyc index b490aa26b6b2878c9f5f1c27bb442d838d5f38f0..d27270f1ab0e14e1ccf227222df421ede603854b 100644 GIT binary patch delta 366 zcmbQrxs8+eGcPX}0}w2}KPx?FBJWW#CJ+w_*nu=N5Px1b`2mv=D^n;_vdm<8Mg`tr z#t23}hG3>(W&=ip$!?6sT%jO7n=w#iaxJ5T?k&E=-2BqKlKABOqN3E~l9!A?V?wG} zR5J6DtN8U$B`5D?)Rtww#a>#RS`?p|a*MSjBQ-bm77K`946M}PY7Nx^}ZnCbA`kA2EXtV7LIoRM*j(+ zGu$tTs4OVkV7ftlhx`Qt&l83h^nEX=`CVc0pL~$1gOP2r7qg5wAJEWS>`=!;+@PRP z#6P)~S&~t7@^ofO=ZMRrJjAD?1lf{?R@D_oXspF&I>f;7CY2!#ULLmC@2*1O`gXr$tW^; w2eUn+z~mpyK8hdK>z>% diff --git a/lib/__pycache__/quiz_helper.cpython-313.pyc b/lib/__pycache__/quiz_helper.cpython-313.pyc index ed2362b28134754d168b3dfd5ea0c4e92193bb33..bbded510af40ad33a212956121ba204173d35eee 100644 GIT binary patch delta 4693 zcma)9ZEO_B8QwYHx4+Il<8SbAkhnGrv9S#%5Dd7+Q2fQ64;-B2SnkHYHG8|4**%}V zsd`9}Du}2G-9|*Ml+r(KB2`MO{AkohsTxJe&tN$z=)#Xw$&XSg4aGsB|N74Ct-q2; z8Qs1+^Uk~P%)IkF@60{g_r>w5mCDMX0OjmwznZ=qs)0`tby32yjx}|US${Sy8LT0xczof4mdA>8kqnso zxjrprvqaUgp;1z76y`s}yhySN)BffV;F?W1qk*BUYYMC{g|mv3BoL=H zbDU((*u+jitTK|ih%aa(<34yCLqc3mvYa2TU`h z7tAIj3RQ|Gr4p+>v>bXo@aX*@E(v!+wU%X=yYSH&Dkmkgy&E6J$sC;rv@+(xzS9iU zXQ-9|W~4Q$6FsdFGq4vAQB8*!n^ir)M0J&orneW5$qJbC;p4KZ0Flh4}I zqSoi$?kEc_=7qAXU98~nlTo6A%UiMiN zzL|*%u>W?vy$U_+@b*37W?_G;)#hnv@T`NEcO$$Sd>i5AfXEv6zk|B1sz5u!Z}tT~ zM1>NbTDovd%Rx3e3OfN|6o+zD%M$UZ4tsl;LrkVgNKw>I(&ABUz_zQi3fZm0AyEP! zsP*S_65XIQckIQ-DIq50B5@cJsth}&sp2G+)PkOsDQ}uvdhm#x0cc2Yph&uSOq^PJa7+0N>sK!*FIYac^yqwd`_Wk%6p_yC?j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gpP>BeI#`goe=AxATNa}wizGc$6 zA_r)2B^9CDSNcOVe!XWaEz;AQ&!*0#mZDt?(T=X`1gEYarY<@{PuHBSJyUzO;Y`Dy J1jn|ze*xSdKb8Oh diff --git a/lib/leaderboard_helper.py b/lib/leaderboard_helper.py index 931de77..9ddd9c8 100644 --- a/lib/leaderboard_helper.py +++ b/lib/leaderboard_helper.py @@ -5,14 +5,14 @@ client = pymongo.MongoClient(os.getenv('mongo_url')) db = client.quiz coll = db.leaderboard -def increment_history_correct(user_id): +def increment_correct(user_id, theme): user = coll.find_one({"_id": user_id}) if user is None: - coll.insert_one({"_id": user_id, "amount_correct": 1}) + coll.insert_one({"_id": user_id, f"{theme}": { "amount_correct": 1}}) return True - coll.update_one({"_id": user_id}, {"$inc": {"amount_correct": 1}}) + coll.update_one({"_id": user_id}, {"$inc": {f"{theme}.amount_correct": 1}}) return True def get_correct_answers(user_id): diff --git a/lib/quiz_helper.py b/lib/quiz_helper.py index 63464cd..f09a9d8 100644 --- a/lib/quiz_helper.py +++ b/lib/quiz_helper.py @@ -2,45 +2,85 @@ import discord import random from lib.leaderboard_helper import * -def load_history_questions(): - questions = [ - "When did the second world war start (based on allied views)?", - "When did the second world war end?", - "Which of these was one of the superpowers in the cold war?", - "Who was the loader of North Korea in 1945?", - "Which country here gained independence between 1945 and 1950?", - "When was the first Punic War?", - "Who was the leader of the Soviet Union in 1957?", - "Who was the leader of the United States in 1966?", - "What combat method was used by the Vietnam in the Vietnam war?", - "What was the 1st Reich?", - "Which battle defeated Harald Hardrada of Norway in 1066?", - "Approximately how many people died in World War 2?", - "What ideology was Hungary in 1919?", - "Who developed the ideology of Communism?", - "What happened in Tiananmen Square?" - ] +def load_questions(theme): + questions = [] + if theme == "History": + questions = [ + "When did the second world war start (based on allied views)?", + "When did the second world war end?", + "Which of these was one of the superpowers in the cold war?", + "Who was the loader of North Korea in 1945?", + "Which country here gained independence between 1945 and 1950?", + "When was the first Punic War?", + "Who was the leader of the Soviet Union in 1957?", + "Who was the leader of the United States in 1966?", + "What combat method was used by the Vietnam in the Vietnam war?", + "What was the 1st Reich?", + "Which battle defeated Harald Hardrada of Norway in 1066?", + "Approximately how many people died in World War 2?", + "What ideology was Hungary in 1919?", + "Who developed the ideology of Communism?", + "What happened in Tiananmen Square?" + ] + elif theme == "Geography": + questions = [ + "Name which continent Kenya is on.", + "What is an Oxbow lake?", + "What happens to the coast when water interacts with it?", + "What is the capital of El Salvador?", + "What is the longest river in the world?", + 'What country is known as "Land of a Thousand Lakes"?', + "What is the tallest mountain in the world?", + "What is the most isolated place on the world called?", + "How many bodies of water is the Great Lakes made of?", + "What is the 6th most populated country in the world?", + "What is the capital city of Malta?", + 'Which of the following is a "wonder of the world"?', + "What is the smallest Country in the world?", + "What is the smallest US state?", + "What is the most populated city in the world?" + ] return questions -def load_history_answers(question): - answers = [ - '0 1939', - '1 1945', - '2 USA,USSR', - '3 Terentii Shtykov,Kim Il-Sung', - '4 Vietnam,Indonesia,Philippines,Jordan,India,Pakistan,Myanmar,SriLanka (Ceylon),Israel,Laos,Cambodia,Syria', - '5 264 BC - 241 BC', - '6 Nikita Khrushchev', - '7 Lyndon B Johnson', - '8 Guerrilla Warfare', - '9 Holy Roman Empire', - '10 Battle of Stamford Bridge', - '11 70 - 85 million', - '12 Communist', - '13 Karl Marx', - '14 Nothing,Massacre' - ] +def load_answers(question, theme): + answers = [] + if theme == "History": + answers = [ + '0 1939', + '1 1945', + '2 USA,USSR', + '3 Terentii Shtykov,Kim Il-Sung', + '4 Vietnam,Indonesia,Philippines,Jordan,India,Pakistan,Myanmar,SriLanka (Ceylon),Israel,Laos,Cambodia,Syria', + '5 264 BC - 241 BC', + '6 Nikita Khrushchev', + '7 Lyndon B Johnson', + '8 Guerrilla Warfare', + '9 Holy Roman Empire', + '10 Battle of Stamford Bridge', + '11 70 - 85 million', + '12 Communist', + '13 Karl Marx', + '14 Nothing,Massacre' + ] + elif theme == "Geography": + answers = [ + "0 Africa", + "1 A curved lake formed from a horseshoe", + "2 Erosion", + "3 San Salvador", + "4 Nile", + "5 Finland", + "6 Mount Everest", + "7 Point Nemo", + "8 5", + "9 Nigeria", + "10 Valletta", + "11 The Great Wall of China,Petra,Christ the Redeemer,Machu Picchu,Chichen Itza,The Colosseum and The Taj Mahal", + "12 Vatican City", + "13 Rhode Island", + "14 Tokyo" + ] answer = answers[question] if ',' in answer: @@ -50,38 +90,59 @@ def load_history_answers(question): else: return answer.split(f"{str(question)} ")[1] -def load_history_choices(question): - choices = [ - '0 1940,1938,1914', - '1 1946,1944,1918,1920', - '2 China,The UK,Germany', - '3 Syngman Rhee,Chiang Kai-shek,Kim Jong Un', - '4 Bahrain,Canada,Australia', - '5 300 BC - 200 BC,264 BC - 146 BC,120 BC -116 BC', - '6 Leonid Brezhnev,Joseph Stalin,Mikhail Gorbachev', - '7 John F. Kennedy,Dwight D. Eisenhower,Richard Nixon', - '8 Air Strikes,Nuclear Warfare,Hand-to-Hand Combat', - '9 Byzantine Empire,Ottoman Empire,Russian Empire', - '10 Battle of Hastings,Battle of Waterloo,Battle of Gettysburg', - '11 100 - 120 million,15 to 30 million,30 to 45 million', - '12 Capitalist,Monarchist,Fascist', - '13 Vladimir Lenin,Joseph Stalin,Friedrich Engels', - '14 The Fall of the Great Wall of China,A Soccer/Football Match,The signing of the Magna Carta' - ] +def load_choices(question, theme): + choices = [] + if theme == "History": + choices = [ + '0 1940,1938,1914', + '1 1946,1944,1918,1920', + '2 China,The UK,Germany', + '3 Syngman Rhee,Chiang Kai-shek,Kim Jong Un', + '4 Bahrain,Canada,Australia', + '5 300 BC - 200 BC,264 BC - 146 BC,120 BC -116 BC', + '6 Leonid Brezhnev,Joseph Stalin,Mikhail Gorbachev', + '7 John F. Kennedy,Dwight D. Eisenhower,Richard Nixon', + '8 Air Strikes,Nuclear Warfare,Hand-to-Hand Combat', + '9 Byzantine Empire,Ottoman Empire,Russian Empire', + '10 Battle of Hastings,Battle of Waterloo,Battle of Gettysburg', + '11 100 - 120 million,15 to 30 million,30 to 45 million', + '12 Capitalist,Monarchist,Fascist', + '13 Vladimir Lenin,Joseph Stalin,Friedrich Engels', + '14 The Fall of the Great Wall of China,A Soccer/Football Match,The signing of the Magna Carta' + ] + elif theme == "Geography": + choices = [ + "0 South America,Europe,Asia", + "1 A circular river,A triangle-shaped lake,A square-shaped lake", + "2 Freezing,Glaciation,Transpiration", + "3 Lima,Caracas,Bogota", + "4 Amazon River,Yangtze River,Mississippi River", + "5 Norway,Switzerland,Sweden", + "6 Mount Fuji,Mount Kilimanjaro,Mount Vesuvius", + "7 Bermuda Triangle,South Pole,Loch Ness", + "8 7,3,8", + "9 South Korea,Russia,Germany", + "10 London,Athens,Paris", + "11 Eiffel Tower,Statue of Liberty,Big Ben,Sphinx,Red Square", + "12 Monaco,Liechtenstein,San Marino,Andorra", + "13 Texas,Connecticut,New Jersey", + "14 Mexico City,New York,Beijing" + ] choice = choices[question] only_choice = choice.split(f"{str(question)} ")[1] question_choices = only_choice.split(',') return question_choices -class load_history_select(discord.ui.Select): - def __init__(self, question, questions): +class load_select(discord.ui.Select): + def __init__(self, question, questions, theme, correct): super().__init__() + self.correct = correct self.question = question self.questions = questions - self.answer = load_history_answers(question) - self.correct = 0 - choices = load_history_choices(question) + self.theme = theme + self.answer = load_answers(question, self.theme) + choices = load_choices(question, self.theme) options = [] responses = [] @@ -106,10 +167,11 @@ class load_history_select(discord.ui.Select): if isinstance(self.answer, list): if any(value in self.answer for value in self.values): self.correct += 1 - increment_history_correct(interaction.user.id) + increment_correct(interaction.user.id, self.theme) else: if self.values[0] == self.answer: - increment_history_correct(interaction.user.id) + self.correct += 1 + increment_correct(interaction.user.id, self.theme) await interaction.response.send_message("Answer recorded..") @@ -118,11 +180,11 @@ class load_history_select(discord.ui.Select): if next_question_index < len(self.questions): next_question = self.questions[next_question_index] em = discord.Embed(title=f"Question {next_question_index + 1}", description=next_question) - await interaction.followup.send(embed=em, view=load_history_view(next_question_index, self.questions)) + await interaction.followup.send(embed=em, view=load_view(next_question_index, self.questions, self.theme, self.correct)) else: await interaction.followup.send(f"You finished the quiz. You got {self.correct} answers correct!") -class load_history_view(discord.ui.View): - def __init__(self, question_index, questions): +class load_view(discord.ui.View): + def __init__(self, question_index, questions, theme, correct = 0): super().__init__(timeout=None) - self.add_item(load_history_select(question_index, questions)) \ No newline at end of file + self.add_item(load_select(question_index, questions, theme, correct)) \ No newline at end of file