Skip to content

Commit 4319c2b

Browse files
author
Erin Peach
committed
Merge branch 'staging' into remove-unused-project-delete [test ui]
2 parents 2ed52db + 631b19a commit 4319c2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3161
-222
lines changed

dashboard/app/helpers/pd/workshop_survey_results_helper.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def generate_workshop_daily_session_summary(workshop)
206206

207207
related_workshops = find_related_workshops(workshop)
208208

209-
summary[:all_my_workshops] = generate_workshops_survey_summary(related_workshops, questions) if related_workshops
209+
summary[:all_my_workshops] = generate_workshops_survey_summary(related_workshops, questions) if related_workshops.present?
210210

211211
summary[:facilitators] = Hash[*workshop.facilitators.pluck(:id, :name).flatten]
212212

@@ -392,7 +392,11 @@ def generate_facilitator_averages(summary)
392392
# responses, which the reduce_summary function does (see below)
393393
flattened_this_workshop_histograms = reduce_summary(summary[:this_workshop].values.flat_map(&:values).select {|x| x.is_a? Hash})
394394

395-
flattened_all_my_workshop_histograms = reduce_summary(summary[:all_my_workshops].values.flat_map(&:values).select {|x| x.is_a? Hash})
395+
flattened_all_my_workshop_histograms = if summary[:all_my_workshops]
396+
reduce_summary(summary[:all_my_workshops].values.flat_map(&:values).select {|x| x.is_a? Hash})
397+
else
398+
{}
399+
end
396400

397401
# Questions are also sorted by day and general vs. facilitator - that distinction needs
398402
# to be removed. Then we need to map each response option to the value that we assign it
@@ -453,8 +457,8 @@ def generate_facilitator_averages(summary)
453457

454458
facilitator_averages[facilitator][question_group[:primary_id]] = {this_workshop: (total_answer_for_this_workshop_sum / total_responses_for_this_workshop.to_f).round(2)}
455459

456-
total_responses_for_all_workshops = histogram_for_all_my_workshops.values.reduce(:+) || 0
457-
total_answer_for_all_workshops_sum = histogram_for_all_my_workshops.map do |k, v|
460+
total_responses_for_all_workshops = histogram_for_all_my_workshops&.values&.reduce(:+) || 0
461+
total_answer_for_all_workshops_sum = histogram_for_all_my_workshops&.map do |k, v|
458462
option = question[:option_map][k]
459463

460464
if option.nil?
@@ -468,9 +472,11 @@ def generate_facilitator_averages(summary)
468472

469473
0
470474
end
471-
end.reduce(:+) || 0
475+
end&.reduce(:+) || 0
472476

473-
facilitator_averages[facilitator][question_group[:primary_id]][:all_my_workshops] = (total_answer_for_all_workshops_sum / total_responses_for_all_workshops.to_f).round(2)
477+
facilitator_averages[facilitator][question_group[:primary_id]][:all_my_workshops] = if total_answer_for_all_workshops_sum != 0 && total_responses_for_all_workshops != 0
478+
(total_answer_for_all_workshops_sum / total_responses_for_all_workshops.to_f).round(2)
479+
end
474480
end
475481

476482
# Finally, keep hold of the question text to render in the averages table
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
function allSpritesWithCostume(costumeName) {
2-
var allSprites = World.allSprites;
3-
var sprites = [];
4-
for(var i = 0; i < allSprites.length; i++) {
5-
if(allSprites[i].getAnimationLabel() === costumeName) {
6-
sprites.push(allSprites[i]);
7-
}
2+
if(costumeGroups.hasOwnProperty(costumeName)) {
3+
return costumeGroups[costumeName];
84
}
9-
return sprites;
105
}

dashboard/config/blocks/aalab/aalab_changePropByFlexible.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function changePropByFlexible(sprite, property, val) {
22
if (sprite === undefined || val === undefined) {
33
return;
44
}
5-
if(sprite.length === undefined) {
5+
if(!Array.isArray(sprite)) {
66
changePropBy(sprite, property, val);
77
} else {
88
for(var i = 0; i < sprite.length; i++) {

dashboard/config/blocks/aalab/aalab_clickedOn.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
},
2525
{
2626
"name": "SPRITE",
27-
"type": "Sprite",
28-
"defer": true
27+
"type": "Sprite"
2928
}
3029
],
3130
"eventBlock": true
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function createNewSprite(name,costume,location) {
2+
if (!location) {
3+
location = {x: 200, y: 200};
4+
}
5+
var newSprite = makeNewSprite(costume,location.x,location.y);
6+
newSprite.maxSpeed = 0;
7+
newSprite.name = name;
8+
if(costumeGroups.hasOwnProperty(costume)) {
9+
costumeGroups[costume].push(newSprite);
10+
} else {
11+
var group = [];
12+
group.push(newSprite);
13+
costumeGroups[costume] = group;
14+
}
15+
return newSprite;
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"category": "Sprites",
3+
"config": {
4+
"func": "createNewSprite",
5+
"inline": false,
6+
"blockText": "aalab make a new sprite \n called {NAME} \n with costume {COSTUME} \n at {LOCATION}",
7+
"color": [
8+
355,
9+
".7",
10+
".7"
11+
],
12+
"args": [
13+
{
14+
"name": "NAME",
15+
"assignment": true,
16+
"customInput": "spritePicker"
17+
},
18+
{
19+
"name": "COSTUME",
20+
"customInput": "costumePicker"
21+
},
22+
{
23+
"name": "LOCATION",
24+
"type": "Location"
25+
}
26+
]
27+
}
28+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"category": "Events",
3+
"config": {
4+
"color": [
5+
140,
6+
1,
7+
0.74
8+
],
9+
"func": "keyPressed",
10+
"blockText": "{CONDITION} {KEY} pressed",
11+
"args": [
12+
{
13+
"name": "CONDITION",
14+
"options": [
15+
[
16+
"when",
17+
"\"when\""
18+
],
19+
[
20+
"while",
21+
"\"while\""
22+
]
23+
]
24+
},
25+
{
26+
"name": "KEY",
27+
"options": [
28+
[
29+
"up",
30+
"\"up\""
31+
],
32+
[
33+
"down",
34+
"\"down\""
35+
],
36+
[
37+
"left",
38+
"\"left\""
39+
],
40+
[
41+
"right",
42+
"\"right\""
43+
],
44+
[
45+
"space",
46+
"\"space\""
47+
]
48+
]
49+
}
50+
],
51+
"eventBlock": true
52+
}
53+
}

dashboard/config/blocks/aalab/aalab_removeAdvanced.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function removeOneAndAll(sprite) {
2+
if(sprite) {
3+
if(!Array.isArray(sprite)) {
4+
sprite.destroy();
5+
} else {
6+
while(sprite.length > 0) {
7+
sprite[0].remove();
8+
sprite.shift();
9+
}
10+
}
11+
}
12+
}

dashboard/config/blocks/aalab/aalab_removeAdvanced.json renamed to dashboard/config/blocks/aalab/aalab_removeOneAndAll.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
1,
77
0.74
88
],
9-
"func": "removeAdvanced",
10-
"blockText": "removeAdvanced {THIS}",
9+
"func": "removeOneAndAll",
10+
"blockText": "aalab remove {THIS}",
1111
"args": [
1212
{
1313
"name": "THIS",

0 commit comments

Comments
 (0)