Skip to content

Commit

Permalink
initial stab at combining ember-lookit-frameplayer and exp-addons int…
Browse files Browse the repository at this point in the history
…o a single app that would be easier to install, maintain, and contribute to. so far able to participate in a study through a few frames, substantial bugs to work out.
  • Loading branch information
Kim Scott committed Feb 20, 2019
1 parent 6d5d7a9 commit 090040c
Show file tree
Hide file tree
Showing 306 changed files with 68,237 additions and 2,845 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ coverage
dist
docs
tmp
tests/*
20 changes: 14 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
// See https://eslint.org/docs/user-guide/configuring#specifying-parser-options

module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
sourceType: 'module',
ecmaFeatures: {
'impliedStrict': true
}
},
extends: 'eslint:recommended',
env: {
browser: true,
es6: true
'browser': true,
'es6': true
},
globals: {
MathJax: true
globals: { // true to allow overwriting
'moment': false,
'jsPDF': false
},
rules: {}
rules: { // 'warn', 'error', or 'off'
'no-console': 'off' // allow console.log
}
};
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
npm-debug.log
testem.log

# HDFVR flash video recorder
/public/VideoRecorder.swf

# Sensitive settings- never commit to github!
/.env
/**/config.json
Expand All @@ -27,3 +24,5 @@ testem.log
scripts/env

migration/output/*

themes/lookit/assets/screenshots/*
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "lib"]
path = lib
url = https://github.com/lookit/exp-addons.git
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.jshintrc
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/boron
10 changes: 10 additions & 0 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* jshint node:true */
'use strict';

module.exports = {
extends: 'recommended',
rules: {
'no-bare-strings': false,
'block-indentation': 4
}
};
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Before beginning, you will need to install Yarn, a package manager (like npm).

Make use of the many generators for code, try `ember help generate` for more details

### Updating docs
Documentation of components is generated using YUIDoc:
```
$ cd exp-player
$ yarn run docs
```

At the moment, this is a manual process: whatever
files are in the top level `/docs/` folder of the master branch will be served via GitHub pages.


### Running Tests

* `ember test`
Expand Down
6 changes: 6 additions & 0 deletions app/components/exp-blank/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Ember from 'ember';
import layout from './template';

export default Ember.Component.extend({
layout
});
1 change: 1 addition & 0 deletions app/components/exp-blank/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield}}
153 changes: 153 additions & 0 deletions app/components/exp-exit-survey/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import Ember from 'ember';
import layout from './template';

import {validator, buildValidations} from 'ember-cp-validations';

import moment from 'moment';

import ExpFrameBaseComponent from '../exp-frame-base/component';
import FullScreen from '../../mixins/full-screen';

/**
* @module exp-player
* @submodule frames
*/

/**
This is the exit survey used by "Your baby the physicist". Use the updated frame {{#crossLink "ExpLookitExitSurvey"}}{{/crossLink}} instead.
@class ExpExitSurvey
@extends ExpFrameBase
@uses Validations
@uses FullScreen
*/

const Validations = buildValidations({
birthDate: validator('presence', {
presence: true,
message: 'This field is required'
}),
useOfMedia: validator('presence', {
presence: true,
message: 'This field is required',
disabled(model) {
return model.get('withdrawal');
}
}),
databraryShare: validator('presence', {
presence: true,
message: 'This field is required'
})
});

export default ExpFrameBaseComponent.extend(Validations, FullScreen, {
layout: layout,
type: 'exp-exit-survey',
fullScreenElementId: 'experiment-player',
meta: {
name: 'ExpExitSurvey',
description: 'Exit survey for Lookit.',
parameters: {
type: 'object',
properties: {
}
},
data: {
type: 'object',
properties: {
birthDate: {
type: 'string',
default: null
},
databraryShare: {
type: 'string'
},
useOfMedia: {
type: 'string'
},
withdrawal: {
type: 'boolean',
default: false
},
feedback: {
type: 'string',
default: ''
},
idealSessionsCompleted: {
type: 'integer',
default: 3
},
idealDaysSessionsCompleted: {
type: 'integer',
default: 14
}
}
}
},
today: new Date(),
section1: true,
minVideosToCountSession: 6,
showWithdrawalConfirmation: false,
showValidation: false,
actions: {
advanceToProgressBar() {
// Move from section 1 (survey) to section 2 (progress bar/ finish button)
// Mark the session complete at this stage, as all data has been entered
this.sendAction('sessionCompleted');
this._save()
.then(()=> {
this.set('section1', false);
})
.catch(err => this.displayError(err));
},
continue() {
// Check whether exit survey is valid, and if so, advance to next screen
if (this.get('validations.isValid')) {
if (this.get('withdrawal')) {
this.set('showWithdrawalConfirmation', true);
} else {
this.send('advanceToProgressBar');
}
} else {
this.set('showValidation', true);
}
},
finish() {
this.send('next');
}
},

currentSessionStatus: Ember.computed('frameContext.pastSessions', function() {
let nSessions = 0;
const sessionDates = [];
this.get('frameContext.pastSessions').forEach(session => {
let nVideos = 0;
Object.keys(session.get('expData')).forEach(frameKeyName => {
if (frameKeyName.includes('pref-phys-videos')) {
nVideos++;
}
});
// Count only sessions with at least minVideos pref-phys-videos frames
if (nVideos >= this.get('minVideosToCountSession')) {
nSessions++;
sessionDates.pushObject(moment(session.get('createdOn')));
}
});
return {'nSessions': nSessions, 'daysSessionsCompleted': moment.max(sessionDates).diff(moment.min(sessionDates), 'days') + 1 };
}),

currentSessionsCompleted: Ember.computed('currentSessionStatus', function() {
return this.get('currentSessionStatus.nSessions');
}),

currentDaysSessionsCompleted: Ember.computed('currentSessionStatus', function() {
return this.get('currentSessionStatus.daysSessionsCompleted');
}),

progressValue: Ember.computed('currentSessionsCompleted', 'idealSessionsCompleted', function() {
return Math.min(100, Math.ceil((this.get('currentSessionsCompleted') / this.get('idealSessionsCompleted')) * 100));
}),
willRender() {
this.send('exitFullscreen');
}
});
Loading

0 comments on commit 090040c

Please sign in to comment.