-
Notifications
You must be signed in to change notification settings - Fork 121
Feature/import download tutorials csv backend #59
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
base: 8.0.x
Are you sure you want to change the base?
Feature/import download tutorials csv backend #59
Conversation
|
Clear Separation of Endpoints Built-in Model Methods Validation Before Save Test Coverage Instructions |
DauDAtem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear Separation of Endpoints
Import and export are logically separated into POST and GET handlers, making the API intuitive.
Built-in Model Methods
Embedding CSV parsing/serialization into the Tutorial model simplifies reuse and keeps controller code concise.
Validation Before Save
Ensuring CSV rows conform to the model prevents malformed data from entering the database.
Test Coverage Instructions
Clear instructions for running both the full suite and the specific tutorial model tests help reviewers verify functionality quickly.
|
Hi @samindiii great work on your PR — it looks solid overall!
|
b0ink
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicks on single vs double string quotes, and a couple discussion points regarding how we retrieve the tutors (unit roles) and if the endpoint should be an extension to the unit entity instead of retrieving the unit id from the CSV
| code,abbreviation,unit_id,tutor_id,tutorial_stream | ||
| test,CS3,4,8, | ||
| ,FX1,1,2,Practical-1 No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the name of the tutor instead of their ID to make things easier if any changes to the CSV need to be made before importing?
This would require the tutor to already be added as a unit role to the unit, and throw a warning for each row that has a tutor name that isn't part of the unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do that but isn't it much better to use ID since it is a unique identifier? If two tutors have the same name or if a tutor has two accounts with the same name but different IDs, how would we know which one to choose? I feel like it is bad practice to use name, which is not a primary key to identify a user, correct me if I'm wrong :)
| params do | ||
| requires :file, type: File, desc: 'CSV upload file.' | ||
| end | ||
| post '/csv/tutorials/upload' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the endpoint be an extension to the unit entity? So that the unit_id is used from the endpoint and not required in the CSV
It would allow the exact same CSV to be imported into two different units
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand why this is necessary. Based on my understanding, two different units cannot have the same tutorials. Will there be a situation where multiple units would have the exact same tutorials given that the information provided in the csv is tutorial specific and tutorials are unit specific?
|
Hi @samindiii Good work on the fixes , I’ve tested the changes and everything is working as expected. Approved from my end |
…ion to prevent partially imported dataset
abcbd7e to
58b5b07
Compare
|
@samindiii LGTM. Please open an upstream pull request against 9.x branch in /doubtfire-lms/doubtfire-api. |

Description
This PR implements backend functionality to manage tutorials via CSV files. It introduces new POST and GET endpoints for importing and exporting tutorials, respectively.
Key Features:
POST Endpoint (Import Tutorials from CSV):
A new POST endpoint is added to handle the import of tutorial data from CSV files.
The endpoint processes incoming CSV files, parses the data, and creates new tutorial records in the database.
Validation ensures that the CSV data is correctly formatted and matches the tutorial model before saving it to the database.
GET Endpoint (Export Tutorials to CSV):
A new GET endpoint is introduced to export tutorials as CSV files.
The endpoint generates a CSV file containing tutorial data, which can be downloaded by the user.
The exported CSV includes all relevant fields associated with the tutorials.
Integration with Tutorial Model:
The tutorial model is extended to support the import and export functionality.
Methods for parsing CSV data and converting tutorial records into CSV format are implemented directly within the tutorial model.
Type of change
How Has This Been Tested?
In your terminal, change directory to doubtfire-api. If you are in doubtfire-deploy, run the following:
cd doubtfire-apiRun the following to run all existing tests
rails testRun the following if you want to specifically run my test
rails test test/models/tutorial_model_test.rbAdditionally, if you want to test the integration, follow these steps:
Checklist: