Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mbu 165 backend add default questions in community category #170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/data/csv/community.csv
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions api/masteriqapp/migrations/0002_auto_20240303_1147.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -57,6 +54,5 @@ class Migration(migrations.Migration):

operations = [
migrations.RunPython(load_initial_data),
migrations.RunPython(add_community_category),
migrations.RunPython(add_category_images)
]
2 changes: 1 addition & 1 deletion api/masteriqapp/views/QuestionView.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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'])
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)
Expand Down
Loading