source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/dashboards_controller.rb
Ruby
mit
19
main
580
# frozen_string_literal: true class DashboardsController < ApplicationController before_action :set_dashboard_params, only: :index def index authorize :dashboard service = DashboardService.instance @dashboard = service.build_dashboard_for(@team, @duration) end private def set_dashboard_params...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/programs_controller.rb
Ruby
mit
19
main
6,096
# frozen_string_literal: true class ProgramsController < ApplicationController include PaginationConcern include SearchContextHelper before_action :set_learning_partner before_action :set_program, except: %i[new index explore create list choose] before_action :set_learner_mode, only: %i[show update add_cour...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/certificate_templates_controller.rb
Ruby
mit
19
main
2,135
# frozen_string_literal: true class CertificateTemplatesController < ApplicationController before_action -> { @active_nav = 'learning_partners' } before_action :set_learning_partner before_action :set_certificate_template, only: %i[update confirm_destroy destroy] def new authorize :certificate_template ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/materials_controller.rb
Ruby
mit
19
main
834
class MaterialsController < ApplicationController include CourseNavContext before_action :set_course def index end def create authorize @course, :update? all_materials = @course.materials.blobs + Array.wrap(materials_params[:materials]) if @course.update(materials: all_materials) flash[:su...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/course_assigns_controller.rb
Ruby
mit
19
main
2,290
# frozen_string_literal: true class CourseAssignsController < ApplicationController before_action -> { @active_nav = 'teams' } before_action :authorize_actions before_action :set_user_or_team include SearchContextHelper def new context = @team_assign ? SearchContext::TEAM_ASSIGN : SearchContext::USER_A...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/user_settings_controller.rb
Ruby
mit
19
main
4,363
# frozen_string_literal: true class UserSettingsController < ApplicationController before_action :set_user before_action :set_learning_partner def show authorize :user_settings end def edit authorize :user_settings end def update authorize :user_settings @user.update(profile_params) ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/certificates_controller.rb
Ruby
mit
19
main
504
# frozen_string_literal: true class CertificatesController < ApplicationController skip_before_action :authenticate_user! before_action :set_certificate def show if @certificate.present? redirect_to rails_blob_url(@certificate.certificate_thumbnail, disposition: "inline") else render "pages...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/quizzes_controller.rb
Ruby
mit
19
main
4,327
# frozen_string_literal: true class QuizzesController < ApplicationController include CommonsHelper include CourseNavContext before_action :set_course before_action :set_course_module before_action :set_quiz, only: %i[show edit update destroy submit_answer moveup movedown] def show authorize @quiz ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/embeds/videos_controller.rb
Ruby
mit
19
main
806
module Embeds class VideosController < ApplicationController include LessonsHelper skip_before_action :authenticate_user! before_action :set_local_content before_action :set_scorm after_action :allow_iframe def show if @scorm.present? && DateTime.now <= @scorm.expires_at @vide...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/webhooks/chatwoot_controller.rb
Ruby
mit
19
main
1,002
class Webhooks::ChatwootController < ApplicationController skip_before_action :verify_authenticity_token skip_before_action :authenticate_user! def create account_id = Rails.application.credentials.dig(:chatwoot, :account_id) unless params.dig(:account, :id).to_s == account_id.to_s return head :un...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/commons/alert_modal_controller.rb
Ruby
mit
19
main
410
class Commons::AlertModalController < ApplicationController def show @title = params[:title] @description = params[:description] @method = params[:method] @action_path = params[:action_path] @action_text = params[:action_text] || I18n.t(@method == 'delete' ? 'button.delete' : 'button.ok') @act...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/api/api_controller.rb
Ruby
mit
19
main
514
# frozen_string_literal: true class Api::ApiController < ActionController::API API_TOKEN = Rails.application.credentials.dig(:api_token) # this can be commented during development or local testing before_action :verify_auth_token! before_action :set_api_version private def set_api_version @api_versio...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/api/v1/otps_controller.rb
Ruby
mit
19
main
1,042
# frozen_string_literal: true module Api module V1 class OtpsController < ApiController before_action :set_phone_number def generate service = Auth::OtpService.new(@phone, name: generate_auth_params[:name]) if service.generate_otp render json: { success: true }, status: :ok...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/api/v1/courses_controller.rb
Ruby
mit
19
main
423
# frozen_string_literal: true module Api module V1 class CoursesController < ApiController def show course = Course.includes(:tags, course_modules: { lessons: :local_contents }) .find(params[:id]) render json: course.to_json_data, status: :ok rescue ActiveRecord::RecordNotFo...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/api/v1/one_timer_tasks_controller.rb
Ruby
mit
19
main
881
# frozen_string_literal: true module Api module V1 class OneTimerTasksController < ApiController before_action :load_rake_tasks TASKS = [:generate_course_ratings] def run_tasks results = [] TASKS.each do |task| if Rails.cache.read(task).blank? invoke_rake...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/lesson/ratings_controller.rb
Ruby
mit
19
main
899
class Lesson::RatingsController < ApplicationController before_action :set_course before_action :set_course_module before_action :set_lesson def new authorize @lesson, policy_class: LessonRatingPolicy end def create authorize @lesson, policy_class: LessonRatingPolicy service = Lessons::Rating...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/concerns/impersonation.rb
Ruby
mit
19
main
424
# frozen_string_literal: true module Impersonation extend ActiveSupport::Concern private def fetch_impersonated_user(id) REDIS_CLIENT.call("GET", "impersonated_support_user_#{id}") end def destroy_impersonation(id) REDIS_CLIENT.call("DEL", "impersonated_support_user_#{id}") end def store_impe...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/concerns/pagination_concern.rb
Ruby
mit
19
main
359
# frozen_string_literal: true module PaginationConcern def get_current_page(record:, page:, per_page_count: 10) current_page = page.to_i current_page = 1 if current_page.zero? courses = record.page(current_page).per(per_page_count) if courses.empty? && current_page > 1 current_page - 1 els...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/concerns/handle_not_found.rb
Ruby
mit
19
main
543
module HandleNotFound extend ActiveSupport::Concern included do rescue_from ActiveRecord::RecordNotFound, with: :not_found rescue_from ActionController::UnknownFormat, with: :not_found before_action :set_default_format, only: [:not_found] def not_found if request.format != :html ren...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/concerns/user_onboarding.rb
Ruby
mit
19
main
372
# frozen_string_literal: true # module UserOnboarding extend ActiveSupport::Concern included do before_action :proceed_to_onboarding_steps, if: :pending_onboarding? private def proceed_to_onboarding_steps redirect_to new_onboarding_welcome_path end def pending_onboarding? user_si...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/concerns/course_associations_preloader.rb
Ruby
mit
19
main
827
module CourseAssociationsPreloader extend ActiveSupport::Concern private def preload_course_associations available_courses = [] enrolled_courses = [] if @type.nil? || @type == "all" available_courses = @available_courses.present? ? @available_courses.to_a : [] end if @type.nil? || @...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/concerns/search_context_helper.rb
Ruby
mit
19
main
1,029
module SearchContextHelper extend ActiveSupport::Concern private def build_search_context(context: nil, resource: nil) options = {} context = (context || search_params[:context]).to_sym case context when SearchContext::TEAM_ASSIGN then options[:team] = resource || Team.find(search_params...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/users/sessions_controller.rb
Ruby
mit
19
main
738
# frozen_string_literal: true class Users::SessionsController < Devise::SessionsController before_action :configure_sign_in_params, only: [:create] before_action :authenticate_user!, only: [:destroy] def create super do if resource.errors.empty? EVENT_LOGGER.publish_user_login(resource, 'passw...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/users/confirmations_controller.rb
Ruby
mit
19
main
251
# frozen_string_literal: true class Users::ConfirmationsController < Devise::ConfirmationsController def show super do |resource| if resource.errors.empty? EVENT_LOGGER.publish_email_verified(resource) end end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/controllers/onboarding/welcomes_controller.rb
Ruby
mit
19
main
1,881
# frozen_string_literal: true class Onboarding::WelcomesController < ApplicationController layout 'onboarding' skip_before_action :proceed_to_onboarding_steps before_action :skip_onboarding_for_active_users, except: :all_set def new end def set_name_and_email render turbo_stream: turbo_stream.replace...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/mailers/user_mailer.rb
Ruby
mit
19
main
844
# frozen_string_literal: true class UserMailer < ApplicationMailer include CommonsHelper layout 'mailer' def course_assignment(user, assigned_by, course) @user = user @assigned_by = assigned_by @course = course return if email_disabled_for?(@user) mail( to: @user.email, subjec...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/team_report_query.rb
Ruby
mit
19
main
589
# frozen_string_literal: true class TeamReportQuery < AppQuery def initialize(partner_id, duration, user_ids) super(partner_id, duration) @user_ids = user_ids end def call run_query do query = Event.where( name: event_names, partner_id: @partner_id, user_id: @user_ids ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/course_completed_query.rb
Ruby
mit
19
main
312
# frozen_string_literal: true class CourseCompletedQuery < AppQuery def call run_query do query = Event.where( name: 'course_completed', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/course_started_query.rb
Ruby
mit
19
main
308
# frozen_string_literal: true class CourseStartedQuery < AppQuery def call run_query do query = Event.where( name: 'course_started', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/user_invited_query.rb
Ruby
mit
19
main
304
# frozen_string_literal: true class UserInvitedQuery < AppQuery def call run_query do query = Event.where( name: 'user_invited', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/app_query.rb
Ruby
mit
19
main
533
# frozen_string_literal: true require 'utilities/tracing' class AppQuery include Utilities::Tracing attr_reader :results, :executed def initialize(partner_id, duration) @partner_id = partner_id @duration = duration @results = [] @executed = false end def run_query # queries will be ru...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/onboarding_initiated_query.rb
Ruby
mit
19
main
408
# frozen_string_literal: true class OnboardingInitiatedQuery < AppQuery def call run_query do query = Event.where( name: 'onboarding_initiated' ).order(:id) # partner id is optional for this query query = query.where(partner_id: @partner_id) if @partner_id.present? query = ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/user_login_query.rb
Ruby
mit
19
main
300
# frozen_string_literal: true class UserLoginQuery < AppQuery def call run_query do query = Event.where( name: 'user_login', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/time_spent_query.rb
Ruby
mit
19
main
309
# frozen_string_literal: true class TimeSpentQuery < AppQuery def call run_query do query = Event.where( name: 'learning_time_spent', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/first_owner_joined_query.rb
Ruby
mit
19
main
314
# frozen_string_literal: true class FirstOwnerJoinedQuery < AppQuery def call run_query do query = Event.where( name: 'first_user_joined', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/lesson_views_query.rb
Ruby
mit
19
main
305
# frozen_string_literal: true class LessonViewsQuery < AppQuery def call run_query do query = Event.where( name: 'lesson_viewed', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/course_views_query.rb
Ruby
mit
19
main
305
# frozen_string_literal: true class CourseViewsQuery < AppQuery def call run_query do query = Event.where( name: 'course_viewed', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/user_enrolled_query.rb
Ruby
mit
19
main
398
# frozen_string_literal: true # Count total number of enrolled users for a particular partner for all available courses class UserEnrolledQuery < AppQuery def call run_query do query = Event.where( name: 'course_enrolled', partner_id: @partner_id ).order(:id) query = query.wher...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/user_logout_query.rb
Ruby
mit
19
main
302
# frozen_string_literal: true class UserLogoutQuery < AppQuery def call run_query do query = Event.where( name: 'user_logout', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/queries/user_joined_query.rb
Ruby
mit
19
main
302
# frozen_string_literal: true class UserJoinedQuery < AppQuery def call run_query do query = Event.where( name: 'user_joined', partner_id: @partner_id ).order(:id) query = query.where(created_at: @duration) if @duration.present? query end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/course_deadline_reminder_job.rb
Ruby
mit
19
main
610
# frozen_string_literal: true class CourseDeadlineReminderJob < BaseJob def perform enrollments = Enrollment.where(deadline_at: Time.zone.now..3.days.from_now) enrollments.each do |enrollment| # send at most one email per day, kept 1 hours as buffer for any retries if enrollment.reminder_send_at...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/extract_and_save_audio_job.rb
Ruby
mit
19
main
932
# frozen_string_literal: true class ExtractAndSaveAudioJob < BaseJob include CommonsHelper def perform(local_content_id) with_tracing "local_content_id=#{local_content_id}" do local_content = LocalContent.find_by(id: local_content_id) return false if local_content.nil? || local_content.video.blank...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/delete_video_from_vimeo_job.rb
Ruby
mit
19
main
250
# frozen_string_literal: true class DeleteVideoFromVimeoJob < BaseJob def perform(url) with_tracing "url=#{url}" do return if url.nil? service = Vimeo::DeleteVideoService.instance service.delete_video(url) end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/lesson_rating_job.rb
Ruby
mit
19
main
262
# frozen_string_literal: true class LessonRatingJob < BaseJob def perform Rails.logger.info "Starting LessonRatingJob at #{Time.current}" service = Lessons::RatingService.instance service.calculate_ratings(date: Date.yesterday.all_day) end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/course_rating_job.rb
Ruby
mit
19
main
217
# frozen_string_literal: true class CourseRatingJob < BaseJob def perform Rails.logger.info "Starting CourseRatingJob at #{Time.current}" service = Courses::RatingService.new service.process end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/generate_report_job.rb
Ruby
mit
19
main
677
# frozen_string_literal: true class GenerateReportJob < BaseJob sidekiq_options retry: false def perform(report_id) with_tracing "report-#{report_id}" do @report = Report.find report_id Reporting::TeamReportService.new(@report).generate notify_user end end def notify_user return...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/transcribe_content_audio_job.rb
Ruby
mit
19
main
529
# frozen_string_literal: true class TranscribeContentAudioJob < BaseJob def perform(local_content_id) with_tracing "local_content_id=#{local_content_id}" do local_content = LocalContent.find(local_content_id) service = AudioTranscriptionService.instance result = service.transcribe(local_conten...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/generate_questions_job.rb
Ruby
mit
19
main
2,275
# frozen_string_literal: true class GenerateQuestionsJob < BaseJob include CommonsHelper def perform(course_id, user_id, notification_link) return if course_id.blank? || user_id.blank? course = Course.find(course_id) user = User.find(user_id) saved_count = 0 prev_question_ids = course.questio...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/upload_video_to_vimeo_job.rb
Ruby
mit
19
main
328
# frozen_string_literal: true class UploadVideoToVimeoJob < BaseJob def perform(id, local_content_id) with_tracing "blob_id=#{id}" do return if id.nil? file = ActiveStorage::Blob.find(id) service = Vimeo::UploadVideoService.instance service.upload_video(file, local_content_id) end ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/generate_course_certificate_job.rb
Ruby
mit
19
main
489
# frozen_string_literal: true class GenerateCourseCertificateJob < BaseJob def perform(course_id, user_id, certificate_template_id) return if course_id.blank? || user_id.blank? || certificate_template_id.blank? course = Course.find(course_id) user = User.find(user_id) certificate_template = Certific...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/communication_channels/send_whatsapp_message_job.rb
Ruby
mit
19
main
434
# frozen_string_literal: true module CommunicationChannels class SendWhatsappMessageJob < BaseJob def perform(template, mobile_number, parameters) return unless mobile_number.present? || template.present? updated_mobile = "91#{mobile_number}" whatsapp_channel = CommunicationChannels::Whatsapp:...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/jobs/communication_channels/send_sms_job.rb
Ruby
mit
19
main
1,063
# frozen_string_literal: true module CommunicationChannels class SendSmsJob < BaseJob def perform(template, mobile_number, country_code, variables_values) return if template.blank? || mobile_number.blank? country_config = AVAILABLE_COUNTRIES.values.find { |c| c[:code] == country_code } return ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/home_page_service.rb
Ruby
mit
19
main
1,452
# frozen_string_literal: true class HomePageService include Singleton CONFIG = { banner: { enabled: false, order: 0 }, programs: { enabled: true, order: 1 }, continue: { enabled: true, order: 2 }, categories: { enabled: true, order: 3, tags: [] } }.freeze def build_data_for(user) data = {...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/user_statistics_service.rb
Ruby
mit
19
main
485
# frozen_string_literal: true class UserStatisticsService include Singleton UserStatistics = Struct.new(:no_courses_enrolled, :total_time_spent, :user_score) def build_stats_for(user) no_courses_enrolled = user.enrollments.size total_time_spent = user.enrollments.map(&:time_spent).reduce(:+) || 0 # time...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/partner_onboarding_service.rb
Ruby
mit
19
main
694
# frozen_string_literal: true class PartnerOnboardingService include Singleton def create_partner(partner, team_management = TeamManagementService.instance) ActiveRecord::Base.transaction do success = partner.save return unless success team = Team.new(name: partner.name) success = te...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/user_channel_notifier_service.rb
Ruby
mit
19
main
939
# frozen_string_literal: true class UserChannelNotifierService include Singleton def notify_user(user, template, parameters = nil) return if template.nil? user.communication_channels.each do |channel| dispatch_job(template, user, channel, parameters) end end def notify_via_sms(template, co...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/ffmpeg_service.rb
Ruby
mit
19
main
784
# frozen_string_literal: true class FfmpegService include Singleton def extract_audio(input_path) raise ArgumentError, 'Input path is required' if input_path.blank? raise ArgumentError, 'Input file does not exist' unless File.exist?(input_path) raise ArgumentError, 'Input file is not readable' unless F...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/event_service.rb
Ruby
mit
19
main
6,773
# frozen_string_literal: true class EventService include Singleton # Events are simply published into database. def publish_event(user, event_data) # A UUID might be need to avoid event duplication when moving to # a queue based system event = build_event(user, event_data) begin publish_ev...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/team_management_service.rb
Ruby
mit
19
main
246
# frozen_string_literal: true class TeamManagementService include Singleton def create_team(team, partner) team.learning_partner = partner team.save end def update_team(team, team_params) team.update(team_params) end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/create_certificate_template_service.rb
Ruby
mit
19
main
2,715
# frozen_string_literal: true class CreateCertificateTemplateService include Singleton include Rails.application.routes.url_helpers def generate(learning_partner, params) template = learning_partner.certificate_templates.build(name: params[:name]) return template if template.name.blank? || params[:temp...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/vimeo_service.rb
Ruby
mit
19
main
2,683
# frozen_string_literal: true require 'net/http' require 'json' class VimeoService include Singleton BASE_URL = 'https://vimeo.com/api/oembed.json' # Example success response # { # "type": "video", # "version": "1.0", # "provider_name": "Vimeo", # "provider_url": "https://vimeo.com/", # ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/login_with_otp_service.rb
Ruby
mit
19
main
721
# frozen_string_literal: true class LoginWithOtpService include Singleton def generate_and_send_otp(user) user.set_otp! return unless Rails.env.production? parameters = { sms_variables_values: { 'var1' => password_decrypter(user.otp) } } service = UserChannelNotifierService.instance service....
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/audio_transcription_service.rb
Ruby
mit
19
main
345
# frozen_string_literal: true class AudioTranscriptionService include Singleton include CommonsHelper def transcribe(audio) raise StandardError, 'Audio file is not attached' if audio.blank? audio.open do |file| return Integrations::Llm::Api.llm_instance(provider: :gemini).generate_transcript(file...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/bulk_invite_input_service.rb
Ruby
mit
19
main
863
# frozen_string_literal: true require 'csv' class BulkInviteInputService include Singleton def process(file_input, country_iso) return [] unless file_input.respond_to? :read return [] unless ['text/csv', 'text/plain'].include?(file_input.content_type) parse_csv(file_input.read, country_iso) rescue...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/user_management_service.rb
Ruby
mit
19
main
3,032
# frozen_string_literal: true class UserManagementService include Singleton def invite(invited_by_user, params, team) raise_error_if_exceeds_user_limit!(team.learning_partner) user = User.new( name: params[:name], phone: params[:phone], role: params[:role], country_code: params[:c...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/notification_service.rb
Ruby
mit
19
main
2,161
# frozen_string_literal: true require 'utilities/queue_client' class NotificationService include Singleton QUEUE_CLIENT = Utilities::QueueClient.new(REDIS_CLIENT) # each user may have at most 25 latest notification at a time MAX_NOTIFICATION_LIMIT = 25 def self.notify(user, title, text, link: nil, ntype:...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/app_config_service.rb
Ruby
mit
19
main
358
# frozen_string_literal: true class AppConfigService include Singleton CONFIG = Rails.application.config_for(:app_config).with_indifferent_access def external_video_hosting? CONFIG[:external_video_hosting] end def sidekiq_auth_enabled? CONFIG[:sidekiq_auth_enabled] end def chatwoot_enabled? ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/auth/otp_service.rb
Ruby
mit
19
main
1,988
# frozen_string_literal: true module Auth class OtpService MAX_ATTEMPTS = 2 def initialize(phone, name: nil) @phone = phone @name = name @data = {} end def cache_key "otp:#{@phone.value}" end def generate_otp return false unless @phone.valid? read_previ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/questions/generation_service.rb
Ruby
mit
19
main
1,204
# frozen_string_literal: true module Questions class GenerationService include CommonsHelper attr_accessor :course, :transcripts, :course_materials MAX_QUESTIONS = 30 def initialize(course) @course = course @transcripts = summarized_transcripts @course_materials = @course.materia...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/vimeo/delete_video_service.rb
Ruby
mit
19
main
617
# frozen_string_literal: true module Vimeo class DeleteVideoService include Singleton def delete_video(url) video_id = url.match(%r{vimeo\.com/(\d+)})[1] create_request(video_id) end private def create_request(video_id) url = URI.parse("https://api.vimeo.com/videos/#{video_id...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/vimeo/upload_video_service.rb
Ruby
mit
19
main
2,479
# frozen_string_literal: true require 'uri' require 'open-uri' require 'tempfile' module Vimeo class UploadVideoService include Singleton def upload_video(file, local_content_id) local_content = LocalContent.find(local_content_id) response = generate_upload_url(file) unless response.is_...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/reporting/team_report_service.rb
Ruby
mit
19
main
5,614
# frozen_string_literal: true require 'csv' module Reporting class TeamReportService NAME = 'Name' COURSE = 'Course' COMPLETION = '% of completion' DOE = 'Date of enrollment' DOC = 'Date of completion' DAYS = 'Days spent' ROLE = 'User role' TEAM_NAME = 'Team' MINUTES = 'Time spen...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/teams/update_total_members_count_service.rb
Ruby
mit
19
main
338
# frozen_string_literal: true module Teams class UpdateTotalMembersCountService include Singleton def update_count(team) return unless team total = team.members.size + team.sub_teams.sum(&:total_members_count) team.update!(total_members_count: total) update_count(team.parent_team) ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/quizzes/generation_service.rb
Ruby
mit
19
main
1,349
# frozen_string_literal: true module Quizzes class GenerationService include CommonsHelper attr_accessor :course_module, :transcripts MAX_QUIZ_QUESTIONS = 5 def initialize(course_module) @course_module = course_module @transcripts = summarized_transcripts end def generate_via_...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/filter_service.rb
Ruby
mit
19
main
3,991
# frozen_string_literal: true module Courses class FilterService attr_reader :user, :search_context def initialize(user, search_context) @user = user @search_context = search_context @result = nil raise Errors::IllegalSearchContext, 'Search context is blank' if user.blank? || search_...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/program_enrollment_service.rb
Ruby
mit
19
main
574
# frozen_string_literal: true module Courses class ProgramEnrollmentService def initialize(user, program) @user = user @program = program end def enroll! service = Courses::ManagementService.instance ActiveRecord::Base.transaction do @program.program_users.create!(user: ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/filter_adapter.rb
Ruby
mit
19
main
1,869
# frozen_string_literal: true module Courses class FilterAdapter include Singleton def filter_courses(user, tags, term = '', type = '') type = type.blank? ? :all : type.to_sym search_context = SearchContext.new(context: :course_listing, tags:, term:, type:) if user.is_admin? searc...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/rating_service.rb
Ruby
mit
19
main
649
# frozen_string_literal: true module Courses class RatingService def process Course.includes(course_modules: :lessons).find_each do |course| lessons = course.course_modules.flat_map do |mod| mod.lessons.select { |lesson| lesson.last_rated_at.present? } end next if lessons...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/course_form_steps.rb
Ruby
mit
19
main
662
# frozen_string_literal: true module Courses class CourseFormSteps STEP_ONE = 1 STEP_TWO = 2 STEP_ONE_FIELDS = %i[title category_id level_id].freeze STEP_TWO_FIELDS = %i[description banner visibility].freeze def self.error_step_for(course) return STEP_ONE if step_one_error?(course) ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/generate_certificate_service.rb
Ruby
mit
19
main
3,437
# frozen_string_literal: true module Courses class GenerateCertificateService include Singleton include Rails.application.routes.url_helpers def generate(course, user, certificate_template) existing_certificate = user.course_certificates.find_by(course: course) return if existing_certificate...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/search_result.rb
Ruby
mit
19
main
303
# frozen_string_literal: true module Courses class SearchResult def initialize(results, search_context) @results = results @search_context = search_context end def records @results end delegate :count, to: :@results def size count end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/courses/management_service.rb
Ruby
mit
19
main
8,153
# frozen_string_literal: true module Courses class ManagementService include Singleton include Errors include Rails.application.routes.url_helpers def enroll!(user, course, assigned_by = nil, deadline = nil) # Enrolling to an unpublished course is unacceptable unless course.published? ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/assessments/update_service.rb
Ruby
mit
19
main
1,685
# frozen_string_literal: true module Assessments class UpdateService NEXT = 'Next' PREVIOUS = 'Previous' SAVE = 'Save' SAVE_AND_NEXT = 'Save and Next' SKIP_AND_NEXT = 'Skip and Next' SAVE_AND_SUBMIT = 'Save and Submit' ACTIONS = { next: NEXT, previous: PREVIOUS, ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/assessments/presenter_service.rb
Ruby
mit
19
main
1,932
# frozen_string_literal: true module Assessments class PresenterService SMALL_DEVICE_NAVIGATION_COLS = 5 STATUS = { current: :current, answered: :answered, not_answered: :not_answered, skipped: :skipped }.freeze attr_reader :assessment def initialize(assessment) @assessment = assessment ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/impersonations/find_or_create_support_user_service.rb
Ruby
mit
19
main
969
# frozen_string_literal: true module Impersonations class FindOrCreateSupportUserService include Singleton def find_or_create_user(learning_partner) support_user = learning_partner.users.find_by(role: 'support') return support_user if support_user.present? generated_password = password ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/lessons/post_processing_service.rb
Ruby
mit
19
main
452
# frozen_string_literal: true module Lessons class PostProcessingService include Singleton def process_local_contents(local_contents) local_contents.each do |content| next unless content.video.attached? UploadVideoToVimeoJob.perform_async(content.video.blob.id, content.id) if APP_CONF...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/lessons/update_service.rb
Ruby
mit
19
main
274
# frozen_string_literal: true module Lessons class UpdateService include Singleton def update_lesson!(lesson, lesson_params) lesson.update!(lesson_params) PostProcessingService.instance.process_local_contents(lesson.local_contents) end end end
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/lessons/create_service.rb
Ruby
mit
19
main
510
# frozen_string_literal: true module Lessons class CreateService include Singleton def create_lesson!(lesson_params, course_module) lesson = course_module.lessons.create!(lesson_params) service = Courses::ManagementService.instance service.update_lesson_ordering!(course_module, lesson, :cr...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/lessons/rating_service.rb
Ruby
mit
19
main
1,568
# frozen_string_literal: true module Lessons class RatingService include Singleton DISCOUNTED_FACTOR = 0.8 DIMINISHING_WINDOW = 30 EPSILON = 0.5 def rate_lesson!(user, lesson, rating) return if rating.nil? || rating <= 0 EVENT_LOGGER.publish_lesson_rating(user, lesson, rating) ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/users/filter_service.rb
Ruby
mit
19
main
611
# frozen_string_literal: true module Users class FilterService attr_accessor :team, :term def initialize(team, term: '', all_members: false) # all_members = true include deactivated members in results @all_members = all_members @team = team @term = term end def filter ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/learning_partners/search_service.rb
Ruby
mit
19
main
394
# frozen_string_literal: true module LearningPartners class SearchService attr_reader :query def initialize(query) @query = query end def search scope = LearningPartner.includes(%i[logo_attachment payment_plan]).order(:name) return scope if query.blank? scope.where('name IL...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/learning_partners/learning_partner_form_steps.rb
Ruby
mit
19
main
953
# frozen_string_literal: true module LearningPartners class LearningPartnerFormSteps STEP_ONE = 1 STEP_TWO = 2 STEP_THREE = 3 STEP_ONE_FIELDS = %i[name about supported_countries organisation_type].freeze STEP_TWO_FIELDS = %i[logo banner].freeze def self.error_step_for(learning_partner) ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/services/webhooks/chatwoot_notifier_service.rb
Ruby
mit
19
main
1,338
# frozen_string_literal: true module Webhooks class ChatwootNotifierService include Singleton include CommonsHelper def notify(params) return if params.empty? text = params.dig('conversation', 'messages').first['content'] llm_response = Integrations::Llm::Api.llm_instance(provider: :...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/channels/application_cable/connection.rb
Ruby
mit
19
main
395
# frozen_string_literal: true module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user end private def find_verified_user if (verified_user = env['warden'].user) verified_user ...
github
openvitae-tech/blackboard-lms
https://github.com/openvitae-tech/blackboard-lms
app/domain/record_ordering.rb
Ruby
mit
19
main
322
# frozen_string_literal: true module RecordOrdering def self.records_in_order(records, order) # sorts a list of records as per the order defined in order array # record in records must respond to :id h = {} order.each { |o| h[o] = nil } records.each { |rec| h[rec.id] = rec } h.values end en...
github
cookpad/denv
https://github.com/cookpad/denv
reload_env_test.rb
Ruby
mit
19
master
842
lib = File.expand_path('../lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'denv' require 'fileutils' FileUtils.rm_rf('tmp') FileUtils.mkdir_p('tmp') Dir.chdir('tmp') do ENV['INIT'] = '1' File.write('.env', "XXX=1\nYYY=2\n") Denv.load raise('Necessary keys are removed') unless E...
github
cookpad/denv
https://github.com/cookpad/denv
Rakefile
Ruby
mit
19
master
632
require "bundler/gem_tasks" task :default => :test begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) rescue LoadError end desc 'Run all tests' task :test do Rake::Task[:spec].invoke Rake::Task[:reload_env_test].invoke Rake::Task[:integration_test].invoke end desc 'Run Rails integration ...
github
cookpad/denv
https://github.com/cookpad/denv
denv.gemspec
Ruby
mit
19
master
1,077
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'denv/version' Gem::Specification.new do |spec| spec.name = 'denv' spec.version = Denv::VERSION spec.authors = ['Taiki Ono'] spec.email = ['taiks.4559@gmail.com'] spec.summ...
github
cookpad/denv
https://github.com/cookpad/denv
rails_integration_test.rb
Ruby
mit
19
master
1,087
require 'fileutils' name = 'denv_test' path = File.expand_path(__dir__) system('bundle install -j8') FileUtils.rm_rf('tmp') FileUtils.mkdir_p('tmp') Dir.chdir('tmp') do system("bundle exec rails new #{name} --skip-bundle") Dir.chdir(name) do lines = File.read('Gemfile').split("\n") new = lines.first(1) + ...
github
cookpad/denv
https://github.com/cookpad/denv
lib/denv.rb
Ruby
mit
19
master
2,637
require "denv/version" module Denv class Error < StandardError end class NoSuchFileError < Error def initialize(filename) super("Can not find envfile: #{filename}") end end class InvalidFormatError < Error def initialize(line, filename, lineno) super("key and value must be separated...