-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Creating Value Generators
Parameters that are included within an exploration (both at the exploration level and the interactive widget level) must each specify both a value generator and an object type. The object type specifies the type of the parameter, while the value generator is responsible (via its generate_value
function) for providing an object of the given type when the widget runs. For example, it might simply return a copy of an object given to it (Copier
), or it might randomly select an object from a given list (RandomSelector
).
Let's suppose you want to create a new value generator called MyValueGenerator
(though in practice you should use a more descriptive name).
- In
extensions/value_generators/models/generators.py
add a classMyValueGenerator
that derives fromvalue_generators_domain.BaseValueGenerator
. It should contain agenerate_value
function that takes thecustomization_args
provided by the widget for the parameter in question, and returns an object of the type the widget specifies for this parameter. - In `extensions/value_generators/models/generators_test.py add tests for your class.
- In
extensions/value_generators/templates/
, add a filemy_value_generator.html
that will be used to display the form for editing parameters. The html from the relevant object's template will have been automatically compiled into aobject-editor
html tag which you should use here. - Add a companion
MyValueGenerator.js
javascript file.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- FAQs
- How to get help
- Getting started with the project
- How the codebase is organized
- Making your first PR
- Debugging
- Testing
- Codebase policies and processes
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Testing jobs and other features on production
- Guidelines for Developers with Write Access to the Oppia Repository
- Release schedule and other information
- Revert and Regression Policy
- Privacy aware programming
- Code review:
- Project organization:
- QA Testing:
- Design docs:
- Team-Specific Guides
- LaCE/CD:
- Developer Workflow:
Developer Reference
- Oppiabot
- Git cheat sheet
- Frontend
- Backend
- Backend Type Annotations
- Writing state migrations
- Calculating statistics
- Storage models
- Coding for speed in GAE
- Adding a new page
- Adding static assets
- Wipeout Implementation
- Notes on NDB Datastore transactions
- How to handle merging of change lists for exploration properties
- Instructions for editing roles or actions
- Protocol buffers
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Performance testing
- Build process
- Best practices for leading Oppia teams
- Past Events