Individual Contributions ‐ Ceydanur Şen - bounswe/bounswe2024group11 GitHub Wiki

Ceydanur Şen

Responsibilities

  • Development of the backend
  • Project Plan

Main Contributions

  • API Implementations:
    • Implementation of Hint API using BabelNet API
    • Implementation of Profile API
    • Implemenation of Bookmark/Unbookmark API
    • Implementation of Quiz and Quiz Question API
  • Search for hint mechanism approaches
  • Keeping in track according to the project plan with Muhammet Emin Çiftçi.

API Contributions

  1. Implemented quiz question and quiz APIs as a backend team member. These APIs are complex to implement since the quiz includes quiz questions. To handle this I implemented a lot of custom methods and used a nested serialzer structure.

Here is a sample call to the endpoint from the terminal using curl (Before executing it, you may need to change Bearer token in the headers part with an active JWT access token of yourself):

curl -X 'GET' \
  'http://138.68.97.90/api/v1/quizzes/?page=1&per_page=3'
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzMzNDkyMzYwLCJpYXQiOjE3MzI4ODc1NjAsImp0aSI6IjI4ODhmYjM0MjlhMzQ0NThhYWYwMDA5YWE5M2JhNzY3IiwidXNlcl9pZCI6OX0.BCnCtGqdW-LEF9NyTTKprVmXGZb48gSbX5JAV9yJdr4'

An example response:

{
 "count": 2,
 "next": null,
 "previous": null,
 "results": [
   {
     "id": 2,
     "title": "Cars Quiz",
     "description": "Test your knowledge about cars",
     "difficulty": 2,
     "author": {
       "id": 3,
       "username": "jackma",
       "email": "[email protected]",
       "full_name": "jackma",
       "avatar": "https://api.dicebear.com/9.x/avataaars/webp?accessories=eyepatch,kurt,prescription01&seed=David%20Bush"
     },
     "tags": [
       {
         "name": "car",
         "linked_data_id": "bn:00007309n",
         "description": "A motor vehicle with four wheels; usually propelled by an internal combustion engine"
       }
     ],
     "type": 2,
     "created_at": "2024-11-12T12:33:23Z",
     "questions": [
       {
         "id": 6,
         "question_text": "Kaput",
         "choices": [
           {
             "id": 21,
             "choice_text": "Hood",
             "is_correct": true
           },
           {
             "id": 22,
             "choice_text": "Fender",
             "is_correct": false
           },
           {
             "id": 23,
             "choice_text": "Bumper",
             "is_correct": false
           },
           {
             "id": 24,
             "choice_text": "Windshield",
             "is_correct": false
           }
         ]
       },
       {
         "id": 7,
         "question_text": "Vites",
         "choices": [
           {
             "id": 25,
             "choice_text": "Belt",
             "is_correct": false
           },
           {
             "id": 26,
             "choice_text": "Tire",
             "is_correct": false
           },
           {
             "id": 27,
             "choice_text": "Clutch",
             "is_correct": false
           },
           {
             "id": 28,
             "choice_text": "Gear",
             "is_correct": true
           }
         ]
       },
       {
         "id": 8,
         "question_text": "Debriyaj",
         "choices": [
           {
             "id": 29,
             "choice_text": "Brake",
             "is_correct": false
           },
           {
             "id": 30,
             "choice_text": "Clutch",
             "is_correct": true
           },
           {
             "id": 31,
             "choice_text": "Accelerator",
             "is_correct": false
           },
           {
             "id": 32,
             "choice_text": "Handbrake",
             "is_correct": false
           }
         ]
       }
     ],
     "num_taken": 1,
     "is_taken": false,
     "rating": {
       "score": 4,
       "count": 1
     },
     "is_my_quiz": false
   },
   {
     "id": 1,
     "title": "Technology Quiz",
     "description": "Test your knowledge about technology",
     "difficulty": 1,
     "author": {
       "id": 2,
       "username": "alibaba",
       "email": "[email protected]",
       "full_name": "alibaba",
       "avatar": "https://api.dicebear.com/9.x/avataaars/webp?accessories=eyepatch,kurt,prescription01&seed=Cody%20Ross"
     },
     "tags": [
       {
         "name": "technology",
         "linked_data_id": "bn:00030858n",
         "description": "The practical application of science to commerce or industry"
       }
     ],
     "type": 1,
     "created_at": "2024-11-02T02:30:20Z",
     "questions": [
       {
         "id": 1,
         "question_text": "Algorithm",
         "choices": [
           {
             "id": 1,
             "choice_text": "Algoritma",
             "is_correct": true
           },
           {
             "id": 2,
             "choice_text": "Yazılım",
             "is_correct": false
           },
           {
             "id": 3,
             "choice_text": "Veri",
             "is_correct": false
           },
           {
             "id": 4,
             "choice_text": "Ağ",
             "is_correct": false
           }
         ]
       },
       {
         "id": 2,
         "question_text": "Cloud Computing",
         "choices": [
           {
             "id": 5,
             "choice_text": "Bulut Bilişim",
             "is_correct": true
           },
           {
             "id": 6,
             "choice_text": "Veritabanı",
             "is_correct": false
           },
           {
             "id": 7,
             "choice_text": "Ağ",
             "is_correct": false
           },
           {
             "id": 8,
             "choice_text": "Sunucu",
             "is_correct": false
           }
         ]
       },
       {
         "id": 3,
         "question_text": "Artificial Intelligence",
         "choices": [
           {
             "id": 9,
             "choice_text": "Yapay Zeka",
             "is_correct": true
           },
           {
             "id": 10,
             "choice_text": "Robot",
             "is_correct": false
           },
           {
             "id": 11,
             "choice_text": "Bilişim",
             "is_correct": false
           },
           {
             "id": 12,
             "choice_text": "Veri Tabanı",
             "is_correct": false
           }
         ]
       },
       {
         "id": 4,
         "question_text": "Cybersecurity",
         "choices": [
           {
             "id": 13,
             "choice_text": "Siber Güvenlik",
             "is_correct": true
           },
           {
             "id": 14,
             "choice_text": "Firewall",
             "is_correct": false
           },
           {
             "id": 15,
             "choice_text": "Yazılım",
             "is_correct": false
           },
           {
             "id": 16,
             "choice_text": "Donanım",
             "is_correct": false
           }
         ]
       },
       {
         "id": 5,
         "question_text": "Virtual Reality",
         "choices": [
           {
             "id": 17,
             "choice_text": "Sanal Gerçeklik",
             "is_correct": true
           },
           {
             "id": 18,
             "choice_text": "Gerçek Zeka",
             "is_correct": false
           },
           {
             "id": 19,
             "choice_text": "Fiziksel Gerçeklik",
             "is_correct": false
           },
           {
             "id": 20,
             "choice_text": "Dijital Dünya",
             "is_correct": false
           }
         ]
       }
     ],
     "num_taken": 0,
     "is_taken": false,
     "rating": {
       "score": null,
       "count": 0
     },
     "is_my_quiz": false
   }
 ]
}

This endpoint is used in the core of the project since we can say that the core functionalities are forums and quizzes.

  1. Implemented hint enpoint for the quiz questions. This feature suggested by Suzan Üsküdarlı during the Milestone 1 presentation. The endpoint aims to retrieve 4 different hint types using an external API(BabelNet).

Here is a sample call to the endpoint from the terminal using curl (Before executing it, you may need to change Bearer token in the headers part with an active JWT access token of yourself):

curl -X 'GET' \
  'http://138.68.97.90/api/v1/hint/?synset_id=bn%3A00007309n&target_lang=EN&word=car' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzMzNDkyMzYwLCJpYXQiOjE3MzI4ODc1NjAsImp0aSI6IjI4ODhmYjM0MjlhMzQ0NThhYWYwMDA5YWE5M2JhNzY3IiwidXNlcl9pZCI6OX0.BCnCtGqdW-LEF9NyTTKprVmXGZb48gSbX5JAV9yJdr4' 

An example response:

{
 "synonyms": [
   "auto",
   "automobile",
   "machine",
   "motorcar"
 ],
 "definitions": [
   "A motor vehicle with four wheels; usually propelled by an internal combustion engine",
   "A car is a wheeled motor vehicle used for transportation.",
   "Road vehicle powered by a motor to carry driver and small number of passengers",
   "A four-wheeled motor vehicle used for land transport.",
   "A type of vehicle designed to move on the ground under its own stored power and intended to carry a driver, a small number of additional passengers, and a very limited amount of other load. A car or motorcar.",
   "Passenger vehicle.",
   "A wheeled vehicle, drawn by a horse or other animal; a chariot.",
   "A vehicle operated mechanically, such as an automobile or an airplane."
 ],
 "examples": [
   "He needs a car to get to work"
 ],
 "images": [
   "https://upload.wikimedia.org/wikipedia/commons/2/2b/Lexus_LF-A_Pic_2.JPG",
   "https://upload.wikimedia.org/wikipedia/commons/a/a9/Lamborghini_Aventador_LP_700-4_-_Flickr_-_Alexandre_Pr%C3%A9vot_%281%29.jpg",
   "https://upload.wikimedia.org/wikipedia/commons/a/a0/Capture_d%E2%80%99%C3%A9cran_2016-10-14_%C3%A0_21.26.28.png",
   "https://upload.wikimedia.org/wikipedia/commons/6/6f/Mustang_Shelby_GT-H.JPG",
   "https://upload.wikimedia.org/wikipedia/commons/2/2c/VW_Golf_VI_20090905_front-1.JPG"
 ]
}

  1. Implemented forum-bookmark endpoint. This endpoint aims to improve user experience.

Here is a sample call to the endpoint from the terminal using curl (Before executing it, you may need to change Bearer token in the headers part with an active JWT access token of yourself):

curl -X 'POST' \
  'http://138.68.97.90/api/v1/forum-bookmarks/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzMzNDkyMzYwLCJpYXQiOjE3MzI4ODc1NjAsImp0aSI6IjI4ODhmYjM0MjlhMzQ0NThhYWYwMDA5YWE5M2JhNzY3IiwidXNlcl9pZCI6OX0.BCnCtGqdW-LEF9NyTTKprVmXGZb48gSbX5JAV9yJdr4' \
  -H 'Content-Type: application/json' \
  -d '{
  "forum_question": 2
}'

An example response:

{
  "id": 2,
  "user": 9,
  "forum_question": 2,
  "created_at": "2024-11-29T14:07:31.993804Z"
}

Code Related Significant Issues

Issue Title Description Issue and/or PR Link
Implement Quiz and QuizQuestion Endpoints Implemented Quiz Question and Quiz models, serializers, and views. Also, implemented unit tests and write swagger documentation for the API. This issue is significant since quizzes are one of the main features of our app. In the demo, we showed how to create quiz and quiz questions successfully. #594
Implement Hint Mechanism for Quizzes Implemented hint mechanism for quiz questions, and added API documentation. For this part, I tried to come up with an effective solution for our hint implementation. In the demo, while creating the quiz questions users can add hints. There are four different choice to add as a hint (image, synonym, definition and examle sentence). #608
Implement Bookmark/Unbookmark Functionality for Forum Questions Implemented model, serializer and the views for the bookmark/unbookmark speciality for forum questions. Also, added API documentation. In the demo we demonstrated this part successfully. #626
Change the QuizQuestion Implementation to Add New Fields Changed and add some extra fields for our quiz question models in one of our Lab Session. #648
Implement Profile Enpoint for Authenticated Users Implemented profile serializer, views and API documentation. In demo we showed the profile page but since it is still in progress it was not connected to backend. #681

Management Related Significant Issues

Issue Title Description Issue and/or PR Link
Add Detailed Error Messages to Swagger Documentation For most API we can see the error codes and messages also for some other endpoints we are planning to improve the error messages returned. The aim of this issue is to make the error messages readable and easier to understand. Also documentation helps us to develop and understand the API efficiently. #605
Add swagger for HintView For the hint mechanism since the endpoint includes different functionalities, swagger helped us to understand and access the API impelemented by other team members. For faster and efficient code generation this was a significant issue to do. #672
Add Bearer Authentication Header for Swagger We changed the authentication mechanism to fulfill our needs with Mücahit Ünlü. #604
Refactor & Merge Backend Branches Branches created for backend implementations were not organized and contain unnecessary ones. Therefore, with Ozan, Mücahit, Muhammet Çiftçi and I merged the branches together and removed the unnecassary branches. By doing so, we reviewed the code implementations together and created a clear working space for our backend team. ##623

PRs

PR Summary
#624 This PR is related to implementing RESTful endpoints for managing Quizzes and QuizQuestions within our Django application. There was not any conflicts for this PR.
#636 This PR is related to implementing bookmark and unbookmark features for forum questions. There was not any conflicts for this PR.
#694 This PR is related to implementing profile page for the users. However, for this milestone even if I implemented the endpoint, we could not use it since for the client side it is still in progress. There is a little conflict about the indentation but when we merge the PR we will resolve this issue simply.
#619 This PR is related to implementing hint mechanism and I created this PR in our Lab(6). After some discussion we decided not to use the logic but use another more efficient one for the hints. Therefore, PR is closed without merging.

Additional

I have also implemented profile API but for the client side it is still in progress. Therefore, we could not demonstrate this feature (connected to backend) in Milestone 2.