Skip to content

Commit

Permalink
Merge pull request #2882 from ChildMindInstitute/bugfixes_alekseyn_4_1
Browse files Browse the repository at this point in the history
Bugfixes alekseyn 4 1
  • Loading branch information
anq83 authored Nov 9, 2022
2 parents ab74ea7 + 4036cf9 commit 459f1fe
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 101 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.21.59] - 2022-10-31
- Bugfixes: 2842 (fix for iOS), 2834, 1064

## [0.21.52] - 2022-09-15
- Bugfixes: 2842, 2822, 2867

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MindLogger 0.21.57
# MindLogger 0.21.59

_Note: v0.1 is deprecated as of June 12, 2019._

Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ android {
applicationId "lab.childmindinstitute.data"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 610
versionName "0.21.57"
versionCode 614
versionName "0.21.59"
missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
}
Expand Down
8 changes: 8 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())


buildscript {
ext {
Expand All @@ -22,6 +24,12 @@ buildscript {
}

allprojects {
configurations.all {
resolutionStrategy {
// Remove this override in 0.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
mavenLocal()
maven {
Expand Down
49 changes: 41 additions & 8 deletions app/components/ActivityScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,49 @@ class ActivityScreens extends React.PureComponent {
const activity = this.props.activity;

for (let i = 0; i < activity.items.length; i++) {
if (activity.items[i].inputType == 'visual-stimulus-response' && !activeScreens.includes(i)) {
if (
activity.items[i].inputType == "visual-stimulus-response" &&
!activeScreens.includes(i)
) {
activeScreens.unshift(i);
}
}

return activeScreens;
}

defineFlankerPosition() {
const activity = this.props.activity;
const currentScreen = this.props.currentScreen;

const flankerIndexes = [];

for (let i = 0; i < activity.items.length; i++) {
if (activity.items[i].inputType == "visual-stimulus-response") {
flankerIndexes.push(i);
}
}

if (!flankerIndexes.length) {
return null;
}

return {
isFirst: currentScreen === flankerIndexes[0],
isLast: currentScreen === flankerIndexes.pop(),
};
}

componentDidUpdate(oldProps) {
if (oldProps.currentScreen !== this.props.currentScreen) {
// eslint-disable-next-line
const activeScreens = [oldProps.currentScreen, this.props.currentScreen];

this.setState({
activeScreens: this.preLoadFlanker(activeScreens),
direction: calcPosition(oldProps.currentScreen, this.props.currentScreen),
direction: calcPosition(
oldProps.currentScreen,
this.props.currentScreen
),
});
}
}
Expand All @@ -58,15 +85,20 @@ class ActivityScreens extends React.PureComponent {
} = this.props;
const { activeScreens, direction } = this.state;

const flankerPosition = this.defineFlankerPosition()

return (
<View onTouchStart={this.props.onAnyTouch} style={{ flex: 1, width: '100%', position: 'relative' }}>
{activeScreens.map(index => (
<View
onTouchStart={this.props.onAnyTouch}
style={{ flex: 1, width: "100%", position: "relative" }}
>
{activeScreens.map((index) => (
<SlideInView
key={`${activity.id}-screen-${index}`}
style={{
position: 'absolute',
height: '100%',
width: '100%',
position: "absolute",
height: "100%",
width: "100%",
}}
position={calcPosition(currentScreen, index)}
slideInFrom={direction}
Expand All @@ -82,6 +114,7 @@ class ActivityScreens extends React.PureComponent {
currentScreen={currentScreen}
isCurrent={index === currentScreen}
onContentError={onContentError}
flankerPosition={flankerPosition}
/>
</SlideInView>
))}
Expand Down
2 changes: 2 additions & 0 deletions app/components/screen/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Widget = ({
onContentError,
appletTokenBalance,
handleReplaceBehaviourResponse,
flankerPosition
}) => {
const valueType = R.path(['valueConstraints', 'valueType'], screen);

Expand Down Expand Up @@ -273,6 +274,7 @@ const Widget = ({
config={screen.inputs}
appletId={applet.id}
isCurrent={isCurrent}
flankerPosition={flankerPosition}
/>
);
}
Expand Down
22 changes: 20 additions & 2 deletions app/components/screen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,24 @@ class ActivityScreen extends Component {
}

render() {
const { activity, screen, answer, isCurrent, onContentError, currentScreen, lastResponseTime, profiles, answers } = this.props;
const { orientation, scrollEnabled, inputDelayed, timerActive } = this.state;
const {
activity,
screen,
answer,
isCurrent,
onContentError,
currentScreen,
lastResponseTime,
profiles,
answers,
flankerPosition,
} = this.props;
const {
orientation,
scrollEnabled,
inputDelayed,
timerActive,
} = this.state;

return (
<View
Expand Down Expand Up @@ -399,6 +415,7 @@ class ActivityScreen extends Component {
this.setState({ scrollEnabled: true });
}}
handleReplaceBehaviourResponse={this.handleReplaceBehaviourResponse.bind(this)}
flankerPosition={flankerPosition}
/>
</View>
</View>
Expand All @@ -417,6 +434,7 @@ class ActivityScreen extends Component {
}}
onContentError={onContentError}
handleReplaceBehaviourResponse={this.handleReplaceBehaviourResponse.bind(this)}
flankerPosition={flankerPosition}
/>
)}
</ScrollView>
Expand Down
2 changes: 2 additions & 0 deletions app/services/scoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ export const getScoreFromLookupTable = (
for (let i = 0; i < responses.length; i++) {
if (responses[i]) {
scores.push(getScoreFromResponse(items[i], responses[i].value));
} else {
scores.push(0);
}
}

Expand Down
41 changes: 33 additions & 8 deletions app/widgets/VisualStimulusResponse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const getTrials = (stimulusScreens, blocks, buttons, samplingMethod) => {
return trials;
}

export const VisualStimulusResponse = ({ onChange, config, isCurrent, appletId }) => {
export const VisualStimulusResponse = ({ onChange, config, isCurrent, appletId, flankerPosition }) => {
const [loading, setLoading] = useState(true);
const [scriptInjected, setScriptInjected] = useState(false);
const [responses, setResponses] = useState([]);
Expand All @@ -71,8 +71,9 @@ export const VisualStimulusResponse = ({ onChange, config, isCurrent, appletId }
const dataString = result.nativeEvent.data;
const dataObject = JSON.parse(dataString);
const dataType = result.nativeEvent.type;
if (dataObject.trial_index > configObj.trials.length) return ;
console.log(parseResponse(dataObject))

if (dataObject.trial_index > configObj.trials.length) return

if (dataType == 'response') {
setResponses(responses.concat([dataObject]));

Expand Down Expand Up @@ -139,12 +140,24 @@ export const VisualStimulusResponse = ({ onChange, config, isCurrent, appletId }
if(!isCurrent || Platform.OS !== 'ios') {
return;
}
NativeModules.FlankerViewManager.parameterGameType(config.blockType == "test" ? 1 : 0, JSON.stringify(configObj));
NativeModules.FlankerViewManager.parameterGame(true, configObj.trials.length, 0);

// todo - review how to avoid setTimeout. Currently it's needed because of
// race condition: FlankerView.swift may be created later than startGame
setTimeout(() => {
NativeModules.FlankerViewManager.setGameParameters(JSON.stringify(configObj))
NativeModules.FlankerViewManager.startGame(flankerPosition.isFirst, flankerPosition.isLast)
}, 600)
}, [isCurrent])

useEffect(() => {
if(!isCurrent || Platform.OS !== 'android') {
if(Platform.OS !== 'ios') {
return;
}
NativeModules.FlankerViewManager.preloadGameImages(JSON.stringify(configObj))
})

useEffect(() => {
if(!isCurrent || Platform.OS !== 'android') {
return;
}
if(!loading && !scriptInjected) {
Expand All @@ -166,6 +179,18 @@ export const VisualStimulusResponse = ({ onChange, config, isCurrent, appletId }
response_touch_timestamp: Platform.OS === 'ios' ? record.response_touch_timestamp : (record.rt ? record.start_timestamp + record.rt : null)
})

if (!isCurrent) {
return (
<View
style={{
height: '100%',
position: 'relative',
}}
>
<Text>DEBUG: Is not current</Text>
</View>)
}

if (Platform.OS === 'ios') {
return (
<View
Expand Down Expand Up @@ -194,8 +219,8 @@ export const VisualStimulusResponse = ({ onChange, config, isCurrent, appletId }
position: 'absolute',
alignItems: 'center',
justifyContent: 'center' }}
onEndGame={onEndGame}
dataJson ={JSON.stringify(configObj)}

onEndGame = { onEndGame }
/>
</View>
</View>
Expand Down
8 changes: 4 additions & 4 deletions ios/MDCApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -830,14 +830,14 @@
CODE_SIGN_ENTITLEMENTS = MDCApp/MDCApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 610;
CURRENT_PROJECT_VERSION = 614;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 8RHKE85KB6;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = MDCApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.21.57;
MARKETING_VERSION = 0.21.59;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -863,12 +863,12 @@
CODE_SIGN_ENTITLEMENTS = MDCApp/MDCApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 610;
CURRENT_PROJECT_VERSION = 614;
DEVELOPMENT_TEAM = 8RHKE85KB6;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = MDCApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.21.57;
MARKETING_VERSION = 0.21.59;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
6 changes: 6 additions & 0 deletions ios/MDCApp/Flanker/FlankerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ class FlankerView: UIView {
super.init(coder: coder)
}


override func removeFromSuperview() {
self.gameManager.clearData()
super.removeFromSuperview()
}

func parameterGame() {
DispatchQueue.main.async {
self.finishView.isHidden = true
Expand Down
5 changes: 3 additions & 2 deletions ios/MDCApp/Flanker/FlankerViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#import "React/RCTViewManager.h"

@interface RCT_EXTERN_MODULE(RCTFlankerViewManager, RCTViewManager)
RCT_EXTERN_METHOD(parameterGameType:(int *)blockType json:(NSString *)json)
RCT_EXTERN_METHOD(parameterGame:(BOOL *)isShowAnswers countGame:(int *)countGame index:(int*)index)
RCT_EXTERN_METHOD(setGameParameters:(NSString *)json)
RCT_EXTERN_METHOD(preloadGameImages:(NSString *)json)
RCT_EXTERN_METHOD(startGame:(BOOL *)isFirst isLast:(BOOL *)isLast)
RCT_EXPORT_VIEW_PROPERTY(onEndGame, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(dataJson, NSString)
RCT_EXPORT_VIEW_PROPERTY(onUpdate, RCTDirectEventBlock)
Expand Down
Loading

0 comments on commit 459f1fe

Please sign in to comment.