Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
afa7fdd
First commit
ssvaditya Feb 7, 2023
fd5b48c
Intial commit for filetered translation
ssvaditya Jul 3, 2023
41ba616
Fixed the filtered_translation.csv loading issue
ssvaditya Sep 29, 2023
353a174
Delete .githooks directory
JackMostow Sep 29, 2023
b25477b
Pre-merge commit
ssvaditya Sep 29, 2023
ad7f745
Merged from development
ssvaditya Sep 29, 2023
a9c030d
Merge branch '2022-10-25_Aditya_SSV_translate_unfiltered_id' of https…
ssvaditya Sep 29, 2023
93498a8
Merge pull request #151 from RoboTutorLLC/2022-10-25_Aditya_SSV_trans…
g-revanth Oct 5, 2023
b8175dc
Cleaned up code in CTutorEngine.java
ssvaditya Oct 24, 2023
c60b3f6
Minor adjustments in loading the Translation Table
ssvaditya Nov 14, 2023
c7ee0b3
Created function to use translation table and minor fixes
ssvaditya Nov 14, 2023
71b8f87
Translate tutotId
ssvaditya Nov 14, 2023
26e8b87
Translate null id
ssvaditya Nov 14, 2023
9ab6b83
Added example to translation table
ssvaditya Nov 14, 2023
c10fd45
Merge branch '2023-07-13-implement-MAB' of https://github.com/RoboTut…
ssvaditya Nov 14, 2023
5623fb3
Update MABHandler.java
g-revanth Nov 30, 2023
b1a7778
Update MABHandler.java
g-revanth Nov 30, 2023
bfc60ea
Update CTutorEngine.java
g-revanth Nov 30, 2023
20baadf
Update MABHandler.java
g-revanth Dec 1, 2023
0404147
Update MABHandler.java
g-revanth Dec 14, 2023
26704f1
Update MABHandler.java
g-revanth Dec 14, 2023
8e15efb
Update MABHandler.java
g-revanth Dec 15, 2023
ae6f03d
Update MABHandler.java
g-revanth Dec 15, 2023
e361a7b
Update ArmWeight.java
g-revanth Dec 15, 2023
f0e3dff
Update MABHandler.java
g-revanth Dec 15, 2023
029afca
Rename ArmWeight.java to Arm.java
g-revanth Dec 15, 2023
52c263f
Merge pull request #152 from RoboTutorLLC/2023-07-13-implement-MAB
j50ju Sep 26, 2024
9a7643f
Update build.gradle
j50ju Oct 1, 2024
e1a941a
Update build.gradle
j50ju Oct 1, 2024
f99ee74
Update build.gradle for ScreenRecordHelper
j50ju Oct 21, 2024
e73395d
Update build.gradle for flexbox
j50ju Oct 21, 2024
9e2a5d3
Update MABHandler.java
j50ju Oct 21, 2024
4da1f00
Update RoboTutor.java
j50ju Oct 21, 2024
05fa2a0
Update MABHandler.java
j50ju Oct 28, 2024
986a90e
Update RoboTutor.java
j50ju Oct 28, 2024
4db6c1a
Update MABHandler.java
j50ju Feb 24, 2025
e1a5a31
Update build-workflow.yml deprecation v3 to v4
j50ju Feb 24, 2025
1fadfd8
Update RoboTutor.java
j50ju Feb 24, 2025
2a72acc
Update TBanner.java
j50ju Feb 24, 2025
8fc83f2
Update build-workflow.yml
j50ju Feb 24, 2025
8087698
Update RoboTutor.java
j50ju Feb 24, 2025
9d5cb9a
Update ConfigurationItems.java
j50ju Feb 24, 2025
3d0ecb3
MAB_runtime_updates
j50ju Mar 23, 2025
91db318
MAB_runtime_updates
j50ju Mar 23, 2025
a29ebfb
Merge remote-tracking branch 'origin/2024-09-20-implement-runtime-MAB…
j50ju Mar 23, 2025
67fbdd9
Merge remote-tracking branch 'origin/development' into 2024-09-20-imp…
j50ju Mar 23, 2025
e6d2f23
Update build.gradle
j50ju Mar 24, 2025
59f0d11
Update build.gradle to insert missing =
JackMostow Jul 7, 2025
3c5b48e
Update to include development branch changes (#158)
JackMostow Jul 7, 2025
c344469
Merge pull request #160 from RoboTutorLLC/development
j50ju Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/src/main/assets/arm-weights.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"arms": [
{
"name": "original",
"weight": 0.22628347156945203,
"matrix": "original_devdata.json"
},
{
"name": "filtered",
"weight": 0.2710968140239559,

"matrix": "filtered_devdata.json"
},
{
"name": "reordered",
"weight": 0.2602214321074131,
"matrix": "reordered_devdata.json"
},
{
"name": "reordered_filtered",
"weight": 0.24239828229917879,
"matrix": "reordered_filtered_devdata.json"
}
]
}
32,265 changes: 32,265 additions & 0 deletions app/src/main/assets/filtered_devdata.json

Large diffs are not rendered by default.

33,195 changes: 33,195 additions & 0 deletions app/src/main/assets/original_devdata.json

Large diffs are not rendered by default.

33,195 changes: 33,195 additions & 0 deletions app/src/main/assets/reordered_devdata.json

Large diffs are not rendered by default.

32,250 changes: 32,250 additions & 0 deletions app/src/main/assets/reordered_filtered_devdata.json

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions app/src/main/assets/tutors/activity_selector/arm-weights.json

This file was deleted.

12 changes: 12 additions & 0 deletions app/src/main/assets/tutors/armweights.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"arm_name": "test1",
"arm_weight": 0.5,
"filepath": "app/src/main/assets/tutors/armweights.json"
},
{
"arm_name": "test2",
"arm_weight": 0.9,
"filepath": "app/src/main/assets/tutors/armweights.json"
}
]
61 changes: 50 additions & 11 deletions app/src/main/java/cmu/xprize/robotutor/RoboTutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
import java.util.List;


import cmu.xprize.comp_intervention.data.CInterventionStudentData;
import cmu.xprize.comp_intervention.CInterventionTimes;
Expand Down Expand Up @@ -87,6 +89,7 @@
import cmu.xprize.robotutor.tutorengine.util.CAssetObject;
import cmu.xprize.robotutor.tutorengine.util.CrashHandler;
import cmu.xprize.robotutor.tutorengine.widgets.core.IGuidView;
import cmu.xprize.robotutor.tutorengine.util.MABHandler;
import cmu.xprize.util.CDisplayMetrics;
import cmu.xprize.util.CLoaderView;
import cmu.xprize.util.IReadyListener;
Expand All @@ -95,7 +98,7 @@
import cmu.xprize.util.TCONST;
import cmu.xprize.util.TTSsynthesizer;
import edu.cmu.xprize.listener.ListenerBase;

import cmu.xprize.robotutor.tutorengine.util.Arm;
import static cmu.xprize.comp_logging.PerformanceLogItem.MATRIX_TYPE.LITERACY_MATRIX;
import static cmu.xprize.comp_logging.PerformanceLogItem.MATRIX_TYPE.MATH_MATRIX;
import static cmu.xprize.comp_logging.PerformanceLogItem.MATRIX_TYPE.SONGS_MATRIX;
Expand Down Expand Up @@ -136,7 +139,7 @@ public class RoboTutor extends Activity implements IReadyListener, IRoboTutor, H
private static final boolean QUICK_DEBUG_CONFIG = false;
private static final ConfigurationItems QUICK_DEBUG_CONFIG_OPTION = ConfigurationQuickOptions.DEBUG_EN;

public static final String MATRIX_FILE = "dev_data.open.json";
public static final String MATRIX_FILE = "dev_data.open.json";
public static final String ARM_WEIGHTS_FILE = "arm-weights.json";

private static final String LOG_SEQUENCE_ID = "LOG_SEQUENCE_ID";
Expand Down Expand Up @@ -207,6 +210,12 @@ public class RoboTutor extends Activity implements IReadyListener, IRoboTutor, H
ScreenRecordHelper screenRecordHelper;
private ScreenRecorder screenRecorder = null;


//Declare armName
private String armName = "default_arm";
private float armWeight = 0;
public static String sArmName = null;

@Override
protected void onCreate(Bundle savedInstanceState) {

Expand Down Expand Up @@ -351,28 +360,53 @@ private void initializeAndStartLogs() {
String initTime = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss", Locale.US).format(calendar.getTime());
SEQUENCE_ID_STRING = String.format(Locale.US, "%06d", getNextLogSequenceId());
// NOTE: Need to include the configuration name when that is fully merged
String logFilename = "RoboTutor_" + // TODO TODO TODO there should be a version name in here!!!
Configuration.configVersion(this) + "_" + BuildConfig.VERSION_NAME + "_" + SEQUENCE_ID_STRING +
"_" + initTime + "_" + Build.SERIAL;

String logFilename = "RoboTutor_" + Build.SERIAL + "_" + SEQUENCE_ID_STRING + "_" +
Configuration.configVersion(this) + "_" + BuildConfig.VERSION_NAME + "_" + armName + "_" + armWeight +
"_" + initTime;
Log.w("LOG_DEBUG", "Beginning new session with LOG_FILENAME = " + logFilename);

logManager = CLogManager.getInstance();
logManager.transferHotLogs(hotLogPath, readyLogPath);
logManager.transferHotLogs(hotLogPathPerf, readyLogPathPerf);

logManager.startLogging(hotLogPath, logFilename);
logManager.startLoggingWithDynamicFilename(hotLogPath, logFilename);
CErrorManager.setLogManager(logManager);

perfLogManager = CPerfLogManager.getInstance();
perfLogManager.startLogging(hotLogPathPerf, "PERF_" + logFilename);

CInterventionLogManager.getInstance().startLogging(interventionLogPath,
perfLogManager.startLoggingWithDynamicFilename(hotLogPathPerf, "PERF_" + logFilename);
CInterventionLogManager.getInstance().startLoggingWithDynamicFilename(interventionLogPath,
"INT_" + logFilename);

ConfigurationItems config = new ConfigurationItems();
// Use MAB
if (config.use_MAB) {
armName = MABHandler.getArm(ARM_WEIGHTS_FILE, null);
List<Arm> arms = MABHandler.getarms(ARM_WEIGHTS_FILE, null);
armWeight = MABHandler.getArmWeight(armName, arms);
String matrixName = MABHandler.getMatrixName(armName, arms);
// Log the arm details using Log.w for visibility
Log.w(TAG, "Selected Arm: " + armName + ", Arm Weight: " + armWeight + ", Matrix Name: " + matrixName);
} else {
armName = "default_arm"; // Set back to default
armWeight = 0;
}

// Rename the Log File in-place
String newLogFilename = "RoboTutor_" + Build.SERIAL + "_" + SEQUENCE_ID_STRING + "_" +
Configuration.configVersion(this) + "_" + BuildConfig.VERSION_NAME + "_" + armName + "_" + armWeight +
"_" + initTime;

logManager.updateLogFilename(newLogFilename);
perfLogManager.updateLogFilename("PERF_" + newLogFilename);
CInterventionLogManager.getInstance().updateLogFilename("INT_" + newLogFilename);




// TODO : implement time stamps
logManager.postDateTimeStamp(GRAPH_MSG, "RoboTutor:SessionStart");
logManager.postEvent_I(GRAPH_MSG, "EngineVersion:" + VERSION_RT);

}

/**
Expand Down Expand Up @@ -930,9 +964,14 @@ protected void onStart() {
// Start the async task to initialize the tutor
//
new tutorConfigTask().execute();
}

// Add ArmName on banner
sArmName = armName;
}

public static String getArmName() {
return sArmName;
}
/**
* requery DB Cursors here
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;

import cmu.xprize.comp_intervention.data.CUpdateInterventionStudentData;
import cmu.xprize.comp_logging.CLogManager;
Expand Down Expand Up @@ -115,6 +122,8 @@ public enum MenuType {STUDENT_CHOICE, CYCLE_CONTENT};

final static private String TAG = "CTutorEngine";

static public HashMap<String, String> translationTable = new HashMap<>();


/**
* TutorEngine is a Singleton
Expand Down Expand Up @@ -808,27 +817,43 @@ private static TransitionMatrixModel loadTransitionMatrixModel() {
//String dataFile = "dev_data.json";
String dataFile = RoboTutor.MATRIX_FILE;

// simpler way to refer to languge
// simpler way to refer to language
String lang = TCONST.langMap.get(CTutorEngine.language);

String dataPath = TCONST.TUTORROOT + "/" + tutorName + "/" + TCONST.TASSETS;
dataPath += "/" + TCONST.DATA_PATH + "/" + lang + "/";

String jsonData = JSON_Helper.cacheData(dataPath + dataFile);

//
// Load the datasource into a separate class...
TransitionMatrixModel matrix = new TransitionMatrixModel(dataPath + dataFile, mRootScope);
matrix.validateAll();
System.out.println("dataPath: " + dataPath);
System.out.println("Log pointer"); //to locate required data in log

loadTranslationTable(Activity.getApplicationContext());
System.out.println("translationTable : " + translationTable);

String oldActivity = "write.missingLtr:lc.begin.ka.2";
String nextActivity = getTranslatedActivityID(oldActivity);

System.out.println("Translated activity: " + nextActivity);
return matrix;
}



private static void getArm() {

Log.d("MAB", "Entering getArm() method.");

String tutorName = "activity_selector";
String dataPath = TCONST.TUTORROOT + "/" + tutorName;
String dataFile = RoboTutor.ARM_WEIGHTS_FILE;

MABHandler.getArm(dataPath + "/" + dataFile, mRootScope);

Log.d("MAB", "Exiting getArm() method.");
}


Expand All @@ -846,6 +871,69 @@ public void loadJSON(JSONObject jsonData, IScope2 scope) {
public void loadJSON(JSONObject jsonObj, IScope scope) {
// Log.d(TAG, "Loader iteration");
loadJSON(jsonObj, (IScope2) scope);

}

public static String getTranslatedActivityID(String oldActivityID){
return translationTable.get(oldActivityID);
}


static void loadTranslationTable(Context context) {

try {
//csv file containing data
InputStream is = context.getResources().openRawResource(R.raw.filtered_translation);

//create BufferedReader to read csv file
BufferedReader br = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String strLine;
StringTokenizer st;
int lineNumber = 0;

//Sample of csv file
//unfiltered_activity_name,unfiltered_row,unfiltered_column,filtered_activity_name,filtered_row,filtered_column
//write.ltr.uc.dic:vow.asc.A..Z.3,0,49,akira:vow.ltr.uc:A..Z.vow.5.asc.say.11,0,50

// Skip the first line
br.readLine();

// read comma-separated file line by line
while ((strLine = br.readLine()) != null) {
lineNumber++;

// break comma-separated line using ","
st = new StringTokenizer(strLine, ",");

// Make sure there are at least 4 tokens before accessing 0th and 3rd indices
if (st.countTokens() >= 4) {
// Skip the first three tokens
String currentActivity = st.nextToken(); // 1st token
st.nextToken(); // Skipping 2nd token
st.nextToken(); // Skipping 3rd token

String nextActivity = st.nextToken(); // 4th token
// Skip the next two tokens
st.nextToken(); // Skipping 5th token
st.nextToken(); // Skipping 6th token

translationTable.put(currentActivity, nextActivity);
} else {
System.err.println("Invalid format in line " + lineNumber + ": " + strLine);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

System.out.println("translationTable : " + translationTable);
}

}





Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import cmu.xprize.robotutor.tutorengine.graph.vars.IScope2;

public class ArmWeight {
public class Arm {

public String name;
public Float weight;
public String matrix;

public ArmWeight(JSONObject jsonObject, IScope2 scope) {
public Arm(JSONObject jsonObject, IScope2 scope) {
try {
loadJSON(jsonObject);
} catch (Exception e) {
Expand All @@ -27,7 +27,7 @@ public void loadJSON(JSONObject jsonObj) throws JSONException {

@Override
public String toString() {
return "ArmWeight{" +
return "Arm{" +
"name='" + name + '\'' +
", weight=" + weight +
", matrix='" + matrix + '\'' +
Expand Down
Loading