**************************************************** Steps to Add a new question to the asset inventory **************************************************** - never use question_option Checklist for adding/removing/updating a question in the asset inventory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Potential items to be accounted for when adding/removing/updating a question in the asset inventory: - adding/removing/changing the model field - contextual guidance: allowing contextual guidance to be added to the question - display in corresponding asset inventory page - display in corresponding upgrade option form - Audit API `pearlcertification.api.audit` - `QA checks `__ - `scoring `__ - scoring tests - Pearl API pearlcertification.public_api (mappings and tests). Pay close attention to removed or updated fields/choices and what to do about them in previous api versions - `HPXML Import `__ (pearlcertification.cert.hpxml_import) - `HPXML export `__ (pearlcertification.cert.hpxml_export) - `Home Energy Score `__ (pearlcertification.cert.hes usually a simple field name change if necessary) - Importing Homes from Resnet db (pearlcertification.cert.resnet_import) - `Comparison statements `__ (pearlcertification.comparison_statements.re_market) - `CR characteristics `__ (pearlcertification.reports.utils.cr) - `HIP characteristics `__ (pearlcertification.hip.report) - `Green Door characteristics `__ (pearlcertification.green_door.characteristics) - `AI Addendum `__ (pearlcertification.reports.utils.ai_addendum) - `MLS’s `__ (pearlcertification.reports.utils.mls) - Batch Home preprocessing for preprocessing_logic that uses the pearl API for creating assets (especially lennox) - check asset data stored in db (when removing or updating answers of a field): referencedata and recommendedimprovementsboilerplate - Baseline assets generation for recommended improvements - data migrations for existing homes data (pearlcertification.asset_inventory.utils.data_migration.HomeDataMigration.migrate_data) - data migrations for upgrade options (usually a one-time script needs to run to do this) Sample detailed scenario of adding a new question to the asset inventory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The scenario for this case describes the addition of a new question to the asset inventory. This is just an overview of the steps that need to happen. To know how to set the different attributes, make sure to check the implementation of existing questions and follow it. - create the new field under the **cert app** and run migrations. - add the field_name to the :code:`model.CONTEXTUAL_GUIDANCE` attribute if contextual guidance can be attached to the question. - add the new question under :code:`pearlcertification/asset_inventory/forms/.py`. The above steps will result in the question displayed in the asset inventory. The next steps depend on ticket requirements: some questions need to be displayed in one or many reports, some don't need to. Add a new asset characteristic based on the new question to the Certification Report (CR) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - An entry under an asset in the CR is called "Asset Characteristic". An Asset Characteristic is usually based on the answer to one question (but can also be based on many questions). - The asset characteristics are placed under :code:`reports/utils/cr/characteristics//.py`. - The characteristic class needs to implement the methods :code:`check_condition` (contains the logic for when the asset characteristic should appear on the CR) and the :code:`get_characteristic_display` (should return the text to be displayed in the CR). - Then, the new characteristic's class needs to be added to the corresponding asset_type class under :code:`reports/utils/cr/cr_data/asset_types.py`. Add the new question to AI Addendum ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - An entry in the AI Addendum is called a :code:`Question`. At a basic level, a :code:`Question` needs just an :code:`answer` and it belongs to a :code:`Section`. - To make things easier, a :code:`Question` can be either: - a :code:`CheckboxQuestion` where the :code:`answer` is a checked or unchecked checkbox if a certain condition :code:`is_verified` or, - a :code:`TextQuestion` where :code:`_asset_qs` is expected to return the asset needed to generate the :code:`answer_display`. - So, to add a new :code:`Question`, we need to create a new :code:`Question` class (or subclass :code:`CheckboxQuestion`/:code:`TextQuestion`) and implement the necessary methods. - A :code:`Question` class (or subclass) must have a :code:`name` attribute. The :code:`Section` class also has a :code:`name` attribute. Both are used to easily reference the :code:`Question` answer in the template using :code:`{{ sections...answer }}`. :code:`sections` is a dict containing all the questions related to the AI Addendum. - The :code:`Question` class should be added under under :code:`reports/utils/ai_addendum/data//
.py`. - Add the new question to its section under :code:`reports/utils/ai_addendum/data/sections.py`. - Then, the :code:`Question` answer need to be referenced correctly in the template under :code:`reports/ai_addendum/.html`.