Requires ruby... if you're on a mac you're good
sudo gem install nokogiri
(remove sudo if you know you don't need that)
run with ruby tots.rb
diff --git a/app/models/data_platform/filters/base.rb b/app/models/data_platform/filters/base.rb | |
index a2442a1..3b028b9 100644 | |
--- a/app/models/data_platform/filters/base.rb | |
+++ b/app/models/data_platform/filters/base.rb | |
@@ -2,8 +2,6 @@ class DataPlatform::Filters::Base | |
FILTER_TYPES = [:id, :date] | |
- class_attribute :token, :name, :opts | |
- |
diff --git a/app/models/data_platform/filters/implementation_period.rb b/app/models/data_platform/filters/implementation_period.rb | |
index 9f4162b..e337f72 100644 | |
--- a/app/models/data_platform/filters/implementation_period.rb | |
+++ b/app/models/data_platform/filters/implementation_period.rb | |
@@ -11,7 +11,7 @@ class DataPlatform::Filters::ImplementationPeriod < DataPlatform::Filters::Base | |
def self.options(params) | |
::ImplementationPeriod | |
.where('title ILIKE ?', "%#{params[:q]}%") | |
- .select('title as text, id') | |
+ .select("title || ' ' || coalesce(market, '') as text, id") |
diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb | |
index 7231f45..697d946 100644 | |
--- a/app/controllers/students_controller.rb | |
+++ b/app/controllers/students_controller.rb | |
@@ -3,6 +3,7 @@ class StudentsController < ApplicationController | |
before_filter :require_student_login, :only => %w[home profile update_profile support redirect_to_survey record_survey_result game] | |
before_filter :require_teacher_login, :only => %w[index new create edit update, :atwork_index] | |
+ before_filter :find_survey_by_slug, only: [:redirect_to_survey] | |
protect_from_forgery :except => :update_profile |
@keys = Activity.where(curriculum_id: Curriculum.ignition).pluck(:assessment_key).compact | |
# @activities = Activity.where(activity_type: 'module', curriculum_id: Curriculum.ignition).inject({}) {|memo, a| memo[a.id] = a; memo } | |
@activities = Activity.where(curriculum_id: 3).inject({}) {|memo, a| memo[a.assessment_key] = a; memo } | |
def fix_page(page, e, b, school) | |
if page && page['data'] && page['data']['correct'] && page['data']['total'] | |
grade = (page['data']['correct'] / page['data']['total'].to_f) * 100 | |
act = @activities[page['id']] | |
unless e.activity_progresses.any? {|ap| ap.activity_id == act.id && ap.grade == grade } | |
passed = grade >= @activities[act.id].try(:passing_grade).to_i | |
e.activity_progresses.create(activity_id: act.id, grade: grade, passed: passed) |
@keys = Activity.where(curriculum_id: 4).pluck(:assessment_key).compact | |
@activities = Activity.where(curriculum_id: 4).inject({}) {|memo, a| memo[a.assessment_key] = a; memo } | |
def fix_page(page, e, b, school) | |
if page && page['data'] && page['data']['correct'] && page['data']['total'] | |
grade = (page['data']['correct'] / page['data']['total'].to_f) * 100 | |
act = @activities[page['id']] | |
unless e.activity_progresses.select {|ap| ap.activity_id == act.id && ap.grade == grade }.any? | |
passed = grade >= act.try(:passing_grade).to_i |
$('head #missionStyles').remove(); | |
var css_href = "some/path/to.css"; | |
if (document.createStyleSheet) { | |
var $link = $("<link>"); | |
$link.appendTo($('head')) | |
.attr('id', 'missionStyles') | |
.attr({type : 'text/css', rel : 'stylesheet'}) | |
.attr('href', css_href); | |
} else { | |
$('head').append("<link id='missionStyles' rel='stylesheet' href='"+css_href+"' >"); |
desc 'backfill pre ass data' | |
task ass: :environment do | |
users = User.where{(created_at >= "2012-08-01".to_date) & (created_at <= "2012-09-10".to_date)} | |
.where(type: 'Users::K12Student').select(["users.*", "enrollments.id as enrollment_id"]) | |
.joins(enrollments: :cohort) | |
.includes(:bookmarks) | |
.where("cohorts.curriculum_id = ?", 5) | |
ids = Curriculum.fin_lit.activities.map(&:id) | |
@keys = ["aa010", "ba010", "ca010", "da010", "ia010", "ga010", "fa010", "ha010", "ea010"] |
require 'csv' | |
output = File.open('create_aps_flume.sql', 'w') | |
begin | |
CSV.foreach('bm_backfill.csv') do |row| | |
enrollment_id, user_id, activity_id, grade = row | |
sql = <<-SQL | |
INSERT INTO "activity_progresses" ("activity_id", "attempt", "created_at", "deleted_at", "enrollment_id", "grade", "passed", "status", "updated_at") | |
VALUES (#{activity_id}, 1, '2013-07-15 20:37:14', NULL, #{enrollment_id}, #{grade}, TRUE, NULL, '2013-07-15 20:37:14'); |
select master_districts.state as state, | |
COUNT(*) as num_s2_respondents | |
from enrollments, | |
cohorts, | |
schools, | |
response_sets, | |
master_schools, | |
master_districts | |
where cohorts.curriculum_id = 5 |