diff --git a/server/app/database/controller/copy.py b/server/app/database/controller/copy.py index 8e0a39103ecbc195a76f41357ef4ef643ed1740a..08b14f439c83c342799f0aaedc0ac86ecec9d9b4 100644 --- a/server/app/database/controller/copy.py +++ b/server/app/database/controller/copy.py @@ -37,7 +37,11 @@ def _component(item_component, item_slide_new): Internal function. Makes a copy of the provided component item to the specified slide. """ - + data = {} + if item_component.type_id == 1: + data["text"] = item_component.text + elif item_component.type_id == 2: + data["image_id"] = item_component.image_id add.component( item_component.type_id, item_slide_new.id, @@ -45,6 +49,7 @@ def _component(item_component, item_slide_new): item_component.y, item_component.w, item_component.h, + **data, ) diff --git a/server/tests/test_db.py b/server/tests/test_db.py index cf10329ce6a320fdceb89ae9eba82da9e6b17092..dd13427c1c62689a88edefc96a6c16b8aa9db682 100644 --- a/server/tests/test_db.py +++ b/server/tests/test_db.py @@ -94,11 +94,13 @@ def check_slides_copy(item_slide_original, item_slide_copy, num_slides, order): assert c1.y == c2.y assert c1.w == c2.w assert c1.h == c2.h - assert c1.data == c2.data assert c1.slide_id == item_slide_original.id assert c2.slide_id == item_slide_copy.id assert c1.type_id == c2.type_id - + if c1.type_id == 1: + assert c1.text == c2.text + elif c1.type_id == 2: + assert c1.image_id == c2.image_id # Checks that all questions were correctly copied questions = item_slide_original.questions questions_copy = item_slide_copy.questions diff --git a/server/tests/test_helpers.py b/server/tests/test_helpers.py index cc630626822aa3358da79b7d9a9a132705982bdf..b5f1e54e136b759d9924a534acf2f37e6f7b08cd 100644 --- a/server/tests/test_helpers.py +++ b/server/tests/test_helpers.py @@ -59,7 +59,7 @@ def add_default_values(): # dbc.add.question(name=f"Q{i+1}", total_score=i + 1, type_id=1, slide_id=item_slide.id) # Add text component - dbc.add.component(1, item_slide.id, {"text": "Text"}, i, 2 * i, 3 * i, 4 * i) + dbc.add.component(1, item_slide.id, i, 2 * i, 3 * i, 4 * i, text="Text") def get_body(response):