Skip to content
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

Fraction type JSONObject Parsing Error #4202

Open
anandwana001 opened this issue Feb 17, 2022 · 22 comments · May be fixed by #5610
Open

Fraction type JSONObject Parsing Error #4202

anandwana001 opened this issue Feb 17, 2022 · 22 comments · May be fixed by #5610
Assignees
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks. Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@anandwana001
Copy link
Contributor

anandwana001 commented Feb 17, 2022

Describe the bug
Fraction's rule type HasIntegerPartEqualTo is not parsing correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Chapter 6 - Mixed Numbers and the Number line (Alpha Data only)
  2. Nothing will show on screen

Expected behavior
The data should be parsed correctly.

Demonstration

Environment

  • Device/emulator being used: emulator
  • Android or SDK version (e.g. Android 5 or SDK 21): SDK 28
  • App version (you can get this through system app settings or via the admin controls menu in-app): 1 with data from the assets repository

Additional context
Error Log

/org.oppia.android E/StateFragment: Failed to retrieve ephemeral state
    org.json.JSONException: Value 0 at x of type java.lang.Integer cannot be converted to JSONObject
        at org.json.JSON.typeMismatch(JSON.java:101)
        at org.json.JSONObject.getJSONObject(JSONObject.java:616)
        at org.oppia.android.domain.util.StateRetriever.createExactInputForFractionInput(StateRetriever.kt:330)
        at org.oppia.android.domain.util.StateRetriever.createExactInputFromJson(StateRetriever.kt:301)
        at org.oppia.android.domain.util.StateRetriever.convertToRuleSpec(StateRetriever.kt:263)
        at org.oppia.android.domain.util.StateRetriever.createSingleAnswerGroupFromJson(StateRetriever.kt:126)
        at org.oppia.android.domain.util.StateRetriever.createAnswerGroupsFromJson(StateRetriever.kt:94)
        at org.oppia.android.domain.util.StateRetriever.createInteractionFromJson(StateRetriever.kt:67)
        at org.oppia.android.domain.util.StateRetriever.createStateFromJson(StateRetriever.kt:49)
        at org.oppia.android.domain.exploration.ExplorationRetriever.createStatesFromJsonObject(ExplorationRetriever.kt:58)
        at org.oppia.android.domain.exploration.ExplorationRetriever.loadExplorationFromAsset(ExplorationRetriever.kt:46)
        at org.oppia.android.domain.exploration.ExplorationRetriever.loadExploration(ExplorationRetriever.kt:33)
        at org.oppia.android.domain.exploration.ExplorationProgressController.retrieveCurrentStateWithinCacheAsync(ExplorationProgressController.kt:463)
        at org.oppia.android.domain.exploration.ExplorationProgressController.retrieveCurrentStateAsync(ExplorationProgressController.kt:446)
        at org.oppia.android.domain.exploration.ExplorationProgressController$getCurrentState$1.invokeSuspend(ExplorationProgressController.kt:438)
        at org.oppia.android.domain.exploration.ExplorationProgressController$getCurrentState$1.invoke(Unknown Source:10)
        at org.oppia.android.util.data.AsyncResult$transformAsync$2.invokeSuspend(AsyncResult.kt:90)
        at org.oppia.android.util.data.AsyncResult$transformAsync$2.invoke(Unknown Source:10)
        at org.oppia.android.util.data.AsyncResult.transformWithResultAsync(AsyncResult.kt:147)
        at org.oppia.android.util.data.AsyncResult.transformAsync(AsyncResult.kt:89)
        at org.oppia.android.util.data.DataProviders$Companion$transformAsync$1.retrieveData(DataProviders.kt:73)
        at org.oppia.android.util.data.DataProviders$NotifiableAsyncLiveData.retrieveFromDataProvider(DataProviders.kt:364)
        at org.oppia.android.util.data.DataProviders$NotifiableAsyncLiveData.handleDataProviderUpdate(DataProviders.kt:352)
        at org.oppia.android.util.data.DataProviders$NotifiableAsyncLiveData$onActive$job$1.invokeSuspend(DataProviders.kt:311)

Data

"rule_specs": [{
"rule_type": "HasIntegerPartEqualTo",
"inputs": {
  "x": 0
}
}, {
"rule_type": "HasIntegerPartEqualTo",
"inputs": {
  "x": 1
}
}, {
"rule_type": "HasIntegerPartEqualTo",
"inputs": {
  "x": 2
}
}],

To Fix

  1. Open file oppia-android/domain/src/main/assets/test_exp_id_2.json
  2. Go to line 407 -
  3. Add 1 more rule type
{
   "rule_type": "HasIntegerPartEqualTo",
        "inputs": {
            "x": 1
         }
 }

it will look like this after adding

"rule_specs": [{
              "rule_type": "IsExactlyEqualTo",
              "inputs": {
                "f": {
                  "isNegative": false,
                  "wholeNumber": 0,
                  "numerator": 1,
                  "denominator": 2
                }
              }
            },
              {
                "rule_type": "HasIntegerPartEqualTo",
                "inputs": {
                  "x": 1
                }
              }],
  1. Uninstall the already installed oppia app if there is any on your testing device
  2. Install app and open First Test Topic
  3. Nothing will be shown on screen and error will occur on logcat.
  4. Now, add the logic to parse new rule - Fraction type JSONObject Parsing Error #4202 (comment)
  5. re-install the app and open First Test Topic, it will work fine now.
@anandwana001
Copy link
Contributor Author

Adding a check in StateRetriver for this rule type will fix the issue

private fun createExactInputForFractionInput(
    inputJson: JSONObject,
    keyName: String,
    ruleType: String
  ): InteractionObject {
    return when (ruleType) {
      "HasNumeratorEqualTo" ->
        InteractionObject.newBuilder()
          .setSignedInt(inputJson.getInt(keyName))
          .build()
      "HasDenominatorEqualTo" ->
        InteractionObject.newBuilder()
          .setNonNegativeInt(inputJson.getInt(keyName))
          .build()
+      "HasIntegerPartEqualTo" ->
+        InteractionObject.newBuilder()
+         .setSignedInt(inputJson.getInt(keyName))
+          .build()
      else ->
        InteractionObject.newBuilder()
          .setFraction(parseFraction(inputJson.getJSONObject(keyName)))
          .build()
    }
  }

@BenHenning
Copy link
Member

This seems reasonable to add, though FWIW this won't affect alpha since we don't use the JSON loader for those lessons.

De-assigning and marking as a good first issue for someone to pick up.

@BenHenning BenHenning removed their assignment Feb 18, 2022
@BenHenning BenHenning added the good first issue This item is good for new contributors to make their pull request. label Feb 18, 2022
@adizcode
Copy link
Contributor

Interested!

@ayush0402
Copy link
Contributor

@adizcode Assigned.

@adizcode
Copy link
Contributor

adizcode commented Mar 2, 2022

@anandwana001 @ayush0402

I'm unable to find any Chapter 6 within the app. There's only 4 topics and none of them have the mentioned chapter. What am I missing?

@anandwana001
Copy link
Contributor Author

@adizcode Chapter 6 mentioned in the issue is a part of the alpha production app so the data can't be shared.
I had added the steps in PR description.

@visheshkadian
Copy link

@anandwana001 hey can you elaborate more on Steps to reproduce the behaviour issue because I couldn't find where this error is ??

@anandwana001
Copy link
Contributor Author

Did you follow the given steps?
Which step you are stuck on?

@visheshkadian
Copy link

@anandwana001 I found the file where we have to make the changes but I couldn't find any option to open chapter 6 to get the error
can you tell me the steps to get this error!!

@anandwana001
Copy link
Contributor Author

anandwana001 commented Mar 8, 2022

No, As I mentioned, chapter 6 is a part of alpha data that is not available publically, that's why we need to fix this issue using the currently available data only.

Check 5th Step, you have to use the First Test Topic exploration which you get when you open the application on the home screen.

@Broppia Broppia added issue_type_bug Impact: Low Low perceived user impact (e.g. edge cases). labels Jun 13, 2022
@adizcode adizcode removed their assignment Jul 12, 2022
@AjayMaheshwari23
Copy link

Please assign this issue to me .

@AbhaySota
Copy link

Could you please assign this to me ?

@JishnuGoyal
Copy link
Contributor

Please make sure to fill the CLA before you start contributing @AbhaySota

@AbhaySota
Copy link

I have filled the CLA form @JishnuGoyal .

@JishnuGoyal
Copy link
Contributor

Assigning you this issue @AbhaySota

@pratik9315
Copy link

Hey @JishnuGoyal @ayush0402 I saw the PR of this issue was marked stale, If its alright can I work on this issue?

@Gunashree-R-V
Copy link

Gunashree-R-V commented Feb 25, 2023

@BenHenning,
I see the above PR is marked stale.
I would like to work on this issue. Hence, could this issue be assigned to me?

@seanlip seanlip added bug End user-perceivable behaviors which are not desirable. and removed issue_user_developer labels Mar 29, 2023
@MohitGupta121 MohitGupta121 added the Work: Low Solution is clear and broken into good-first-issue-sized chunks. label Jun 8, 2023
@adhiamboperes adhiamboperes removed the good first issue This item is good for new contributors to make their pull request. label Jun 19, 2023
@TanishMoral11
Copy link
Contributor

TanishMoral11 commented Dec 14, 2024

Hey @adhiamboperes @anandwana001 @JishnuGoyal @ayush0402 ,
I wanted to check if this issue is still unresolved.
Can anyone confirm the status or provide an update on this ?

@adhiamboperes
Copy link
Collaborator

@TanishMoral11, this lesson exists in the Playstore vesrion. You can try to reproduce it using the repro steps mentioned in the main issue body.

@TanishMoral11
Copy link
Contributor

Hey @adhiamboperes , I Want To Work On This Issue .
Can You Assign This To Me .

Additionally, I have a quick question regarding Chapter 6 (Playstore Version). Since this issue is in Chapter 6, do I need to complete all five chapters on my own, or is there any way to focus directly on the specific chapter causing the issue?
The reason I ask is that the other chapters are currently locked.

Thanks !!

@adhiamboperes
Copy link
Collaborator

@TanishMoral11, for the playstore version, you actually need to play through the lessons, because the chapters being locked is a feature. The developer version of the app has means to bypass this however.

@TanishMoral11
Copy link
Contributor

Hey @adhiamboperes , Can I Work On It ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks. Z-ibt Temporary label for Ben to keep track of issues he's triaged.