Skip to content

Commit

Permalink
Merge pull request #20843 from code-dot-org/dtl_candidate_5edb30f1
Browse files Browse the repository at this point in the history
  • Loading branch information
deploy-code-org committed Feb 22, 2018
2 parents 42162d6 + 5edb30f commit 813891c
Show file tree
Hide file tree
Showing 114 changed files with 908 additions and 823 deletions.
8 changes: 7 additions & 1 deletion apps/i18n/common/en_us.json
@@ -1,6 +1,7 @@
{
"activity": "Activity",
"actions": "Actions",
"add": "Add",
"addRemoveCleverClassrooms": "Visit https://clever.com/ and confirm your classroom is connected to Code.org.",
"addRemoveGoogleClassrooms": "Visit https://classroom.google.com/ to add and remove classrooms.",
"addSectionName": "Enter a name for your section that will help you remember which classroom it is for. Your students will also be able to see this name.",
Expand Down Expand Up @@ -52,6 +53,7 @@
"assignUnit": "Assign Unit",
"authorizeGoogleClassrooms": "Click here to authorize Google Classroom.",
"authorizeGoogleClassroomsText": "Before you can sync Google Classroom, you must give Code.org permission to access your Google Classroom account.",
"autoGenerated": "Auto-generated",
"autolock": "Note: Stage auto-locks after 24 hours.",
"backToActivity": "Back to activity",
"backToPreviousLevel": "Back to previous level",
Expand Down Expand Up @@ -796,11 +798,15 @@
"removeFromClassGallery": "Remove from Class Gallery",
"removeFromPublicGallery": "Remove from Public Gallery",
"removeStudent": "Remove student",
"removeStudentConfirm": "Are you sure you want to remove this student?",
"removeStudentConfirm1": "If your student currently logs in through a secret picture or secret pair of words, the student may no longer be able to log into their account if you remove them from your section. If this is the case, please give your student a chance to keep using their Code.org account by letting them create a personal login.",
"removeStudentConfirm2": "Send home these instructions on how to create a personal login.",
"removeStudentConfirm3": "Give them at least a few days to follow these instructions before you remove them.",
"removeStudentHeader": "Are you sure you want to remove this student?",
"rename": "Rename",
"repeat": "repeat",
"replayButton": "Replay",
"reportAbuse": "Report Abuse",
"required": "required",
"reset": "Reset",
"resetProgram": "Reset",
"resetPassword": "Reset password",
Expand Down
10 changes: 7 additions & 3 deletions apps/src/code-studio/initApp/project.js
Expand Up @@ -20,7 +20,7 @@ var channels = require('./clientApi').create('/v3/channels');

var showProjectAdmin = require('../showProjectAdmin');
var header = require('../header');
import {queryParams, hasQueryParam} from '../utils';
import {queryParams, hasQueryParam, updateQueryParam} from '../utils';

// Name of the packed source file
var SOURCE_FILE = 'main.json';
Expand Down Expand Up @@ -867,6 +867,7 @@ var projects = module.exports = {
'analysis-events',
{
study: 'project-data-integrity',
study_group: 'v2',
event: errorType,
data_int: errorCount,
project_id: current.id + '',
Expand All @@ -882,7 +883,8 @@ var projects = module.exports = {
shareUrl: this.getShareUrl(),
currentSourceVersionId: currentSourceVersionId,
}),
}
},
{includeUserId: true}
);
},
updateCurrentData_(err, data, options = {}) {
Expand Down Expand Up @@ -1294,15 +1296,17 @@ function fetchAbuseScoreAndPrivacyViolations(callback) {
}

/**
* Temporarily allow for setting Maker APIs enabled / disabled via URL parameters.
* Allow setting Maker APIs enabled / disabled via URL parameters.
*/
function setMakerAPIsStatusFromQueryParams() {
if (hasQueryParam('enableMaker')) {
currentSources.makerAPIsEnabled = true;
updateQueryParam('enableMaker', undefined, true);
}

if (hasQueryParam('disableMaker')) {
currentSources.makerAPIsEnabled = false;
updateQueryParam('disableMaker', undefined, true);
}
}

Expand Down
13 changes: 9 additions & 4 deletions apps/src/gamelab/ErrorDialogStack.jsx
Expand Up @@ -10,6 +10,7 @@ import Button from '@cdo/apps/templates/Button';
import DialogFooter from '@cdo/apps/templates/teacherDashboard/DialogFooter';
import * as animationActions from './animationListModule';
import firehoseClient from '@cdo/apps/lib/util/firehose';
import {getCurrentId} from '../code-studio/initApp/project';

/**
* Renders error dialogs in sequence, given a stack of errors.
Expand All @@ -29,11 +30,13 @@ class ErrorDialogStack extends React.Component {
'analysis-events',
{
study: 'animation_no_load',
study_group: 'animation_no_load_v2',
study_group: 'animation_no_load_v3',
event: 'delete_selected',
project_id: getCurrentId(),
data_json: JSON.stringify({'version': this.props.animationList.propsByKey[key].version,
'animationName': this.props.animationList.propsByKey[key].name})
}
},
{includeUserId: true}
);
this.props.deleteAnimation(key);
this.props.dismissError();
Expand All @@ -45,11 +48,13 @@ class ErrorDialogStack extends React.Component {
'analysis-events',
{
study: 'animation_no_load',
study_group: 'animation_no_load_v2',
study_group: 'animation_no_load_v3',
event: 'reload_selected',
project_id: getCurrentId(),
data_json: JSON.stringify({'version': this.props.animationList.propsByKey[key].version,
'animationName': this.props.animationList.propsByKey[key].name})
}
},
{includeUserId: true}
);
location.reload();
}
Expand Down
1 change: 1 addition & 0 deletions apps/src/gamelab/GameLabJr.interpreted.js
Expand Up @@ -216,6 +216,7 @@ function makeNewGroup() {
addBehavior(group[i], behavior, name);
}
};
group.destroy = group.destroyEach;
return group;
}

Expand Down
18 changes: 10 additions & 8 deletions apps/src/gamelab/animationListModule.js
Expand Up @@ -14,7 +14,7 @@ import * as assetPrefix from '../assetManagement/assetPrefix';
import {selectAnimation} from './AnimationTab/animationTabModule';
import {reportError} from './errorDialogStackModule';
import {throwIfSerializedAnimationListIsInvalid} from './shapes';
import {projectChanged, isOwner} from '../code-studio/initApp/project';
import {projectChanged, isOwner, getCurrentId} from '../code-studio/initApp/project';
import firehoseClient from '@cdo/apps/lib/util/firehose';

// TODO: Overwrite version ID within session
Expand Down Expand Up @@ -568,13 +568,15 @@ function loadAnimationFromSource(key, callback) {
// Log data about when this scenario occurs
firehoseClient.putRecord(
'analysis-events',
{
study: 'animation_no_load',
study_group: 'animation_no_load_v2',
event: isOwner() ? 'animation_not_loaded_owner' : 'animation_not_loaded_viewer',
data_json: JSON.stringify({'sourceUrl': sourceUrl, 'version': state.propsByKey[key].version,
'animationName': state.propsByKey[key].name, 'error': err.message})
}
{
study: 'animation_no_load',
study_group: 'animation_no_load_v3',
event: isOwner() ? 'animation_not_loaded_owner' : 'animation_not_loaded_viewer',
project_id: getCurrentId(),
data_json: JSON.stringify({'sourceUrl': sourceUrl, 'version': state.propsByKey[key].version,
'animationName': state.propsByKey[key].name, 'error': err.message})
},
{includeUserId: true}
);

if (isOwner()) {
Expand Down
123 changes: 115 additions & 8 deletions apps/src/gamelab/blocks.js
Expand Up @@ -6,6 +6,8 @@ import {
const SPRITE_CATEGORY = 'sprites';
const EVENT_CATEGORY = 'events';
const EVENT_LOOP_CATEGORY = 'event_loop';
const VARIABLES_CATEGORY = 'variables';
const WORLD_CATEGORY = 'world';
const CATEGORIES = {
[SPRITE_CATEGORY]: {
color: [184, 1.00, 0.74],
Expand All @@ -16,6 +18,12 @@ const CATEGORIES = {
[EVENT_LOOP_CATEGORY]: {
color: [322, 0.90, 0.95],
},
[VARIABLES_CATEGORY]: {
color: [312, 0.32, 0.62],
},
[WORLD_CATEGORY]: {
color: [240, 0.45, 0.65],
},
};

const SPRITES = [
Expand All @@ -29,21 +37,29 @@ export default {
ORDER_COMMA,
ORDER_FUNCTION_CALL,
ORDER_MEMBER,
ORDER_NONE,
} = Blockly.JavaScript;
const SPRITE_TYPE = blockly.BlockValueType.NUMBER;

// TODO(ram): Create Blockly.BlockValueType.SPRITE
const SPRITE_TYPE = blockly.BlockValueType.NONE;
const generator = blockly.Generator.get('JavaScript');

const createJsWrapperBlock = ({
category,
func,
expression,
orderPrecedence,
name,
blockText,
args,
returnType,
methodCall,
eventBlock,
eventLoopBlock,
}) => {
const blockName = `gamelab_${func}`;
args = args || [];
const blockName = `gamelab_${name || func}`;

blockly.Blocks[blockName] = {
helpUrl: '',
init: function () {
Expand All @@ -59,8 +75,7 @@ export default {

this.setInputsInline(true);
if (returnType) {
// TODO(ram): Create Blockly.BlockValueType.SPRITE
this.setOutput(true, Blockly.BlockValueType.NUMBER);
this.setOutput(true, returnType);
} else {
if (eventLoopBlock) {
this.appendStatementInput('DO');
Expand Down Expand Up @@ -105,6 +120,14 @@ export default {
values.push(`function () {\n${handlerCode}}`);
}

if (expression) {
if (returnType !== undefined) {
return [`${prefix}${expression}`, orderPrecedence || ORDER_NONE];
} else {
return `${prefix}${expression}`;
}
}

if (returnType !== undefined) {
return [`${prefix}${func}(${values.join(', ')})`, ORDER_FUNCTION_CALL];
} else {
Expand All @@ -116,15 +139,33 @@ export default {
createJsWrapperBlock({
category: SPRITE_CATEGORY,
func: 'makeNewSprite',
blockText: 'Make a new {ANIMATION} sprite at {X} {Y}',
blockText: 'make a new {ANIMATION} sprite at {X} {Y}',
args: [
{ name: 'ANIMATION', options: SPRITES},
{ name: 'X', type: blockly.BlockValueType.NUMBER},
{ name: 'Y', type: blockly.BlockValueType.NUMBER},
{ name: 'ANIMATION', options: SPRITES },
{ name: 'X', type: blockly.BlockValueType.NUMBER },
{ name: 'Y', type: blockly.BlockValueType.NUMBER },
],
returnType: SPRITE_TYPE,
});

createJsWrapperBlock({
category: SPRITE_CATEGORY,
func: 'makeNewGroup',
blockText: 'make a new group',
args: [],
returnType: SPRITE_TYPE,
});

createJsWrapperBlock({
category: SPRITE_CATEGORY,
func: 'add',
blockText: 'add {SPRITE} to group {THIS}',
args: [
{ name: 'SPRITE', type: SPRITE_TYPE },
],
methodCall: true,
});

createJsWrapperBlock({
category: SPRITE_CATEGORY,
func: 'moveUp',
Expand Down Expand Up @@ -220,5 +261,71 @@ export default {
args: [],
eventLoopBlock: true,
});

createJsWrapperBlock({
category: EVENT_CATEGORY,
func: 'whenTouching',
blockText: 'when {SPRITE1} is touching {SPRITE2}',
args: [
{ name: 'SPRITE1', type: SPRITE_TYPE },
{ name: 'SPRITE2', type: SPRITE_TYPE },
],
eventBlock: true,
});

createJsWrapperBlock({
category: SPRITE_CATEGORY,
func: 'displace',
blockText: '{THIS} blocks {SPRITE} from moving',
args: [
{name: 'SPRITE', type: SPRITE_TYPE },
],
methodCall: true,
});

createJsWrapperBlock({
category: SPRITE_CATEGORY,
func: 'destroy',
blockText: 'remove {THIS}',
args: [],
methodCall: true,
});

createJsWrapperBlock({
category: VARIABLES_CATEGORY,
expression: 'arguments[0]',
orderPrecedence: ORDER_MEMBER,
name: 'firstTouched',
blockText: 'first touched sprite',
returnType: SPRITE_TYPE,
});

createJsWrapperBlock({
category: VARIABLES_CATEGORY,
expression: 'arguments[1]',
orderPrecedence: ORDER_MEMBER,
name: 'secondTouched',
blockText: 'second touched sprite',
returnType: SPRITE_TYPE,
});

createJsWrapperBlock({
category: SPRITE_CATEGORY,
expression: 'length',
orderPrecedence: ORDER_MEMBER,
name: 'groupLength',
blockText: 'number of sprites in {THIS}',
methodCall: true,
returnType: blockly.BlockValueType.NUMBER,
});

createJsWrapperBlock({
category: WORLD_CATEGORY,
func: 'setBackground',
blockText: 'set background color {COLOR}',
args: [
{ name: 'COLOR', type: blockly.BlockValueType.COLOUR },
],
});
},
};
2 changes: 1 addition & 1 deletion apps/src/lib/kits/maker/CircuitPlaygroundBoard.js
Expand Up @@ -161,7 +161,7 @@ export default class CircuitPlaygroundBoard extends EventEmitter {
// on the next run.
// Note: This doesn't seem to be necessary when using browser-serialport
// and the Chrome App connector, but it is required for native
// node serialport in the Maker Toolkit Browser.
// node serialport in the Code.org Maker App.
if (this.serialPort_ && typeof this.serialPort_.close === 'function') {
this.serialPort_.close();
}
Expand Down
3 changes: 1 addition & 2 deletions apps/src/templates/MakerLanding.jsx
Expand Up @@ -2,7 +2,6 @@
import TopCourse from './studioHomepages/TopCourse';
import VerticalImageResourceCardRow from './VerticalImageResourceCardRow';
import shapes from './studioHomepages/shapes';
import {pegasus} from '@cdo/apps/lib/util/urlHelpers';
import i18n from '@cdo/locale';

const styles = {
Expand All @@ -26,7 +25,7 @@ export default class MakerLanding extends Component {
{
title: i18n.makerNewProjectTitle(),
description: i18n.makerNewProjectDesc(),
link: pegasus('/applab'),
link: '/projects/applab/new?enableMaker=true',
image: "applab-project",
buttonText: i18n.makerNewProjectButton()
},
Expand Down

0 comments on commit 813891c

Please sign in to comment.