Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTL (Test > Levelbuilder): 6462e608 #18077

Merged
merged 25 commits into from Oct 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3a0e9ce
use gctools GC::OOB::UnicornMiddleware
wjordan Sep 28, 2017
4a10134
shorten text to be the same as on code.org/yourschool
tanyaparker Sep 28, 2017
1af210a
getting channel shouldnt affect view options
Bjvanminnen Sep 29, 2017
3b61741
Merge remote-tracking branch 'upstream/staging' into section_dialog_f…
larrypo Sep 29, 2017
13e3dae
Merge remote-tracking branch 'upstream/staging' into section_dialog_f…
larrypo Sep 29, 2017
2599f31
set dashboard GC env variables
wjordan Sep 29, 2017
10cba92
Make `useAgent` dependent on `agentStartPosition`
Hamms Sep 29, 2017
ee21c08
Fixed DialogFooter to fix the cancel and/or save buttons to the botto…
larrypo Sep 29, 2017
92cbcc6
Re-style collecter gem counter
Sep 29, 2017
5e0858c
Merge pull request #18050 from code-dot-org/agent-without-agent
Hamms Sep 29, 2017
c013eea
remove recently-removed block from toolbox
Hamms Sep 29, 2017
b3eca44
Merge pull request #18012 from code-dot-org/oob_gc_update
wjordan Sep 29, 2017
16c0fb6
Merge pull request #18059 from code-dot-org/fix-craft-toolbox
Hamms Sep 29, 2017
e6a8b61
Merge pull request #18056 from larrypo/section_dialog_fixes
islemaster Sep 30, 2017
6dd3788
Updated cookbook versions
deploy-code-org Sep 30, 2017
e44b21a
Optimize generate_username query
wjordan Sep 25, 2017
256c411
Merge pull request #18061 from code-dot-org/generate_username_fix
wjordan Sep 30, 2017
bc31a37
Merge pull request #18062 from code-dot-org/staging
wjordan Sep 30, 2017
5ced6de
Merge pull request #18060 from code-dot-org/goal-count-style
balderdash Oct 2, 2017
164d1f5
Merge pull request #18064 from code-dot-org/staging
deploy-code-org Oct 2, 2017
b5282d2
Merge pull request #18037 from code-dot-org/getChannelFix
Bjvanminnen Oct 2, 2017
ba63a23
Merge pull request #18027 from code-dot-org/consistent-yourschool-boxes
tanyaparker Oct 2, 2017
5bbbc80
Merge pull request #18067 from code-dot-org/staging
deploy-code-org Oct 2, 2017
683db68
content scoop (-tanya)
deploy-code-org Oct 2, 2017
6462e60
Merge pull request #18068 from code-dot-org/staging
deploy-code-org Oct 2, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -111,6 +111,7 @@ gem 'factory_girl_rails', group: [:development, :staging, :test, :adhoc]
# For pegasus PDF generation.
gem 'open_uri_redirections', require: false, group: [:development, :staging, :test]

gem 'gctools'
gem 'unicorn', '~> 5.1.0'

gem 'chronic', '~> 0.10.2'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -319,6 +319,7 @@ GEM
font-awesome-rails (4.6.3.1)
railties (>= 3.2, < 5.1)
fspath (3.1.0)
gctools (0.2.4)
gemoji (2.1.0)
gherkin (4.0.0)
globalid (0.3.7)
Expand Down Expand Up @@ -781,6 +782,7 @@ DEPENDENCIES
firebase_token_generator
font-awesome-rails (~> 4.6.3)
full-name-splitter!
gctools
gemoji
geocoder!
google-api-client
Expand Down
4 changes: 2 additions & 2 deletions apps/src/craft/agent/craft.js
Expand Up @@ -479,8 +479,8 @@ export default class Craft {
actionPlane: levelConfig.actionPlane,
fluffPlane: fluffPlane,
entities: levelConfig.entities,
useAgent: true,
usePlayer: true,
useAgent: !!levelConfig.agentStartPosition,
usePlayer: !!levelConfig.playerStartPosition,
playerStartPosition: levelConfig.playerStartPosition,
playerStartDirection: levelConfig.playerStartDirection,
agentStartPosition: levelConfig.agentStartPosition,
Expand Down
45 changes: 28 additions & 17 deletions apps/src/maze/CollectorGemCounter.jsx
Expand Up @@ -13,10 +13,16 @@ const styles = {
pointerEvents: 'none',
textAlign: 'right',
verticalAlign: 'top',
marginTop: 5,
},
label: {
color: color.lighter_gray,
textTransform: 'capitalize'
color: color.white,
textTransform: 'capitalize',
backgroundColor: color.charcoal,
textAlign: 'center',
fontSize: 14,
borderRadius: 2,
width: '100%',
},
hr: {
borderColor: color.lighter_gray,
Expand All @@ -25,7 +31,8 @@ const styles = {
},
gemImage: {
backgroundImage: `url("${assetUrl('media/skins/collector/gem.png')}")`,
backgroundSize: '100%',
backgroundSize: '120%',
backgroundPosition: 'center',
display: 'inline',
padding: 5
},
Expand All @@ -37,6 +44,11 @@ const styles = {
position: 'relative',
top: 7,
},
gemCount: {
paddingRight: 5,
fontSize: 17,
color: color.charcoal,
},
};

export class CollectorGemCounter extends React.Component {
Expand All @@ -54,21 +66,20 @@ export class CollectorGemCounter extends React.Component {

return (
<div style={styles.container}>
<div>
<span style={styles.label}>{msg.goal()}</span>
<hr style={styles.hr} />
<div style={styles.gemImage} >
<i
style={{
...styles.checkmark,
visibility: showCheckmark ? 'visible' : 'hidden',
}}
className="fa fa-check"
aria-hidden="true"
/>
</div>
<span>{this.props.currentCollected}/{this.props.minRequired}</span>
<div style={styles.label}>{msg.goal()}</div>
<div style={styles.gemImage} >
<i
style={{
...styles.checkmark,
visibility: showCheckmark ? 'visible' : 'hidden',
}}
className="fa fa-check"
aria-hidden="true"
/>
</div>
<span style={styles.gemCount}>
{this.props.currentCollected}/{this.props.minRequired}
</span>
</div>
);
}
Expand Down
22 changes: 19 additions & 3 deletions apps/src/templates/teacherDashboard/DialogFooter.jsx
@@ -1,6 +1,19 @@
import React, {Component, PropTypes} from 'react';

const style = {
aboveFooter: {
height: '90px',
},
footer: {
position: 'absolute',
height: '80px',
padding: '0 20px 20px 20px',
left: '0',
right: '0',
bottom: '0',
background: 'white',
zIndex: '50',
},
buttonRow: {
display: 'flex',
flexFlow: 'row',
Expand All @@ -21,9 +34,12 @@ export default class DialogFooter extends Component {
render() {
return (
<div>
<hr/>
<div style={style.buttonRow}>
{this.props.children}
<div style={style.aboveFooter}></div>
<div style={style.footer}>
<hr/>
<div style={style.buttonRow}>
{this.props.children}
</div>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/Berksfile.lock
Expand Up @@ -61,7 +61,7 @@ GRAPH
seven_zip (>= 0.0.0)
windows (>= 0.0.0)
build-essential (2.1.3)
cdo-apps (0.2.239)
cdo-apps (0.2.241)
apt (>= 0.0.0)
build-essential (>= 0.0.0)
cdo-cloudwatch-extra-metrics (>= 0.0.0)
Expand Down
6 changes: 6 additions & 0 deletions cookbooks/cdo-apps/attributes/default.rb
@@ -1,6 +1,12 @@
default['cdo-apps'] = {
'dashboard' => {
'port' => 8080,
'env' => {
RUBY_GC_HEAP_FREE_SLOTS: 600_000, # Default is 4096
RUBY_GC_MALLOC_LIMIT_MAX: 134_217_728, # 128MB, default is 32MB
RUBY_GC_OLDMALLOC_LIMIT_MAX: 1_000_000_000, # 1GB, default is 128MB
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR: 3 # Default is 2.0
}
},

'pegasus' => {
Expand Down
3 changes: 2 additions & 1 deletion cookbooks/cdo-apps/libraries/cdo_apps.rb
Expand Up @@ -40,7 +40,8 @@ def setup_app(app_name)
pid_file: "#{app_root}/config/unicorn.rb.pid",
user: user,
env: node.chef_environment,
bundle_env: node['cdo-apps']['bundle_env']
export_env: node['cdo-apps']['bundle_env'].
merge(node['cdo-apps'][app_name]['env'] || {})
notifies :reload, "service[#{app_name}]", :delayed
end

Expand Down
2 changes: 1 addition & 1 deletion cookbooks/cdo-apps/metadata.rb
Expand Up @@ -4,7 +4,7 @@
license 'All rights reserved'
description 'Installs/Configures cdo-apps'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.239'
version '0.2.241'

depends 'apt'
depends 'build-essential'
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/cdo-apps/templates/default/unicorn.sh.erb
Expand Up @@ -14,7 +14,7 @@ APP_ROOT=<%= @app_root %>
PID=<%= @pid_file %>
CMD="cd $APP_ROOT; LANG=en_US.UTF-8 bundle exec unicorn -D -c <%= @src_file %> -E <%= @env %>"
AS_USER=<%= @user %>
<%= @bundle_env ? @bundle_env.map{|k,v|"export #{k}=#{v}"}.join("\n") : '' %>
<%= @export_env ? @export_env.map{|k,v|"export #{k}=#{v}"}.join("\n") : '' %>
UPGRADE_DELAY=${UPGRADE_DELAY-4}

action="$1"
Expand Down
17 changes: 7 additions & 10 deletions dashboard/app/helpers/levels_helper.rb
Expand Up @@ -45,7 +45,7 @@ def readonly_view_options

# Returns the channel associated with the given Level and User pair, or
# creates a new channel for the pair if one doesn't exist.
def get_channel_for(level, user = nil, make_readonly_with_other_user = true)
def get_channel_for(level, user = nil)
# This only works for logged-in users because the storage_id cookie is not
# sent back to the client if it is modified by ChannelsApi.
return unless current_user
Expand All @@ -55,9 +55,6 @@ def get_channel_for(level, user = nil, make_readonly_with_other_user = true)
# set_level_source to load answers when looking at another user,
# we have to load the channel here.
channel_token = ChannelToken.find_channel_token(level, user)
if make_readonly_with_other_user
readonly_view_options # TODO: has side effects
end
else
channel_token = ChannelToken.find_or_create_channel_token(
level,
Expand All @@ -73,10 +70,6 @@ def get_channel_for(level, user = nil, make_readonly_with_other_user = true)
channel_token.try :channel
end

def safe_get_channel_for(level, user)
get_channel_for(level, user, false)
end

def select_and_track_autoplay_video
return if @level.try(:autoplay_blocked_by_level?)

Expand Down Expand Up @@ -135,7 +128,11 @@ def app_options
# Unsafe to generate these twice, so use the cached version if it exists.
return @app_options unless @app_options.nil?

view_options(channel: get_channel_for(@level, @user)) if @level.channel_backed?
if @level.channel_backed?
view_options(channel: get_channel_for(@level, @user))
# readonly if viewing another user's channel
readonly_view_options if @user
end

# Always pass user age limit
view_options(is_13_plus: current_user && !current_user.under_13?)
Expand Down Expand Up @@ -202,7 +199,7 @@ def app_options
if recent_attempt
level_view_options(@level.id, pairing_attempt: edit_level_source_path(recent_attempt)) if recent_attempt
elsif @level.channel_backed?
recent_channel = safe_get_channel_for(@level, recent_user) if recent_user
recent_channel = get_channel_for(@level, recent_user) if recent_user
level_view_options(@level.id, pairing_attempt: send("#{@level.game.app}_project_view_projects_url".to_sym, channel_id: recent_channel)) if recent_channel
end
end
Expand Down
1 change: 0 additions & 1 deletion dashboard/app/models/levels/craft.rb
Expand Up @@ -512,7 +512,6 @@ def agent_blocks
</block>
<block type='craft_destroyBlock'></block>
<block type='craft_placeBlock'></block>
<block type='craft_placeTorch'></block>
<block type="when_run"></block>
</category>
XML
Expand Down
4 changes: 2 additions & 2 deletions dashboard/config.ru
Expand Up @@ -2,8 +2,8 @@

require ::File.expand_path('../config/environment', __FILE__)

require 'unicorn/oob_gc'
use Unicorn::OobGC
require 'gctools/oobgc/unicorn_middleware'
use GC::OOB::UnicornMiddleware
use Rack::ContentLength
require 'rack/ssl-enforcer'
use Rack::SslEnforcer,
Expand Down
Binary file added dashboard/public/c/video_thumbnails/225.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/public/c/video_thumbnails/226.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/public/c/video_thumbnails/227.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/public/c/video_thumbnails/228.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/public/c/video_thumbnails/229.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions dashboard/test/helpers/levels_helper_test.rb
Expand Up @@ -213,6 +213,11 @@ def request
# channel exists
create :channel_token, level: @level, user: @user, channel: 'whatever'
assert_equal 'whatever', get_channel_for(@level, @user)

# calling app_options should set readonly_workspace, since we're viewing for
# different user
app_options
assert_equal true, view_options[:readonly_workspace]
end

test 'applab levels should include pairing_driver and pairing_attempt when viewed by navigator' do
Expand All @@ -230,6 +235,10 @@ def request

assert_not_nil app_options[:level]['pairingDriver']
assert_not_nil app_options[:level]['pairingAttempt']

# calling app_options should not set readonly_workspace
app_options
assert_nil view_options[:readonly_workspace]
end

def stub_country(code)
Expand Down
31 changes: 15 additions & 16 deletions dashboard/test/models/user_helpers_test.rb
Expand Up @@ -36,39 +36,38 @@ def create_user_with_username(username)
test 'generate_username for existing username via dart throwing' do
create_user_with_username 'captain_picard'

# An existing username attempts the username, fails, and receives '6'.
# An existing username attempts the username, fails, and receives '784'.
srand 0
assert_equal 'captain_picard6',
assert_equal 'captain_picard784',
UserHelpers.generate_username(User, 'Captain Picard')
create_user_with_username 'captain_picard6'
create_user_with_username 'captain_picard784'

# The next Captain Picard attempts '6', fails, and receives '1'
# The next Captain Picard attempts '784', fails, and receives '659'
srand 0
assert_equal 'captain_picard1',
assert_equal 'captain_picard659',
UserHelpers.generate_username(User, 'Captain Picard')
create_user_with_username 'captain_picard1'
create_user_with_username 'captain_picard659'

# The next Captain Picard attempts '6', fails, attempts '1', fails, and
# receives '4'.
# The next Captain Picard attempts '784' and '659', fails, and
# receives '4264'.
srand 0
assert_equal 'captain_picard4',
assert_equal 'captain_picard4264',
UserHelpers.generate_username(User, 'Captain Picard')
create_user_with_username 'captain_picard4'
create_user_with_username 'captain_picard4264'

# The next Captain Picard attempts '6', fails, attempts '1', fails,
# attempts '4', fails, and receives '77'.
# The next Captain Picard attempts the above, fails and receives '5859'.
srand 0
assert_equal 'captain_picard77',
assert_equal 'captain_picard5859',
UserHelpers.generate_username(User, 'Captain Picard')
end

test 'generate_username for existing username via fallback' do
['', '6', '1', '4', '77', '19', '93', '377', '854', '904'].each do |suffix|
['', 784, 659, 4264, 5859, 51993, 96293, 54824, 47456, 383298, 593063, 548242, 474564].each do |suffix|
create_user_with_username "captain_picard#{suffix}"
end

srand 0
assert_equal 'captain_picard905',
assert_equal 'captain_picard383299',
UserHelpers.generate_username(User, 'Captain Picard')
end

Expand Down Expand Up @@ -98,7 +97,7 @@ def create_user_with_username(username)
test 'generate_username' do
default_params = {email: 'foo@bar.com', password: 'foosbars', name: 'tester', user_type: User::TYPE_STUDENT, age: 28}
names = ['a', 'b', 'Captain Picard', 'Captain Picard', 'Captain Picard', 'this is a really long name blah blah blah blah blah blah']
expected_usernames = %w(coder_a coder_b captain_picard captain_picard6 captain_picard1 this_is_a_really)
expected_usernames = %w(coder_a coder_b captain_picard captain_picard784 captain_picard659 this_is_a_really)

i = 0
users = names.map do |name|
Expand Down