Skip to content
Vignesh Sundar edited this page Nov 28, 2018 · 12 revisions

Testpress Exams SDK helps you to integrate Testpress exam features in your android app seamlessly.

Install

The Gradle dependency is available via jCenter.

repositories {
  jcenter()
}

dependencies {
  implementation 'com.github.testpress:exam:1.3.25'
}

Usage

There are two ways by which Testpress exams can be integrated with your application.

1. Open exams in a fragment

Use this method if Testpress exams view should be opened inside a container activity as a fragment. You might want to consider using this in case you have a navigation drawer and want to have an item as exams.

public static void show(FragmentActivity activity,
                        Integer containerViewId,
                        TestpressSession testpressSession)

Parameters:

  • activity - Parent activity which should hold the fragment
  • containerViewId - Container view id in which the exam fragment should be embedded
  • testpressSession - TestpressSession got from the core module
Usage example:
TestpressExam.show(
        this,
        R,id.fragment_container,
        TestpressSdk.getTestpressSession(this)
);
Note:

If the parent activity overrides

protected void onActivityResult(int requestCode, int resultCode, Intent data)

it should call its super

super.onActivityResult(requestCode, resultCode, data)

2. Open exams in a new activity

Use this method if you want Testpress exams view to be open as a new Activity.

public static void show(Context context,  TestpressSession testpressSession)

Parameters:

  • context - Context to start the new activity.
  • testpressSession - TestpressSession got from the core module
Usage example:
TestpressExam.show(this, TestpressSdk.getTestpressSession(this));

Note:

  • You must initialize the Testpress SDK successfully using core module before using the exam module.

Custom color

If you want to customize the look and feel, you can override the following variables in res/color.xml based on your requirements.

<resources>
    <color name="testpress_actionbar_background">#333399</color>
    <color name="testpress_actionbar_text">#ffffff</color>
    <color name="testpress_color_primary">#ff0000</color>
    <color name="testpress_button_text_color">#00ff00</color>
</resources>

Here, testpress_color_primary is the primary theme color.


Sample App

Refer the samples app for example implementation.

Clone this wiki locally