Skip to content

Fix code formatting for data capture getting started #2726

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions build-docs.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ mkdir -p site/
# is up-to-date with the Pipfile before installing. If it's not, it will fail the
# installation. This is useful for ensuring strict dependency control during CI.
pipenv install --deploy
pipenv run pip install -U setuptools
pipenv run mkdocs build --strict
60 changes: 30 additions & 30 deletions docs/use/SDCL/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,44 +48,44 @@ your app, follow these steps:
1. Add a `FragmentContainerView` to your activity's layout to contain the
Questionnaire.

```xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
... >

<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
```
```xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
... >

<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
```

1. Create a bundle with the JSON questionnaire content for the fragment, in
this case as a `String` read from a JSON file stored in the `assets` folder.

```kotlin
// Small questionnaires can be read directly as a string, larger ones
// should be passed as a URI instead.
val questionnaireJsonString =
application.assets.open("questionnaire.json")
.bufferedReader().use { it.readText() }

val bundle = bundleOf( QuestionnaireFragment.EXTRA_QUESTIONNAIRE_JSON_STRING to
questionnaireJsonString )
```
```kotlin
// Small questionnaires can be read directly as a string, larger ones
// should be passed as a URI instead.
val questionnaireJsonString =
application.assets.open("questionnaire.json")
.bufferedReader().use { it.readText() }

val bundle = bundleOf( QuestionnaireFragment.EXTRA_QUESTIONNAIRE_JSON_STRING to
questionnaireJsonString )
```

1. Set the fragment to the `FragmentContainerView`.

```kotlin
if (savedInstanceState == null) {
supportFragmentManager.commit {
setReorderingAllowed(true)
add<QuestionnaireFragment>(R.id.fragment_container_view, args = bundle)
}
```kotlin
if (savedInstanceState == null) {
supportFragmentManager.commit {
setReorderingAllowed(true)
add<QuestionnaireFragment>(R.id.fragment_container_view, args = bundle)
}
```
}
```

## Get a QuestionnaireResponse

Expand Down