Refactor: Updating subparts of activity to accept object as a parameter instead of dict.
See original GitHub issueWe expect a domain object should only accept dict for the class method from_dict()
and we should avoid accepting dict for updating subparts of the object. In the following section we have curated a list of methods that needs to be refactored:
Subtopic: @RafayGhafoor
- update_page_contents_html
- update_page_contents_audio
State:
- update_content @RafayGhafoor
- update_param_changes @RafayGhafoor
- update_interaction_customization_args @sauravpratihar
- update_interaction_default_outcome @florinbalint
- update_interaction_hints @florinbalint
- update_interaction_answer_groups @Nik-09
- update_interaction_solution @anmol1point0
Question:
- update_question_state_data @teddymarchildon
Skill:
- update_explanation @Vinit-Dantkale
- update_worked_examples @nadintamer
- add_misconception @kiriakivel
You can follow these steps to complete the work (for each method):
- Find the place where the method is defined. (*_domain.py where * is the name of the class.)
- Change the method such that it accepts objects instead of dict (Also, do keep a record of how it’s converting the dict to object as you’ll be using this code later.).
- Update the docstring of the method.
- Find all files where this method is used.
- Update the caller to firstly convert the dict into a domain object, and only then send the domain object as a parameter.
- Look for the test file where this method is used and update the test files accordingly (you can use
git grep
to find all the cases where this method is used.) - Try running tests for the changed test files.
- Once the tests pass, you can create a PR!
Pr’s for reference: #8582 #8591 #8699 #7024
Note: For a guide on how to access Oppia’s webpages, see this.
Issue Analytics
- State:
- Created 5 years ago
- Comments:112 (90 by maintainers)
Top Results From Across the Web
python - Is it better practice to pass sometimes complex dicts ...
Yes, it is very usual to pass a dictionary to Python functions in order to reduce the number of arguments. Dictionary-style configuration ...
Read more >Dictionaries in Python - Real Python
In this Python dictionaries tutorial, you'll cover the basic characteristics and learn how to access and manage dictionary data. Once you have finished...
Read more >Groovy Language Documentation
String , but we pass a groovy.lang.GString instance, the toString() method of the GString is automatically and transparently called.
Read more >Are there guidelines on how many parameters a function ...
I've never seen a guideline, but in my experience a function that takes more than three or four parameters indicates one of two...
Read more >Solutions to Exercises - Springer Link
Arity is the number of arguments passed to a constructor or method or the ... List<Object>, you cannot pass an object whose type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RafayGhafoor, Thanks for the updates. (/cc @apb7 [onboarding mentor])
@RafayGhafoor, Yeah sure! 😃
I’ve assigned you to remaining parts of this issue, you can check the header comment of this issue.