Skip to content
Merged

DTT #2988

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8c74ccf
Use milestone parser v2 in analyze_hoc_activity
wjordan Jun 11, 2015
ee7fe8a
add indexes for slow hoc_activity start-finish queries
wjordan Jun 25, 2015
20a34c0
MiniTest::Unit::TestCase => Minitest::Test
wjordan Jun 25, 2015
c2894ba
revert Minitest::Test change
wjordan Jun 26, 2015
f2f0134
aws-sdk 2.1.2
wjordan Jun 26, 2015
6207199
add `has_teacher` dimension to GA
wjordan Jun 26, 2015
a484560
cast ga dimensions to strings
wjordan Jun 26, 2015
14f47af
studio.code.org: Make 'try now' show up again for unstarted courses.
breville Jun 29, 2015
16adb6b
add assets api endpoint to copy all files from one channel to another.
davidsbailey Jun 26, 2015
d2e4f50
[finishes #96140614] copy assets on remix
davidsbailey Jun 26, 2015
b860fa6
on deserialize, reconstruct asset urls from canonical image urls, in …
davidsbailey Jun 26, 2015
cf0cbd2
dont go back page when pressing backspace in applab
Bjvanminnen Jun 29, 2015
779aaec
add test_assets_copy_all
davidsbailey Jun 29, 2015
2dff35e
Merge pull request #2978 from code-dot-org/staging
wjordan Jun 29, 2015
c96d390
Add User.completed? and User.working_on? functions.
breville Jun 29, 2015
c82dca4
Merge pull request #2977 from code-dot-org/noBackwardsOnDelete
Bjvanminnen Jun 29, 2015
8be3737
Automatically built.
deploy-code-org Jun 29, 2015
0655343
dropbox and gsheet changes
deploy-code-org Jun 29, 2015
6c1cbde
Merge pull request #2976 from code-dot-org/assets-api-remix
davidsbailey Jun 29, 2015
8189508
Automatically built.
deploy-code-org Jun 29, 2015
23eab42
Update designMode.js
davidsbailey Jun 29, 2015
00d742a
Automatically built.
deploy-code-org Jun 29, 2015
0588689
Clean up Rake logging and backtraces
wjordan Jun 29, 2015
0cd3d1f
do TODO, duh
laurelfan Jun 29, 2015
30ab488
Dropbox changes
deploy-code-org Jun 29, 2015
1d8edd4
Merge pull request #2983 from code-dot-org/staging
tanyaparker Jun 29, 2015
53d88c9
add step button back to course 1 stage 5, by tanya
deploy-code-org Jun 29, 2015
066d0f2
Merge pull request #2984 from code-dot-org/levelbuilder
tanyaparker Jun 29, 2015
da4bfe5
Merge pull request #2965 from code-dot-org/ga_has_teacher_dimension
wjordan Jun 30, 2015
5098c37
ignore advertised blocks, and add ellipse for titles
tanyaparker Jun 30, 2015
27ffbbc
Merge pull request #2947 from code-dot-org/analyze_hoc_activity_fix
wjordan Jun 30, 2015
0f3ab0c
increase height for 2 lines of smalltext
tanyaparker Jun 30, 2015
dfe9e46
fix typo in query
wjordan Jun 30, 2015
2fe80f6
fix typo in query
wjordan Jun 30, 2015
c2e96b8
use description_short instead of description
tanyaparker Jun 30, 2015
ddf7f80
touch up smalltext css
tanyaparker Jun 30, 2015
095401c
Merge pull request #2986 from code-dot-org/staging
tanyaparker Jun 30, 2015
dcf43df
levelbuilder changes committed by tanya
deploy-code-org Jun 30, 2015
561e3de
Merge pull request #2987 from code-dot-org/levelbuilder
tanyaparker Jun 30, 2015
d136d09
clean up scripts.en.yml, add description_short
tanyaparker Jun 30, 2015
70d22a0
update translate/videos
tanyaparker Jun 30, 2015
9c8cc0e
fix scripts.en.yml
tanyaparker Jun 30, 2015
ddda5ea
Merge pull request #2985 from code-dot-org/courseprogressblocks
tanyaparker Jun 30, 2015
6366522
Merge pull request #2974 from code-dot-org/fixtrynow
breville Jun 30, 2015
98efdc8
update course progress actions with helper functions
tanyaparker Jun 30, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ GEM
builder
mime-types
xml-simple
aws-sdk (2.0.29)
aws-sdk-resources (= 2.0.29)
aws-sdk-core (2.0.29)
builder (~> 3.0)
aws-sdk (2.1.2)
aws-sdk-resources (= 2.1.2)
aws-sdk-core (2.1.2)
jmespath (~> 1.0)
multi_json (~> 1.0)
multi_xml (~> 0.5)
aws-sdk-resources (2.0.29)
aws-sdk-core (= 2.0.29)
aws-sdk-resources (2.1.2)
aws-sdk-core (= 2.1.2)
bcrypt (3.1.7)
better_errors (1.1.0)
coderay (>= 1.0.0)
Expand Down Expand Up @@ -218,7 +215,7 @@ GEM
powerbar
mocha (1.0.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
multi_json (1.11.1)
multi_test (0.1.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ namespace :build do
begin
RakeUtils.rake 'db:migrate'
rescue => e
HipChat.log "/quote #{e.message} #{e.backtrace.join("\n")}", message_format: 'text'
HipChat.log "/quote #{e.message} #{CDO.backtrace e}", message_format: 'text'
end

HipChat.log 'Seeding <b>pegasus</b>...'
begin
RakeUtils.rake 'seed:migrate'
rescue => e
HipChat.log "/quote #{e.message} #{e.backtrace.join("\n")}", message_format: 'text'
HipChat.log "/quote #{e.message} #{CDO.backtrace e}", message_format: 'text'
end
end

Expand Down
28 changes: 28 additions & 0 deletions apps/src/applab/applab.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,34 @@ Applab.init = function(config) {
dom.addClickTouchEvent(viewDataButton, throttledViewDataClick);
}

// Prevent the backspace key from navigating back. Make sure it's still
// allowed on other elements.
// Based on http://stackoverflow.com/a/2768256/2506748
$(document).on('keydown', function (event) {
var doPrevent = false;
if (event.keyCode !== KeyCodes.BACKSPACE) {
return;
}
var d = event.srcElement || event.target;
if ((d.tagName.toUpperCase() === 'INPUT' && (
d.type.toUpperCase() === 'TEXT' ||
d.type.toUpperCase() === 'PASSWORD' ||
d.type.toUpperCase() === 'FILE' ||
d.type.toUpperCase() === 'EMAIL' ||
d.type.toUpperCase() === 'SEARCH' ||
d.type.toUpperCase() === 'DATE' )) ||
d.tagName.toUpperCase() === 'TEXTAREA') {
doPrevent = d.readOnly || d.disabled;
}
else {
doPrevent = !d.isContentEditable;
}

if (doPrevent) {
event.preventDefault();
}
});

designMode.addKeyboardHandlers();

designMode.renderDesignWorkspace();
Expand Down
6 changes: 6 additions & 0 deletions apps/src/applab/designElements/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,11 @@ module.exports = {
element.style.backgroundColor = '#1abc9c';

return element;
},
onDeserialize: function (element, onPropertyChange) {
var url = element.getAttribute('data-canonical-image-url');
if (url) {
onPropertyChange(element, 'image', url);
}
}
};
5 changes: 0 additions & 5 deletions apps/src/applab/designElements/elementUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ module.exports.rgb2hex = function (rgb) {
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
};

module.exports.extractImageUrl = function (str) {
var inner = str.match(/^url\((.*)\)$/);
return inner ? inner[1] : str;
};
6 changes: 6 additions & 0 deletions apps/src/applab/designElements/image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,11 @@ module.exports = {
element.setAttribute('src', '');

return element;
},
onDeserialize: function (element, onPropertyChange) {
var url = element.getAttribute('data-canonical-image-url');
if (url) {
onPropertyChange(element, 'picture', url);
}
}
};
6 changes: 3 additions & 3 deletions apps/src/applab/designElements/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ module.exports = {
* Code to be called after deserializing element, allowing us to attach any
* necessary event handlers.
*/
onDeserialize: function (element) {
onDeserialize: function (element, onPropertyChange) {
var elementType = this.getElementType(element);
if (elements[elementType].onDeserialize) {
elements[elementType].onDeserialize(element);
if (elements[elementType] && elements[elementType].onDeserialize) {
elements[elementType].onDeserialize(element, onPropertyChange);
}
},

Expand Down
6 changes: 6 additions & 0 deletions apps/src/applab/designElements/screen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@ module.exports = {
element.style.zIndex = 0;

return element;
},
onDeserialize: function (element, onPropertyChange) {
var url = element.getAttribute('data-canonical-image-url');
if (url) {
onPropertyChange(element, 'screen-image', url);
}
}
};
5 changes: 4 additions & 1 deletion apps/src/applab/designMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ designMode.parseFromLevelHtml = function(rootEl, allowDragging) {
}

children.each(function () {
elementLibrary.onDeserialize($(this)[0]);
elementLibrary.onDeserialize($(this)[0], designMode.onPropertyChange.bind(this));
});
children.children().each(function() {
elementLibrary.onDeserialize($(this)[0], designMode.onPropertyChange.bind(this));
});
};

Expand Down
1 change: 1 addition & 0 deletions apps/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ exports.BeeTerminationValue = {
};

exports.KeyCodes = {
BACKSPACE: 8,
ENTER: 13,
SPACE: 32,
LEFT: 37,
Expand Down
10 changes: 7 additions & 3 deletions bin/analyze_hoc_activity
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ def add_count_to_hash(hash, key, count)
end

def analyze_day_fast(date)
day = date.strftime('%Y-%m-%d')
next_day = (date + 1).strftime('%Y-%m-%d')
froms = [
"FROM hoc_activity WHERE started_at LIKE '#{date.strftime('%Y-%m-%d')} %' OR pixel_started_at LIKE '#{date.strftime('%Y-%m-%d')} %'",
"FROM hoc_activity WHERE (started_at >= '#{day}' AND started_at < '#{next_day}')" +
" OR (pixel_started_at >= '#{day}' AND pixel_started_at < '#{next_day}')",
]

finished_froms = [
"FROM hoc_activity WHERE finished_at LIKE '#{date.strftime('%Y-%m-%d')} %' OR pixel_finished_at LIKE '#{date.strftime('%Y-%m-%d')} %'",
"FROM hoc_activity WHERE (finished_at >= '#{day}' AND finished_at < '#{next_day}')" +
" OR (pixel_finished_at >= '#{day}' AND pixel_finished_at < '#{next_day}')",
]

#HipChat.log "Analyzing by <b>tutorial</b>..." if rack_env?(:production)
Expand Down Expand Up @@ -153,7 +157,7 @@ def main()
}

#HipChat.log 'Calculating lines of code...' if rack_env?(:production)
lines_of_code = rack_env?(:production) ? `#{deploy_dir('bin','count-lines-of-code-from-milestone-logs')}`.to_i : 0
lines_of_code = rack_env?(:production) ? `#{deploy_dir('bin','count-lines-of-code-from-milestone-logs_v2')}`.to_i : 0

time = DateTime.now
Properties.set :metrics, {
Expand Down
2 changes: 1 addition & 1 deletion bin/count-lines-of-code-from-milestone-logs_v2
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
require_relative '../deployment'
require 'cdo/analytics/milestone_parser'

puts "Total Lines of Code: #{MilestoneParser::count}"
puts MilestoneParser::count
9 changes: 9 additions & 0 deletions dashboard/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,15 @@ def reset_secret_words
save!
end

def completed?(script)
user_script = user_scripts.where(script_id: script.id).first
user_script.try(:completed_at) || (user_script && next_unpassed_progression_level(script).nil?)
end

def working_on?(script)
working_on_scripts.include?(script)
end

def working_on_scripts
backfill_user_scripts if needs_to_backfill_user_scripts?

Expand Down
4 changes: 3 additions & 1 deletion dashboard/app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
- if current_user
#user_hero
= render template: 'api/user_hero'
- [current_user.working_on_user_scripts, current_user.completed_user_scripts].compact.reduce([], :|).each_slice(2) do |course_pair|
- advertised_scripts = [Script::HOC_NAME, Script::FROZEN_NAME, Script::INFINITY_NAME, Script::FLAPPY_NAME, Script::PLAYLAB_NAME, Script::ARTIST_NAME, Script::COURSE1_NAME, Script::COURSE2_NAME, Script::COURSE3_NAME, Script::COURSE4_NAME, Script::TWENTY_HOUR_NAME]
- unadvertised_user_scripts = [current_user.working_on_user_scripts, current_user.completed_user_scripts].compact.flatten.delete_if { |user_script| user_script.script.name.in?(advertised_scripts)}
- unadvertised_user_scripts.each_slice(2) do |course_pair|
.row
- course_pair.each do |user_script|
= render partial: 'shared/course_progress_block', locals: { script: user_script.script, user_script: user_script }
Expand Down
7 changes: 4 additions & 3 deletions dashboard/app/views/layouts/_analytics.html.haml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
- create_params = {cookieDomain: (Rails.env.development? ? 'none' : 'auto')}
-# The following dimensions must match in order the custom dimension settings in our Google Analytics account.
- selected_language_dim, age_dim, gender_dim, user_type_dim, env_dim, pixel_ratio = (1..6).map{|x|"dimension#{x}"}
- selected_language_dim, age_dim, gender_dim, user_type_dim, env_dim, pixel_ratio, has_teacher = (1..7).map{|x|"dimension#{x}"}
- dimensions = {}
- dimensions[selected_language_dim] = language if (accepted_languages.present? && accepted_languages.first != language)
- dimensions[env_dim] = Rails.env
- if user_signed_in?
- dimensions[age_dim] = current_user.age
- dimensions[age_dim] = current_user.age.to_s
- dimensions[gender_dim] = current_user.gender
- dimensions[user_type_dim] = current_user.user_type
- dimensions[has_teacher] = current_user.teachers.any? ? '1' : '0'
- create_params[:userId] = "#{current_user.id}#{'-dev' unless Rails.env.production?}"
:javascript
// Google Analytics snippet (https://developers.google.com/analytics/devguides/collection/analyticsjs/)
Expand All @@ -20,7 +21,7 @@

var dimensions = #{dimensions.to_json};
if ('devicePixelRatio' in window) {
dimensions["#{pixel_ratio}"] = window.devicePixelRatio;
dimensions["#{pixel_ratio}"] = window.devicePixelRatio.toString();
}

ga('set', dimensions);
Expand Down
33 changes: 15 additions & 18 deletions dashboard/app/views/shared/_course_progress_block.html.haml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
- user_script ||= nil
.course_progress{style: 'float: left; position: relative;'}
- unless script.name.in?([Script::HOC_NAME, Script::FROZEN_NAME, Script::INFINITY_NAME, Script::FLAPPY_NAME, Script::PLAYLAB_NAME, Script::ARTIST_NAME, Script::COURSE1_NAME, Script::COURSE2_NAME, Script::COURSE3_NAME, Script::COURSE4_NAME, Script::TWENTY_HOUR_NAME])
.courseblock-span3.courseblock-wide-small{style: 'width: 460px; height: 110px;'}
=link_to script_url(script.id) do
.heading
%h3= data_t_suffix('script.name', script.name, 'title')
.clear
.smalltext= data_t_suffix('script.name', script.name, 'description')
.clear
- next_unpassed_progression_level = current_user.next_unpassed_progression_level(script)
- if user_script.try(:completed_at) || (user_script && next_unpassed_progression_level.nil?)
%a{href: script_certificate_image_url(current_user, script)}
.bottombar.smalltext.printcertificate{style: 'bottom: 0; position: absolute'}= t('home.print_certificate')
- elsif next_unpassed_progression_level
%a{href: build_script_level_url(next_unpassed_progression_level)}
.bottombar.smalltext.continue{style: 'bottom: 0; position: absolute'}= t('continue')
- else
= link_to build_script_level_url(current_user.next_unpassed_progression_level(script)) do
.bottombar.smalltext.trynow{style: 'bottom: 0; position: absolute'}= t('home.trynow')
.courseblock-span3.courseblock-wide-small{style: 'width: 460px; height: 120px;'}
=link_to script_url(script.id) do
%h3= data_t_suffix('script.name', script.name, 'title')
.clear
.smalltext= data_t_suffix('script.name', script.name, 'description_short')
.clear
- if current_user.completed?(script)
%a{href: script_certificate_image_url(current_user, script)}
.bottombar.bottombartext.printcertificate{style: 'bottom: 0; position: absolute'}= t('home.print_certificate')
- elsif current_user.working_on?(script)
%a{href: build_script_level_url(current_user.next_unpassed_progression_level(script))}
.bottombar.bottombartext.continue{style: 'bottom: 0; position: absolute'}= t('continue')
- else
%a{href: script_url(script.id)}
.bottombar.bottombartext.trynow{style: 'bottom: 0; position: absolute'}= t('home.trynow')
8 changes: 3 additions & 5 deletions dashboard/app/views/shared/_courseblock_action.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
.clear

- script = Script.find_by_name(id)
- user_script = current_user.user_scripts.where(script_id: script.id).first
- next_unpassed_progression_level = current_user.next_unpassed_progression_level(script)

- if user_script.try(:completed_at) || (user_script && next_unpassed_progression_level.nil?)
- if current_user.completed? (script)
= link_to script_certificate_image_url(current_user, script), class: 'whitelink' do
.bottombar.smalltext.printcertificate
= t('home.print_certificate')
- elsif next_unpassed_progression_level
%a.whitelink{href: build_script_level_url(next_unpassed_progression_level)}
- elsif current_user.working_on? (script)
%a.whitelink{href: build_script_level_url(current_user.next_unpassed_progression_level(script))}
.bottombar.smalltext.continue
= t('continue')
- else
Expand Down
9 changes: 4 additions & 5 deletions dashboard/app/views/shared/_user_stats.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
- puzzle_outer_class = 'puzzle_outer_level'
%span{class: puzzle_outer_class}
- link = url_from_path("/s/#{script_summary[:name]}/stage/#{stage[:position]}/puzzle/#{level[:position]}")
- if current_user.try(:admin?) # TODO remove when we ship this feature
- if current_user && current_user != user # viewing someone else's progress
- link += "?user_id=#{user.id}"
- if @section
- link += "&section_id=#{@section.id}"
- if current_user && current_user != user # viewing someone else's progress
- link += "?user_id=#{user.id}"
- if @section
- link += "&section_id=#{@section.id}"
%a.level_link{href: link, class: status}
- if level[:kind] == 'unplugged'
%span.puzzle-named
Expand Down
Loading