From f4528e9bcec1678ecdb007668965ba65747dc287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Thu, 25 Apr 2024 21:09:05 +0200 Subject: [PATCH 1/4] create community csv file --- api/data/csv/community.csv | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 api/data/csv/community.csv diff --git a/api/data/csv/community.csv b/api/data/csv/community.csv new file mode 100644 index 0000000..0577926 --- /dev/null +++ b/api/data/csv/community.csv @@ -0,0 +1,19 @@ +,Questions,Correct,A,B,C,D +0,"There are many theories about the identity of this mysterious British serial killer. He marks the dawn of the modern age of serial murders. Although the number of his victims is not high, compared to others on our list (5), he is probably the worlds most famous serial murderer.",Jack The Ripper,Earl Frederick,Jack The Ripper,The Toledo Clubber,Joel Rifkin +1,He disliked Jews and accused them of causing all disasters in German history.,Hitler,Mussolini,Lenin,Stalin,Hitler +2,He delivered the famous I have a dream speech.,Martin Luther King Jr.,Mao Zedong,Martin Luther King Jr.,Ho Chi Minh,Pope John Paul II +3,She was the only woman to become Prime Minister of Great Britain.,Margaret Thatcher,Diane Julie Abbott,Queen Victoria,Margaret Thatcher,Elizabeth Furse +4,He was the only Pope of non-Italian origin since the Dutch-German Pope Adrian VI.,Pope John Paul II,John Paul I,Benedict XVI,Blessed John XXIII,Pope John Paul II +5,He was the only actor to become US President.,Ronald Reagan,Teddy Roosevelt,Franklin Delano Roosevelt,Ronald Reagan,Bill Clinton +6,He was the first democratically-elected President of South Africa.,Nelson Mandela,Nelson Mandela,Martin Luther King,Mao Zedong,Lech Walesa +7,He brought the cause of Indias independence to world attention.,Mohandas Gandhi,Ho Chi Minh,Lech Walesa,Nelson Mandela,Mohandas Gandhi +8,Which British Prime Minister is considered to have saved his country during WW2?,Winston Churchill,Edward Heath,Neville Chamberlain,Edward Churchill,Winston Churchill +9,He established the first fascist party.,Benito Mussolini,Hitler,Winston Churchill,Benito Mussolini,Stalin +10,"The name he is known as means Awakened One, Enlightened One.",Buddha,Jesus Christ,Dalai Lama,Buddha,Mohamed +11,"What is the subject of study of thanatology, personified in Greek mythology by Thanatos?",death,death,plague,birth,grave +12,"This astral body, known as Earths only natural satellite, is the subject of study selenology.",Moon,Sun,Venus,Jupiter,Moon +13,This contractile tissue of the body is the subject of study of myology.,muscles,blood cells,bones,hairs,muscles +14,"What term is used to designate a hurricanes calm, low-pressure center around which winds of high velocity spin?",Eye,Outer rim,Eye wall,Rain bands,Eye +15,A swallow hole is an unnatural depression in earths surface formed by the collapse of a large building.,False,True,False,, +16,What term refers to electric power produced by running or falling water?,Hydroelectric power,Nuclear power,Aquatic power,Hydrothermal power,Hydroelectric power +17,What term do scientists use to denote the gradual warming of the planet due to absorption of infrared radiation by the atmosphere?,Greenhouse effect,Greenhouse effect,Ozone depletion,Atmospheric termoincrease,Global dimming \ No newline at end of file From c33fbb862c0eeb5cf2e127495ee03b5fd728dd06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Thu, 25 Apr 2024 21:09:22 +0200 Subject: [PATCH 2/4] update migration --- api/masteriqapp/migrations/0002_auto_20240303_1147.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/api/masteriqapp/migrations/0002_auto_20240303_1147.py b/api/masteriqapp/migrations/0002_auto_20240303_1147.py index 1de3d31..7dcc179 100644 --- a/api/masteriqapp/migrations/0002_auto_20240303_1147.py +++ b/api/masteriqapp/migrations/0002_auto_20240303_1147.py @@ -36,9 +36,6 @@ def load_initial_data(apps, schema_editor): option_model.objects.create(text=df[letter][row], is_correct=False, question=question) print("Initial data loaded!") -def add_community_category(apps, schema_editor): - category_model = apps.get_model('masteriqapp', 'Category') - category_model.objects.create(name="Community", image_path='data\\images\\community.jpg') def add_category_images(apps, schema_editor): category_model = apps.get_model('masteriqapp', 'Category') @@ -57,6 +54,5 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(load_initial_data), - migrations.RunPython(add_community_category), migrations.RunPython(add_category_images) ] From 7214d4e6b5de4173afe17256fc0bdb79593c073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Thu, 25 Apr 2024 21:09:35 +0200 Subject: [PATCH 3/4] fix error when changing category --- api/masteriqapp/views/QuestionView.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/masteriqapp/views/QuestionView.py b/api/masteriqapp/views/QuestionView.py index 37ed5e5..8d634ca 100644 --- a/api/masteriqapp/views/QuestionView.py +++ b/api/masteriqapp/views/QuestionView.py @@ -54,7 +54,8 @@ class QuestionView(viewsets.ViewSet): def new(self, request, pk): category = get_object_or_404(self.queryset, pk=pk) if 'question' in request.session: - actual_question = self.question_model.objects.get(self.question_model.objects.all(), pk=request.session['question']) + print(request.session['question']) + actual_question = self.question_model.objects.get(pk=request.session['question']) if actual_question is not None and actual_question.category == category: serializer = QuestionSerializer(actual_question) return Response(serializer.data, status=status.HTTP_200_OK) From c8fb4ea7cad6d5aac95bc1ec75ba1ae495297fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Thu, 25 Apr 2024 21:10:02 +0200 Subject: [PATCH 4/4] remove useless print --- api/masteriqapp/views/QuestionView.py | 1 - 1 file changed, 1 deletion(-) diff --git a/api/masteriqapp/views/QuestionView.py b/api/masteriqapp/views/QuestionView.py index 8d634ca..3f1a993 100644 --- a/api/masteriqapp/views/QuestionView.py +++ b/api/masteriqapp/views/QuestionView.py @@ -54,7 +54,6 @@ class QuestionView(viewsets.ViewSet): def new(self, request, pk): category = get_object_or_404(self.queryset, pk=pk) if 'question' in request.session: - print(request.session['question']) actual_question = self.question_model.objects.get(pk=request.session['question']) if actual_question is not None and actual_question.category == category: serializer = QuestionSerializer(actual_question)