'7_1_7' :activities: - tutorial_text: instructions: - Read and listen to the word list and the tutorial about technical language. sentences: - ! 'In the text Exposed: the tattoo sleeve, the writer has used some words that we don''t use in everyday conversation; for example, dermis, which means the second-deepest layer of the skin.' - Two other words in the list are usually only used in medical or health situations. An autoclave is a sterilising device and antibacterial describes something that kills bacteria. - Some words can be used in everyday conversations but have specialised meanings. Sterilised means treated to kill germs and tattoo means a pattern or picture marked in ink on the skin. Words like dermis, sterilised, autoclave, antibacterial and tattoo are called specialised or technical language. words: - tattoo - sterilised - autoclave - dermis - antibacterial show_instructions: - Are these statements TRUE or FALSE? statements: - All the words in the word list are technical words used to talk about the specialised topic of tattooing. - A technical word is a word not usually used in everyday conversations about general topics. - Sterilised is a word often used in everyday conversation. answers: - true - true - false explanations: - False; sterilised is used in scientific or technical contexts.
This baby lets us get that yaml data in a ruby'esk way class BlakeModel < OpenStruct module Methods def initialize(id, locale='au') @id, @locale = id, locale # this calls super to make all ze methods super(data) end private # This grabs the data from BlakeDataSource and mimics a # rails like interface that we can interact with and # expect things to fail gracefully def data if id && data = data_yaml data else raise(ActiveRecord::RecordNotFound) end end def data_yaml file_path = "word_flyers/#{category.pluralize}/au/#{id}" BlakeDataSource::YmlLoader.new(file_path).data end end end
Lesson < BlakeModel attr_reader :unit self.category = 'lesson' def activities data[:activities].map.with_index do |conf, index| # name, position, data, lesson_id Activity.new(conf.keys.first, (index + 1), conf.values.first, self.id) end end def activity(index) return if index == 0 activities[index-1] end def unit @unit ||= Unit.find(self.unit_id) end end
an extension module. config.to_prepare do Dir.entries("app/extensions") .select{ |f| !File.directory? f} .each do |file_name| array = file_name.split("_") array.pop klass_name = array.map(&:capitalize).join klass = klass_name.constantize klass.class_eval do include "#{klass}Extensions".constantize end end end
end def address [street, suburb, state, postcode, country].join(', ') end def all_students_except_from(obj) students.active.where.not(id: obj.student_ids) end def all_students_except(student_id) students.active.where("users.id <> ?", student_id) end module ClassMethods end end
Composition properties [:first_name, :last_name, :email, :chat_disabled], on: :student properties [:school_grade, :grade_level, :locale, :country], on: :profile model :student validates :first_name, :last_name, :email, presence: true end end
end def create form = create_new_form if form.validate(params) form.save do |data, map| # do whatever you want with data # -- we aren't doing this exactly.. # but something similar student = Student.create(map[:student]) profile = StudentProfile.create(map[:profile]) respond_with student end else render :new end end private def create_new_form Forms::StudentForm.new(student: Student.new, profile: StudentProfile.new) end end
attr_reader :file, :school, :school_class def initialize(file, school, school_class=nil) @file, @school, @school_class = file, school, school_class end def call CSV.foreach(file.path, headers: true) do |row| form = build_form if form.validate(row.to_hash) form.save do |data, map| student = Service::ManageStudent.new(map[:student].merge(map[:profile]), school.id).create school_class.students << student if school_class end end end end private def build_form Forms::StudentForm.new(student: school.students.new, profile: StudentProfile.new) end end end
show @lesson = lesson_session.lesson @activity = Activity.find(params[:activity_id]) @unit = @lesson.unit end private def ensure_policy if Policy::Activity.new( current_student, lesson_session, params[:activity_id] ).not_allowed? redirect_to activity_path(lesson_session.id, lesson_session.current_activity_id) end end def lesson_session @lesson_session ||= LessonSession.find(params[:id]) end end
business logic for these badge rewards class WorldTravellerQualifier def self.valid?(student, badge) # North America, South America, Europe, # Asia, Africa, Australia, Antarctica. StudentPurchase.new(student).locations .map(&:continent).uniq.size == 7 end end class BusyWeekQualifier extend PurchasedLocationCalc def self.valid?(student, badge) purchased_locations_for_timeframe(student) == 5 end end
|badge| ::BadgeQualifier.new(student, badge).award end class BadgeQualifier def initialize(student, badge) @student, @badge = student, badge end def award _award if not_awarded? && valid? end def valid? "#{badge.qualifier_type.classify}Qualifier" .constantize.valid?(student, badge) end private attr_reader :student, :badge def not_awarded? !student.badges.include?(badge) end def _award student.achievements.create!(badge_id: badge.id) end end
than once. • A LessonSession is a single attempt at completing a lesson. • A student can have many lesson sessions for a single lesson. • The system uses their best lesson session to compute score / correctness.
create lesson_session .process_attempts(params[:attempts].values) head :created, location: redirect_url end private def lesson_session @lesson_session ||= LessonSession .find(params[:lesson_session_id]) end end