Skip to content

Commit

Permalink
Merge pull request #19662 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT (Staging > Test) [robo-dtt]
  • Loading branch information
deploy-code-org committed Dec 14, 2017
2 parents 75f6390 + 0d01b0b commit 8e13a62
Show file tree
Hide file tree
Showing 21 changed files with 866 additions and 274 deletions.
1 change: 0 additions & 1 deletion apps/src/sites/studio/pages/home/_homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ function showHomepage() {
id: announcementId
}
]}
hocLaunch={homepageData.hoc_launch}
courses={homepageData.courses}
joinedSections={homepageData.joined_sections}
topCourse={homepageData.topCourse}
Expand Down
10 changes: 6 additions & 4 deletions apps/src/templates/studioHomepages/ImageResourceCard.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {Component, PropTypes} from 'react';
import Radium from 'radium';
import {connect} from 'react-redux';
import Button from '../Button';
import color from "../../util/color";

Expand Down Expand Up @@ -84,11 +84,11 @@ class ImageResourceCard extends Component {
const imgSrc = filenameToImgUrl[image];

return (
<div style={[styles.card, localeStyle]}>
<div style={{...styles.card, ...localeStyle}}>
<div style={styles.image}>
<img src={imgSrc}/>
</div>
<div style={[styles.textbox, localeStyle, uncoverImage]}>
<div style={{...styles.textbox, ...localeStyle, ...uncoverImage}}>
<div style={styles.title}>
{title}
</div>
Expand All @@ -108,4 +108,6 @@ class ImageResourceCard extends Component {
}
}

export default Radium(ImageResourceCard);
export default connect(state => ({
isRtl: state.isRtl,
}))(ImageResourceCard);
16 changes: 1 addition & 15 deletions apps/src/templates/studioHomepages/ImageResourceCard.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ImageResourceCard from './ImageResourceCard';
export default storybook => {
return storybook
.storiesOf('ImageResourceCard', module)
.withReduxStore()
.addStoryTable([
{
name: 'basic resource card',
Expand All @@ -15,21 +16,6 @@ export default storybook => {
image="teacher-community"
buttonText= "Connect Today"
link= "link to teacher community"
isRtl={false}
/>
)
},
{
name: 'basic resource card - RTL',
description: `This is an example resource card with RTL styling.`,
story: () => (
<ImageResourceCard
title= "Teacher Community"
description="Ask questions about curriculum, share ideas from your lessons, and get help from other teachers"
image="teacher-community"
buttonText= "Connect Today"
link= "link to teacher community"
isRtl={true}
/>
)
},
Expand Down
72 changes: 2 additions & 70 deletions apps/src/templates/studioHomepages/TeacherHomepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {PropTypes, Component} from 'react';
import ReactDOM from 'react-dom';
import $ from 'jquery';
import HeaderBanner from '../HeaderBanner';
import {SpecialAnnouncementActionBlock} from './TwoColumnActionBlock';
import Notification from '../Notification';
import RecentCourses from './RecentCourses';
import TeacherSections from './TeacherSections';
Expand All @@ -12,7 +11,6 @@ import ProjectWidgetWithData from '@cdo/apps/templates/projects/ProjectWidgetWit
import shapes from './shapes';
import ProtectedStatefulDiv from '../ProtectedStatefulDiv';
import i18n from "@cdo/locale";
import {pegasus} from '@cdo/apps/lib/util/urlHelpers';

const styles = {
clear: {
Expand All @@ -30,7 +28,6 @@ export default class TeacherHomepage extends Component {
isRtl: PropTypes.bool.isRequired,
queryStringOpen: PropTypes.string,
canViewAdvancedTools: PropTypes.bool,
hocLaunch: PropTypes.object,
isEnglish: PropTypes.bool.isRequired
};

Expand All @@ -42,7 +39,7 @@ export default class TeacherHomepage extends Component {

render() {
const { courses, topCourse, announcements, isRtl, queryStringOpen, joinedSections } = this.props;
const { canViewAdvancedTools, hocLaunch, isEnglish } = this.props;
const { canViewAdvancedTools } = this.props;

return (
<div>
Expand All @@ -56,73 +53,8 @@ export default class TeacherHomepage extends Component {
<ProtectedStatefulDiv
ref="termsReminder"
/>
{hocLaunch &&
hocLaunch.special_announcement &&
(hocLaunch.special_announcement === "mc2017" ||
(hocLaunch.special_announcement === "applab2017" && !isEnglish) ||
(hocLaunch.special_announcement === "celebs2017" && !isEnglish)) && (
<SpecialAnnouncementActionBlock
imageUrl={pegasus('/images/mc/fill-540x289/special-announcement-hoc2017.jpg')}
heading={i18n.specialAnnouncementHeading()}
subHeading={""}
description={i18n.specialAnnouncementDescription()}
buttons={[
{url: 'https://hourofcode.com/#join', text: i18n.joinUs()},
{url: pegasus('/minecraft'), text: i18n.tryIt()}
]}
/>
)}

{hocLaunch &&
hocLaunch.special_announcement &&
hocLaunch.special_announcement === "applab2017" &&
isEnglish && (
<SpecialAnnouncementActionBlock
imageUrl={pegasus('/images/fill-540x289/special-announcements/applab_hoc2017.jpg')}
heading={i18n.specialAnnouncementHeadingAppLab()}
subHeading={""}
description={i18n.specialAnnouncementDescriptionAppLab()}
buttons={[
{url: 'https://hourofcode.com/#join', text: i18n.joinUs()},
{url: pegasus('/learn'), text: i18n.tryIt()}
]}
/>
)}

{hocLaunch &&
hocLaunch.special_announcement &&
hocLaunch.special_announcement === "celebs2017" &&
isEnglish && (
<SpecialAnnouncementActionBlock
imageUrl={pegasus('/images/fill-540x289/special-announcements/celebs_hoc2017.jpg')}
heading={i18n.specialAnnouncementHeading()}
subHeading={""}
description={i18n.specialAnnouncementDescriptionCelebs()}
buttons={[
{url: pegasus('/challenge'), text: i18n.celebrityChallenge()},
{url: pegasus('/learn'), text: i18n.tryHOC()}
]}
/>
)}

{hocLaunch &&
hocLaunch.special_announcement &&
hocLaunch.special_announcement === "celebs2017actualhoc" &&
isEnglish && (
<SpecialAnnouncementActionBlock
imageUrl={pegasus('/images/fill-540x289/special-announcements/celebs_hoc2017.jpg')}
heading={i18n.specialAnnouncementHeadingCelebs()}
subHeading={""}
description={i18n.specialAnnouncementDescriptionCelebs()}
buttons={[
{url: pegasus('/challenge'), text: i18n.celebrityChallenge()},
{url: pegasus('/learn'), text: i18n.tryHOC()}
]}
/>
)}

{announcements.length > 0 &&
!(hocLaunch && hocLaunch.hide_teacher_announcement) && (
{announcements.length > 0 && (
<div>
<Notification
type={announcements[0].type || "bullhorn"}
Expand Down
4 changes: 0 additions & 4 deletions apps/src/templates/studioHomepages/TeacherResources.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,27 @@ export default class TeacherResources extends Component {
image="teacher-community"
buttonText={i18n.joinCommunity()}
link="https://forum.code.org"
isRtl={isRtl}
/>
<ImageResourceCard
title={i18n.professionalLearning()}
description={i18n.professionalLearningDescription()}
image="professional-learning"
buttonText={i18n.learnMore()}
link="/my-professional-learning"
isRtl={isRtl}
/>
<ImageResourceCard
title={i18n.standardsAndFramework()}
description={i18n.standardsAndFrameworkDescription()}
image="standards-framework"
buttonText={i18n.reviewDocuments()}
link={planUrl}
isRtl={isRtl}
/>
<ImageResourceCard
title={i18n.findGuestSpeaker()}
description={i18n.findGuestSpeakerDescription()}
image="guest-speaker"
buttonText={i18n.inspireStudents()}
link={volunteerUrl}
isRtl={isRtl}
/>
</div>
</ContentContainer>
Expand Down
10 changes: 1 addition & 9 deletions apps/src/templates/studioHomepages/TeacherResources.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TeacherResources from './TeacherResources';
export default storybook => {
return storybook
.storiesOf('TeacherResources', module)
.withReduxStore()
.addStoryTable([
{
name: 'Resources for teachers',
Expand All @@ -14,14 +15,5 @@ export default storybook => {
/>
)
},
{
name: 'Resources for teachers - RTL',
description: `This is the TeacherResources section that will be used on the teacher homepage with RTL styles.`,
story: () => (
<TeacherResources
isRtl={true}
/>
)
},
]);
};
92 changes: 92 additions & 0 deletions aws/redshift/queries/code_studio.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
SELECT COUNT(0) value, 'all time teachers' metric
FROM users
WHERE user_type = 'teacher'
and cast(created_at as date) <= last_day(dateadd(month, -1, getdate()))
AND current_sign_in_at IS NOT NULL

union all

SELECT COUNT(0) value, 'all time students' metric
FROM users
WHERE user_type = 'student'
and cast(created_at as date) <= last_day(dateadd(month, -1, getdate()))
AND current_sign_in_at IS NOT NULL

union all

SELECT COUNT(distinct case when gender = 'f' then u.id end)::float / COUNT(distinct u.id) value, 'all time % female' metric
FROM users u
WHERE user_type = 'student'
and cast(u.created_at as date) <= last_day(dateadd(month, -1, getdate()))
AND current_sign_in_at IS NOT NULL
and gender in ('m', 'f')

union all

SELECT COUNT(distinct case when f.id is not null then u.id end)::float / count(distinct u.id) value, 'all time % of students with teachers' metric
FROM users u
left join followers f on f.student_user_id = u.id
WHERE user_type = 'student'
and cast(u.created_at as date) <= last_day(dateadd(month, -1, getdate()))
AND current_sign_in_at IS NOT NULL

union all

SELECT COUNT(DISTINCT sections.user_id) value, 'L30D teachers with active students' metric
FROM (SELECT u.id FROM sign_ins si join users u on u.id = si.user_id WHERE user_type = 'student' AND date_diff('day', sign_in_at, last_day(dateadd(month, -1, getdate()))) between 0 and 30) AS u
INNER JOIN followers ON u.id = followers.student_user_id
inner join sections on followers.section_id = sections.id

union all

SELECT COUNT(DISTINCT sections.user_id) value, 'L365D teachers with active students' metric
FROM (SELECT id FROM users WHERE user_type = 'student' AND date_diff('day', current_sign_in_at, (select max(created_at) from users)) between 0 and 364) AS u -- calculated when closest to end of month data was available
INNER JOIN followers ON u.id = followers.student_user_id
inner join sections on followers.section_id = sections.id

union all

select count(distinct user_id) value, 'L30D active students' metric
from sign_ins si
join users u on u.id = si.user_id
where user_type = 'student'
and date_diff('day', sign_in_at, last_day(dateadd(month, -1, getdate()))) between 0 and 29

union all

select count(distinct id) value, 'L365D active students' metric
from users
where date_diff('day', current_sign_in_at, (select max(created_at) from users)) between 0 and 364 -- calculated when most recent data was from oct 13
and user_type = 'student'

union all

SELECT COUNT(distinct case when gender = 'f' then u.id end)::float / COUNT(distinct u.id) value, 'L30D % female students' metric
FROM users u
WHERE user_type = 'student'
AND u.id in (SELECT u.id FROM sign_ins si join users u on u.id = si.user_id WHERE user_type = 'student' AND date_diff('day', sign_in_at, last_day(dateadd(month, -1, getdate()))) between 0 and 29)
and gender in ('m', 'f')

union all

select count(distinct
case when urm = 1 then u.id
else null
END
)::float /
count(distinct
case when urm in (0,1) then u.id
else null
END
) value, 'L30D % URM students (13+)' metric
FROM users u
WHERE user_type = 'student'
AND u.id in (SELECT u.id FROM sign_ins si join users u on u.id = si.user_id WHERE user_type = 'student' AND date_diff('day', sign_in_at, last_day(dateadd(month, -1, getdate()))) between 0 and 29)

union all

SELECT COUNT(distinct case when f.id is not null then u.id end)::float / count(distinct u.id) value, 'L30D % students with teachers' metric
FROM users u
left join followers f on f.student_user_id = u.id
WHERE user_type = 'student'
AND u.id in (SELECT u.id FROM sign_ins si join users u on u.id = si.user_id WHERE user_type = 'student' AND date_diff('day', sign_in_at, last_day(dateadd(month, -1, getdate()))) between 0 and 29);

0 comments on commit 8e13a62

Please sign in to comment.