think_feel_do_engine 3.12.3 → 3.12.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/javascripts/think_feel_do_engine/feel/draw_graphs.js +78 -0
- data/app/assets/javascripts/think_feel_do_engine/feel/emotion_mood_viz.js +2 -2
- data/app/assets/javascripts/think_feel_do_engine/feel/emotions.js +0 -7
- data/app/models/content_modules/lesson_module.rb +4 -3
- data/app/models/participant.rb +1 -1
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_vizs.html.erb +10 -44
- data/app/views/think_feel_do_engine/emotions/index.html.erb +1 -1
- data/lib/think_feel_do_engine/version.rb +1 -1
- metadata +3 -3
- data/app/assets/javascripts/think_feel_do_engine/feel/mood.js +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f279384413ae9527ed63dccf63ac46f933d377
|
4
|
+
data.tar.gz: aa19128c6c22d29d07d829ec1cf65e9eb67c8303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28b0dc6f1d139ee57be4f1eee004dba48269bfaa606f171dd8f89077f8077404d0696b3e81ea45f836e9626475f54f4d4374e29b6ed05090c193c4c9d8e2847c
|
7
|
+
data.tar.gz: 3a664d335ad7e15538aeaf5c9f1ef22db659d8d245eb1bb0400f7af99a34467196ae8c5c2b2df6c0103b5e32164231a5dd739d956aa46a24519bee28e051f75e
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
|
26
26
|
require "jshintrb/jshinttask"
|
27
27
|
Jshintrb::JshintTask.new :jshint do |t|
|
28
|
-
t.pattern = %w( spec/dummy/spec/javascripts/**/*.js app/assets/javascripts/think_feel_do_engine/**/
|
28
|
+
t.pattern = %w( spec/dummy/spec/javascripts/**/*.js app/assets/javascripts/think_feel_do_engine/**/draw_graphs.js )
|
29
29
|
t.options = :defaults
|
30
30
|
t.globals = ["$".to_sym, :spyOn, :afterEach, :beforeEach, :describe, :expect, :it, :jasmine, :sc, :Graph, :appendDateRange, :columnChart, :d3, :moment]
|
31
31
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
(function () {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
sc.appendDateRange = function (graphParameters) {
|
5
|
+
var FORMAT = 'MMM DD YYYY';
|
6
|
+
|
7
|
+
$('div#date-range strong')
|
8
|
+
.empty()
|
9
|
+
.append(graphParameters.startDate.format(FORMAT) + ' - ' + graphParameters.endDate.format(FORMAT));
|
10
|
+
};
|
11
|
+
|
12
|
+
sc.drawEmotionViz = function(graphParameters) {
|
13
|
+
var GRAPH_DIV_ID = '#emotions';
|
14
|
+
var GRAPH_TITLE = 'Positive and Negative Emotions*';
|
15
|
+
var LEGEND = [['Positive', '#4682B4'], ['Negative', '#A52A2A'], ['Daily Average', 'green']];
|
16
|
+
var LEGEND_DIV_ID = '#emotion-legend';
|
17
|
+
var PIXEL_HEIGHT = 400;
|
18
|
+
var Y_MAX = 10;
|
19
|
+
var Y_MIN = -10;
|
20
|
+
var YLABEL = 'Intensity';
|
21
|
+
|
22
|
+
$('div#emotions, div#emotion-legend').empty();
|
23
|
+
d3.select(GRAPH_DIV_ID)
|
24
|
+
.datum(graphParameters.emotionsData)
|
25
|
+
.call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
|
26
|
+
.width(graphParameters.graphWidth)
|
27
|
+
.height(PIXEL_HEIGHT)
|
28
|
+
.drawLegend(LEGEND_DIV_ID, LEGEND, ['*Click each day for more information.']));
|
29
|
+
};
|
30
|
+
|
31
|
+
sc.drawMoodViz = function(graphParameters) {
|
32
|
+
var GRAPH_DIV_ID = '#mood';
|
33
|
+
var GRAPH_TITLE = 'Mood*';
|
34
|
+
var LEGEND = [['Mood', '#4682B4'], ['Daily Average', 'green']];
|
35
|
+
var LEGEND_DIV_ID = '#mood-legend';
|
36
|
+
var PIXEL_HEIGHT = 300;
|
37
|
+
var Y_MAX = 10;
|
38
|
+
var Y_MIN = 0;
|
39
|
+
var YLABEL = 'mood';
|
40
|
+
|
41
|
+
$('div#mood, div#mood-legend').empty();
|
42
|
+
d3.select(GRAPH_DIV_ID)
|
43
|
+
.datum(graphParameters.moodData)
|
44
|
+
.call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
|
45
|
+
.width(graphParameters.graphWidth)
|
46
|
+
.height(PIXEL_HEIGHT)
|
47
|
+
.y(function(date, i) {
|
48
|
+
return date.intensity;
|
49
|
+
})
|
50
|
+
.drawLegend(LEGEND_DIV_ID, LEGEND, ['*Click each day for more information.']));
|
51
|
+
};
|
52
|
+
|
53
|
+
sc.drawPHQViz = function(graphParameters) {
|
54
|
+
var GRAPH_DIV_ID = '#phq';
|
55
|
+
var GRAPH_TITLE = "PHQ9";
|
56
|
+
var PIXEL_HEIGHT = 300;
|
57
|
+
var Y_MAX = 27;
|
58
|
+
var Y_MIN = 0;
|
59
|
+
var YLABEL = 'Score';
|
60
|
+
|
61
|
+
$(GRAPH_DIV_ID).empty();
|
62
|
+
d3.select(GRAPH_DIV_ID)
|
63
|
+
.datum(graphParameters.phqData)
|
64
|
+
.call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
|
65
|
+
.width(graphParameters.graphWidth)
|
66
|
+
.height(PIXEL_HEIGHT)
|
67
|
+
.y(function(date, i) {
|
68
|
+
return date.intensity;
|
69
|
+
}));
|
70
|
+
};
|
71
|
+
|
72
|
+
sc.drawGraphs = function(graphParameters) {
|
73
|
+
sc.drawPHQViz(graphParameters);
|
74
|
+
sc.drawMoodViz(graphParameters);
|
75
|
+
sc.drawEmotionViz(graphParameters);
|
76
|
+
sc.appendDateRange(graphParameters);
|
77
|
+
};
|
78
|
+
})();
|
@@ -11,7 +11,7 @@
|
|
11
11
|
graphParameters.interval = input.val();
|
12
12
|
graphParameters.offset = 1;
|
13
13
|
sc.offsetInterval(graphParameters);
|
14
|
-
sc.drawGraphs();
|
14
|
+
sc.drawGraphs(graphParameters);
|
15
15
|
});
|
16
16
|
|
17
17
|
$('.offset').on('click', function(event) {
|
@@ -24,7 +24,7 @@
|
|
24
24
|
} else {
|
25
25
|
graphParameters.offset += parseInt($(this).data('value'), 10);
|
26
26
|
sc.offsetInterval(graphParameters);
|
27
|
-
sc.drawGraphs();
|
27
|
+
sc.drawGraphs(graphParameters);
|
28
28
|
}
|
29
29
|
});
|
30
30
|
};
|
@@ -438,13 +438,6 @@ sc.offsetInterval = function (graphParameters) {
|
|
438
438
|
graphParameters.endDate = moment().subtract(endOffset, 'days').startOf('day');
|
439
439
|
}
|
440
440
|
|
441
|
-
function appendDateRange (graphParameters) {
|
442
|
-
var FORMAT = 'MMM DD YYYY'
|
443
|
-
$('div#date-range strong')
|
444
|
-
.empty()
|
445
|
-
.append(graphParameters.startDate.format(FORMAT) + ' - ' + graphParameters.endDate.format(FORMAT));
|
446
|
-
}
|
447
|
-
|
448
441
|
function maxOffset (activationDate, interval) {
|
449
442
|
return Math.ceil(moment().diff(activationDate, 'days')/interval)
|
450
443
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ContentModules
|
2
2
|
# Container for didactic content.
|
3
3
|
class LessonModule < BitCore::ContentModule
|
4
|
+
SLIDESHOW_PROVIDER_TYPE = "BitCore::ContentProviders::SlideshowProvider"
|
4
5
|
after_save :update_slideshow
|
5
6
|
|
6
7
|
def self.sort(arm_id, lesson_ids)
|
@@ -39,9 +40,9 @@ module ContentModules
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def lesson_provider
|
42
|
-
@lesson_provider ||=
|
43
|
-
|
44
|
-
|
43
|
+
@lesson_provider ||=
|
44
|
+
(content_providers.find_by_type(SLIDESHOW_PROVIDER_TYPE) ||
|
45
|
+
add_content_provider(SLIDESHOW_PROVIDER_TYPE))
|
45
46
|
end
|
46
47
|
|
47
48
|
def slides
|
data/app/models/participant.rb
CHANGED
@@ -280,7 +280,7 @@ class Participant < ActiveRecord::Base
|
|
280
280
|
def emotional_rating_daily_averages
|
281
281
|
averaged_ratings = []
|
282
282
|
|
283
|
-
daily_ratings = emotional_ratings.group_by
|
283
|
+
daily_ratings = emotional_ratings.group_by(&:created_at)
|
284
284
|
# rubocop:disable all
|
285
285
|
daily_ratings.each do |day, emotion_array|
|
286
286
|
# rubocop:enable all
|
@@ -25,49 +25,15 @@
|
|
25
25
|
<div id="mood"></div>
|
26
26
|
<div id="emotions"></div>
|
27
27
|
<script>
|
28
|
-
// starting graph parameters assume 7 day view ending in today
|
29
|
-
var activationDate = activation("<%= patient.created_at %>")
|
30
|
-
var graphParameters = new Graph(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
// starting graph parameters assume 7 day view ending in today
|
29
|
+
var activationDate = activation("<%= patient.created_at %>")
|
30
|
+
var graphParameters = new Graph(
|
31
|
+
<%= sanitize(patient.mood_rating_daily_averages.to_json) %>,
|
32
|
+
<%= sanitize(patient.emotional_rating_daily_averages.to_json) %>,
|
33
|
+
<%= phq_features? ? sanitize(patient.phq_scores.to_json) : "null" %>,
|
34
|
+
$("div#viz-container")
|
35
|
+
);
|
36
36
|
|
37
|
-
sc.drawGraphs
|
38
|
-
|
39
|
-
|
40
|
-
<% if phq_features? %>
|
41
|
-
$("div#phq").empty();
|
42
|
-
var phqGraphTitle = "PHQ9";
|
43
|
-
d3.select("#phq")
|
44
|
-
.datum(graphParameters.phqData)
|
45
|
-
.call(columnChart(graphParameters.startDate, graphParameters.endDate, 0, 27, phqGraphTitle, "Score")
|
46
|
-
.width(graphParameters.graphWidth)
|
47
|
-
.height(300)
|
48
|
-
.x(function(d, i) { return moment(d.day).startOf('day')._d; })
|
49
|
-
.y(function(d, i) { return d.intensity; }));
|
50
|
-
<% end %>
|
51
|
-
|
52
|
-
var moodGraphTitle = "Mood";
|
53
|
-
d3.select("#mood")
|
54
|
-
.datum(graphParameters.moodData)
|
55
|
-
.call(columnChart(graphParameters.startDate, graphParameters.endDate, 0, 10, moodGraphTitle, "mood")
|
56
|
-
.width(graphParameters.graphWidth)
|
57
|
-
.height(300)
|
58
|
-
.x(function(d, i) { return moment(d.day).startOf('day')._d; })
|
59
|
-
.y(function(d, i) { return d.intensity; }));
|
60
|
-
|
61
|
-
var emotionGraphTitle = "Positive and Negative Emotions";
|
62
|
-
d3.select("#emotions")
|
63
|
-
.datum(graphParameters.emotionsData)
|
64
|
-
.call(columnChart(graphParameters.startDate, graphParameters.endDate, -10, 10, emotionGraphTitle, "Intensity")
|
65
|
-
.width(graphParameters.graphWidth)
|
66
|
-
.height(400));
|
67
|
-
|
68
|
-
appendDateRange(graphParameters);
|
69
|
-
}
|
70
|
-
|
71
|
-
sc.drawGraphs();
|
72
|
-
sc.filterEmotionMoodViz(graphParameters);
|
37
|
+
sc.drawGraphs(graphParameters);
|
38
|
+
sc.filterEmotionMoodViz(graphParameters);
|
73
39
|
</script>
|
@@ -32,6 +32,6 @@
|
|
32
32
|
|
33
33
|
var graphParameters = new Graph(<%= sanitize(mood_ratings.to_json) %>, <%= sanitize(emotional_ratings.to_json) %>, null, $("#viz-container"));
|
34
34
|
|
35
|
-
sc.
|
35
|
+
sc.drawGraphs(graphParameters);
|
36
36
|
sc.filterEmotionMoodViz(graphParameters);
|
37
37
|
</script>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: think_feel_do_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.12.
|
4
|
+
version: 3.12.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Carty-Fickes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -347,9 +347,9 @@ files:
|
|
347
347
|
- app/assets/javascripts/think_feel_do_engine/dateWrapper.js
|
348
348
|
- app/assets/javascripts/think_feel_do_engine/devise/passwords/edit.js.erb
|
349
349
|
- app/assets/javascripts/think_feel_do_engine/event_capture/init.js
|
350
|
+
- app/assets/javascripts/think_feel_do_engine/feel/draw_graphs.js
|
350
351
|
- app/assets/javascripts/think_feel_do_engine/feel/emotion_mood_viz.js
|
351
352
|
- app/assets/javascripts/think_feel_do_engine/feel/emotions.js
|
352
|
-
- app/assets/javascripts/think_feel_do_engine/feel/mood.js
|
353
353
|
- app/assets/javascripts/think_feel_do_engine/feel/timeago.js
|
354
354
|
- app/assets/javascripts/think_feel_do_engine/forms/multi_page.js.erb
|
355
355
|
- app/assets/javascripts/think_feel_do_engine/forms/multi_page_thought.js.erb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
(function () {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
sc.calcStartOfDay = function(date) {
|
5
|
-
return moment(date.day, 'YYYY-MM-DDTHH:mm:ss.sssZ').startOf('day')._d;
|
6
|
-
};
|
7
|
-
|
8
|
-
sc.drawMoodEmotionGraphs = function(graphParameters) {
|
9
|
-
var NOTES = '*Click each day for more information.';
|
10
|
-
|
11
|
-
function clearContainers() {
|
12
|
-
$('div#mood, div#mood-legend, div#emotions, div#emotion-legend')
|
13
|
-
.empty();
|
14
|
-
}
|
15
|
-
|
16
|
-
function drawMoodViz(graphParameters) {
|
17
|
-
var GRAPH_DIV_ID = '#mood';
|
18
|
-
var GRAPH_TITLE = 'Mood*';
|
19
|
-
var LEGEND = [['Mood', '#4682B4'], ['Daily Average', 'green']];
|
20
|
-
var LEGEND_DIV_ID = '#mood-legend';
|
21
|
-
var PIXEL_HEIGHT = 300;
|
22
|
-
var Y_MAX = 10;
|
23
|
-
var Y_MIN = 0;
|
24
|
-
var YLABEL = 'mood';
|
25
|
-
|
26
|
-
d3.select(GRAPH_DIV_ID)
|
27
|
-
.datum(graphParameters.moodData)
|
28
|
-
.call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
|
29
|
-
.width(graphParameters.graphWidth)
|
30
|
-
.height(PIXEL_HEIGHT)
|
31
|
-
.x(function(date, i) {
|
32
|
-
return sc.calcStartOfDay(date);
|
33
|
-
})
|
34
|
-
.y(function(d, i) {
|
35
|
-
return d.intensity;
|
36
|
-
})
|
37
|
-
.drawLegend(LEGEND_DIV_ID, LEGEND, [NOTES]));
|
38
|
-
}
|
39
|
-
|
40
|
-
function drawEmotionViz(graphParameters) {
|
41
|
-
var GRAPH_DIV_ID = '#emotions';
|
42
|
-
var GRAPH_TITLE = 'Positive and Negative Emotions*';
|
43
|
-
var LEGEND = [['Positive', '#4682B4'], ['Negative', '#A52A2A'], ['Daily Average', 'green']];
|
44
|
-
var LEGEND_DIV_ID = '#emotion-legend';
|
45
|
-
var PIXEL_HEIGHT = 400;
|
46
|
-
var Y_MAX = 10;
|
47
|
-
var Y_MIN = -10;
|
48
|
-
var YLABEL = 'Intensity';
|
49
|
-
|
50
|
-
d3.select(GRAPH_DIV_ID)
|
51
|
-
.datum(graphParameters.emotionsData)
|
52
|
-
.call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
|
53
|
-
.width(graphParameters.graphWidth)
|
54
|
-
.height(PIXEL_HEIGHT)
|
55
|
-
.drawLegend(LEGEND_DIV_ID, LEGEND, [NOTES]));
|
56
|
-
}
|
57
|
-
|
58
|
-
clearContainers();
|
59
|
-
drawMoodViz(graphParameters);
|
60
|
-
drawEmotionViz(graphParameters);
|
61
|
-
return appendDateRange(graphParameters);
|
62
|
-
};
|
63
|
-
})();
|