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/value_objects/scorm_service/lesson.rb | Ruby | mit | 19 | main | 699 | # frozen_string_literal: true
module ScormService
class Lesson < ScormPackage::BaseLesson
attr_reader :lesson, :scorm_token
def initialize(lesson, scorm_token)
super()
@lesson = lesson
@scorm_token = scorm_token
end
delegate :title, to: :lesson
def videos
lesson.local_c... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/errors/errors.rb | Ruby | mit | 19 | main | 446 | # frozen_string_literal: true
module Errors
class InvalidEnrollmentError < StandardError; end
class IllegalAccessError < StandardError; end
class IllegalInviteError < StandardError; end
class InvalidNotificationType < StandardError; end
class IllegalUserState < StandardError; end
class IllegalPartnerState ... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/report_policy.rb | Ruby | mit | 19 | main | 295 | # frozen_string_literal: true
class ReportPolicy
attr_reader :user, :report
def initialize(user, report)
@user = user
@report = report
end
def new?
user.privileged_user?
end
def create?
user.privileged_user?
end
def show?
user.privileged_user?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/course_assigns_policy.rb | Ruby | mit | 19 | main | 307 | # frozen_string_literal: true
class CourseAssignsPolicy
attr_reader :user, :course
def initialize(user, course)
@user = user
@course = course
end
def new?
user.privileged_user?
end
def create?
user.privileged_user?
end
def load_more?
user.privileged_user?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/course_module_policy.rb | Ruby | mit | 19 | main | 598 | # frozen_string_literal: true
class CourseModulePolicy
attr_reader :user, :course_module
def initialize(user, record)
@user = user
@course_module = record
end
def new?
user.is_admin?
end
def show?
user.is_admin?
end
def create?
user.is_admin?
end
def update?
user.is_adm... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/payment_plan_policy.rb | Ruby | mit | 19 | main | 455 | # frozen_string_literal: true
class PaymentPlanPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def new?
user.is_admin? && record.payment_plan.blank?
end
def create?
user.is_admin? && record.payment_plan.blank?
end
def show?
user.i... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/assessment_policy.rb | Ruby | mit | 19 | main | 368 | # frozen_string_literal: true
class AssessmentPolicy
attr_reader :user, :assessment
def initialize(user, record)
@user = user
@assessment = record
end
def show?
user == @assessment.user
end
def update?
user == @assessment.user
end
def retry?
user == @assessment.user
end
def... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/course_policy.rb | Ruby | mit | 19 | main | 1,587 | # frozen_string_literal: true
class CoursePolicy
include CourseVisibilityHelper
attr_reader :user, :course
def initialize(user, course)
@user = user
@course = course
end
def index?
user.present?
end
def continue?
!user.is_admin?
end
def complete?
!user.is_admin?
end
def ... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/issue_policy.rb | Ruby | mit | 19 | main | 243 | # frozen_string_literal: true
class IssuePolicy
attr_reader :user, :issue
def initialize(user, record)
@user = user
@issue = record
end
def new?
user == @issue.user
end
def create?
user == @issue.user
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/team_policy.rb | Ruby | mit | 19 | main | 691 | # frozen_string_literal: true
class TeamPolicy
attr_reader :user, :team
def initialize(user, record)
@user = user
@team = record
end
def new?
user.privileged_user?
end
def show?
user.privileged_user? && user_included_in_subteam?
end
def create?
user.privileged_user? && user_incl... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/scorm_policy.rb | Ruby | mit | 19 | main | 276 | # frozen_string_literal: true
class ScormPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@scorm = record
end
def new?
user.is_admin?
end
def create?
user.is_admin?
end
def download?
user.is_admin?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/question_policy.rb | Ruby | mit | 19 | main | 524 | # frozen_string_literal: true
class QuestionPolicy
attr_reader :user, :question
def initialize(user, record)
@user = user
@question = record
end
def index?
user.is_admin?
end
def new?
user.is_admin?
end
def create?
user.is_admin?
end
def generate?
user.is_admin?
end
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/invite_policy.rb | Ruby | mit | 19 | main | 745 | # frozen_string_literal: true
class InvitePolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def new?
user.is_admin? || user.privileged_user?
end
def new_admin?
user.is_admin?
end
def create?
return true if user.is_admin? && record.l... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/user_settings_policy.rb | Ruby | mit | 19 | main | 864 | # frozen_string_literal: true
class UserSettingsPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def show?
user.present?
end
def edit?
user.present?
end
def update?
user.present?
end
def change_password?
user.present?
en... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/certificate_template_policy.rb | Ruby | mit | 19 | main | 418 | # frozen_string_literal: true
class CertificateTemplatePolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def new?
user.is_admin?
end
def index?
user.is_admin?
end
def create?
user.is_admin?
end
def update?
user.is_admin?
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/quiz_policy.rb | Ruby | mit | 19 | main | 756 | # frozen_string_literal: true
class QuizPolicy
attr_reader :user, :quiz
def initialize(user, record)
@user = user
@quiz = record
end
def new?
user.is_admin?
end
def show?
user.is_admin? || user.enrolled_for_course?(quiz.course_module.course)
end
def create?
user.is_admin?
end
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/tag_policy.rb | Ruby | mit | 19 | main | 426 | # frozen_string_literal: true
class TagPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@tag = record
end
def new?
user.is_admin?
end
def index?
user.is_admin?
end
def show?
user.is_admin?
end
def create?
user.is_admin?
end
def update?
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/my_profile_policy.rb | Ruby | mit | 19 | main | 507 | # frozen_string_literal: true
class MyProfilePolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def show?
user.is_learner? || user.is_manager? || user.is_owner?
end
def share_certificate?
user.is_learner? || user.is_manager? || user.is_owner?... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/lesson_rating_policy.rb | Ruby | mit | 19 | main | 244 | # frozen_string_literal: true
class LessonRatingPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def new?
!user.is_admin?
end
def create?
!user.is_admin?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/program_policy.rb | Ruby | mit | 19 | main | 934 | # frozen_string_literal: true
class ProgramPolicy
attr_reader :user, :program
def initialize(user, record)
@user = user
@program = record
end
def index?
user.privileged_user?
end
def explore?
user.not_admin?
end
def new?
user.privileged_user?
end
def create?
user.privil... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/user_policy.rb | Ruby | mit | 19 | main | 1,360 | # frozen_string_literal: true
class UserPolicy
attr_reader :user, :other_user
def initialize(user, other_user)
@user = user
@other_user = other_user
end
def show?
user.manager_of?(other_user)
end
def deactivate?
other_user.active? && user.manager_of?(other_user)
end
def confirm_deac... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/learning_partner_policy.rb | Ruby | mit | 19 | main | 724 | # frozen_string_literal: true
class LearningPartnerPolicy
attr_reader :user, :learning_partner
def initialize(user, learning_partner)
@user = user
@learning_partner = learning_partner
end
def index?
user.is_admin?
end
def show?
user.is_admin?
end
def create?
user.is_admin?
end... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/local_content_policy.rb | Ruby | mit | 19 | main | 211 | # frozen_string_literal: true
class LocalContentPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@local_content = record
end
def retry?
user.is_admin?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/lesson_policy.rb | Ruby | mit | 19 | main | 744 | # frozen_string_literal: true
class LessonPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def new?
user.is_admin?
end
def show?
user.is_admin? || user.enrolled_for_course?(record)
end
def create?
user.is_admin?
end
def update... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/dashboard_policy.rb | Ruby | mit | 19 | main | 209 | # frozen_string_literal: true
class DashboardPolicy
attr_reader :user, :record
def initialize(user, _record)
@user = user
@record = record
end
def index?
user.privileged_user?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/impersonation_policy.rb | Ruby | mit | 19 | main | 284 | # frozen_string_literal: true
class ImpersonationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def create?
user.is_admin? && user.active_for_authentication?
end
def destroy?
user.is_support?
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/policies/concerns/course_visibility_helper.rb | Ruby | mit | 19 | main | 259 | # frozen_string_literal: true
module CourseVisibilityHelper
extend ActiveSupport::Concern
def visible_course?(record)
return true if user.is_admin?
return true unless user.learning_partner.is_public?
record.visibility == 'public'
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/lesson.rb | Ruby | mit | 19 | main | 2,001 | # frozen_string_literal: true
class Lesson < ApplicationRecord
belongs_to :course_module, counter_cache: true
validates :title, presence: true
validates :duration, presence: { message: I18n.t('lesson.duration_not_set') }
validate :unique_local_content_lang
validate :local_contents_present?
has_many :loca... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/enrollment.rb | Ruby | mit | 19 | main | 3,445 | # frozen_string_literal: true
class Enrollment < ApplicationRecord
belongs_to :user, counter_cache: true
belongs_to :course, counter_cache: true
belongs_to :assigned_by, class_name: 'User', optional: true
has_many :quiz_answers, dependent: :destroy
validates :user_id, uniqueness: { scope: :course_id }
sc... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/issue.rb | Ruby | mit | 19 | main | 234 | # frozen_string_literal: true
class Issue < ApplicationRecord
belongs_to :user
belongs_to :question
validates :description, presence: true, length: { minimum: 10 }
validates :user_id, uniqueness: { scope: :question_id }
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/scorm.rb | Ruby | mit | 19 | main | 392 | # frozen_string_literal: true
class Scorm < ApplicationRecord
validates :token, presence: true, uniqueness: true
validates :expires_at, presence: true
has_secure_token :token
before_validation :set_expires_at
belongs_to :learning_partner
def regenerate_scorm_token
regenerate_token
end
private
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/report.rb | Ruby | mit | 19 | main | 958 | # frozen_string_literal: true
class Report < ApplicationRecord
TEAM_REPORT = 'team_report'
has_one_attached :document
validates :name, presence: true
validates :start_date, presence: true
validates :end_date, presence: true
validates :report_type, inclusion: { in: [TEAM_REPORT], message: I18n.t('reports.... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/program.rb | Ruby | mit | 19 | main | 558 | # frozen_string_literal: true
class Program < ApplicationRecord
DEFAULT_PER_PAGE_SIZE = 6
MANAGER_MODE = 'manager'
LEARNER_MODE = 'learner'
validates :name, presence: true
has_many :program_courses, dependent: :destroy
has_many :courses, through: :program_courses
has_many :program_users, dependent: :d... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/quiz_answer.rb | Ruby | mit | 19 | main | 1,005 | # frozen_string_literal: true
class QuizAnswer < ApplicationRecord
STATUS_MAPPING = {
correct: 'correct',
incorrect: 'incorrect',
skipped: 'skipped'
}.freeze
VALID_OPTIONS = %w[a b c d skip].freeze
belongs_to :quiz
belongs_to :enrollment
belongs_to :course_module
validates :status, presenc... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/payment_plan.rb | Ruby | mit | 19 | main | 1,261 | # frozen_string_literal: true
class PaymentPlan < ApplicationRecord
DEFAULT_TOTAL_SEATS = 50
DEFAULT_PER_SEAT_COST = 500
validates :start_date, :end_date, :per_seat_cost, presence: true
validates :total_seats, presence: true, numericality: { only_integer: true, greater_than: 0 }
validate :acceptable_total_... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/course.rb | Ruby | mit | 19 | main | 3,363 | # frozen_string_literal: true
class Course < ApplicationRecord
include CustomValidations
include CourseJson
ENROLLED_COURSES_LIMIT = 4
PER_PAGE_LIMIT = 12
enum :visibility, { public: 'public', private: 'private' }, prefix: :visibility
has_many :course_modules, dependent: :destroy
has_many :questions, ... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/team.rb | Ruby | mit | 19 | main | 1,927 | # frozen_string_literal: true
class Team < ApplicationRecord
include CustomValidations
validates :name, presence: true
validates :department, presence: true, allow_nil: true
has_one_attached :banner
belongs_to :learning_partner
has_many :users # rubocop:disable Rails/HasManyOrHasOneDependent
belongs_... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/team_enrollment.rb | Ruby | mit | 19 | main | 346 | # frozen_string_literal: true
#
# modal for tracking the enrollments at a team level
# all the fine details of the enrolments will be still kept at the
# Enrollment table.
class TeamEnrollment < ApplicationRecord
belongs_to :team, counter_cache: true
belongs_to :course, counter_cache: true
belongs_to :assigned_b... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/course_module.rb | Ruby | mit | 19 | main | 1,977 | # frozen_string_literal: true
class CourseModule < ApplicationRecord
belongs_to :course, counter_cache: true
has_many :lessons, dependent: :destroy
has_many :quizzes, dependent: :destroy
validates :title, presence: true, length: { minimum: 6, maximum: 255 }
def duration
lessons.map(&:duration).reduce(&:... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/question.rb | Ruby | mit | 19 | main | 1,009 | # frozen_string_literal: true
class Question < ApplicationRecord
belongs_to :course
has_many :issues, dependent: :destroy
paginates_per 5
validates :content, presence: true
validates :options, length: { minimum: 2, message: ->(_object, _data) { I18n.t('question.not_enough_options') } }
validates :answers... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/event.rb | Ruby | mit | 19 | main | 3,578 | # frozen_string_literal: true
class Event < ApplicationRecord
ONBOARDING_INITIATED = 'onboarding_initiated'
FIRST_USER_JOINED = 'first_user_joined'
USER_INVITED = 'user_invited'
USER_JOINED = 'user_joined'
USER_LOGIN = 'user_login'
USER_LOGOUT = 'user_logout'
COURSE_ASSIGNED = 'course_assigned'
COURSE_... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/local_content.rb | Ruby | mit | 19 | main | 1,533 | # frozen_string_literal: true
class LocalContent < ApplicationRecord
attr_accessor :blob_id
enum :status, { pending: 'pending', complete: 'complete' }, default: :pending
SUPPORTED_LANGUAGES = {
english: 'English',
hindi: 'Hindi',
tamil: 'Tamil',
marathi: 'Marathi',
bengali: 'Bengali',
k... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/course_certificate.rb | Ruby | mit | 19 | main | 348 | # frozen_string_literal: true
class CourseCertificate < ApplicationRecord
validates :issued_at, presence: true
validates :certificate_uuid, presence: true, uniqueness: true
validates :file_hash, presence: true, uniqueness: true
has_one_attached :file
has_one_attached :certificate_thumbnail
belongs_to :co... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/certificate_template.rb | Ruby | mit | 19 | main | 1,197 | # frozen_string_literal: true
class CertificateTemplate < ApplicationRecord
ALLOWED_VARIABLES = %w[CandidateName CourseName IssueDate].freeze
validates :name, presence: true
validates :active, inclusion: { in: [true, false] }
validate :only_one_active_template, if: :active?
validate :validate_html_file, on... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/tag.rb | Ruby | mit | 19 | main | 440 | # frozen_string_literal: true
class Tag < ApplicationRecord
DEFAULT_PER_PAGE_SIZE = 9
TAG_LOAD_LIMIT = 100
enum :tag_type, { category: 'category', level: 'level' }, default: 'category'
validates :name, presence: true, uniqueness: true
validates :tag_type, presence: true
has_and_belongs_to_many :courses ... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/program_course.rb | Ruby | mit | 19 | main | 324 | # frozen_string_literal: true
class ProgramCourse < ApplicationRecord
belongs_to :program, counter_cache: :courses_count
belongs_to :course
validates :course_id, uniqueness: {
scope: :program_id,
message: ->(object, _data) { I18n.t('program_course.already_added', course_name: object.course.title) }
}
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/assessment.rb | Ruby | mit | 19 | main | 2,254 | # frozen_string_literal: true
class Assessment < ApplicationRecord
belongs_to :user
belongs_to :course
STATUS = { pending: 0, in_progress: 1, completed: 2 }.freeze
QUESTIONS_COUNT = 20
PASS_PERCENTAGE = 50
MAX_ATTEMPT = 2
validate :validate_questions_count
validates :status, inclusion: { in: STATUS.v... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/user.rb | Ruby | mit | 19 | main | 6,142 | # frozen_string_literal: true
class User < ApplicationRecord
include UserState
include CustomValidations
scope :active, -> { where(state: 'active') }
scope :skip_deactivated, -> { where.not(state: 'in-active') }
EMAIL_REGEXP = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
PHONE_REGEXP = /\A[6-9][0-9... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/quiz.rb | Ruby | mit | 19 | main | 388 | # frozen_string_literal: true
class Quiz < ApplicationRecord
belongs_to :course_module, counter_cache: true
has_many :quiz_answers, dependent: :destroy
validates :question, presence: true
validates :option_a, presence: true
validates :option_b, presence: true
validates :option_c, presence: true
validate... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/transcript.rb | Ruby | mit | 19 | main | 1,001 | # frozen_string_literal: true
class Transcript < ApplicationRecord
belongs_to :local_content
validates :start_at, :end_at, :text, presence: true
validate :start_time_must_be_before_end_time
# rubocop:disable Rails/SkipsModelValidations
def self.update_with_transaction(local_content, data)
Transcript.tr... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/learning_partner.rb | Ruby | mit | 19 | main | 2,032 | # frozen_string_literal: true
class LearningPartner < ApplicationRecord
include CustomValidations
include PartnerState
has_many :users, dependent: :destroy
has_many :certificate_templates, dependent: :destroy
has_one :scorm, dependent: :destroy
has_one :payment_plan, dependent: :destroy
accepts_nested_a... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/concerns/custom_validations.rb | Ruby | mit | 19 | main | 1,686 | # frozen_string_literal: true
module CustomValidations
extend ActiveSupport::Concern
MATERIAL_CONTENT_TYPES = %w[application/pdf].freeze
MATERIAL_MAX_MB = 10
included do
def acceptable_logo
acceptable_image('logo')
end
def acceptable_banner
acceptable_image('banner')
end
def... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/concerns/user_state.rb | Ruby | mit | 19 | main | 1,027 | # frozen_string_literal: true
module UserState
extend ActiveSupport::Concern
UNVERIFIED = 'unverified'
VERIFIED = 'verified'
ACTIVE = 'active'
INACTIVE = 'in-active'
USER_STATES = [UNVERIFIED, VERIFIED, ACTIVE, INACTIVE].freeze
included do
def unverified?
state == UNVERIFIED
end
def... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/concerns/course_json.rb | Ruby | mit | 19 | main | 3,198 | # frozen_string_literal: true
module CourseJson
extend ActiveSupport::Concern
def to_json_data
course_data = fill_course_data_attributes
course_data['modules'] = []
modules_in_order.each do |course_module|
module_data = fill_module_data_attributes(course_module)
module_data['lessons'] = [... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/models/concerns/partner_state.rb | Ruby | mit | 19 | main | 741 | # frozen_string_literal: true
module PartnerState
extend ActiveSupport::Concern
PARTNER_STATES = %w[new in-active].freeze
included do
validates :state, presence: true, inclusion: { in: PARTNER_STATES }
def active?
# considering new partners as active by default
state == 'new'
end
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/cards_helper.rb | Ruby | mit | 19 | main | 1,928 | # frozen_string_literal: true
module CardsHelper
MIN_PROGRAM_CARDS = 5
def program_cards(programs)
return [] if programs.empty?
enrolled_program_ids = current_user.program_ids.to_set
cards = programs.map do |program|
link_to program_path(program, mode: Program::LEARNER_MODE) do
program... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/quizzes_helper.rb | Ruby | mit | 19 | main | 225 | # frozen_string_literal: true
module QuizzesHelper
def quiz_delete_tooltip_message(course)
if course.published?
t('quiz.cannot_delete_published')
else
t('quiz.cannot_delete_enrolled')
end
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/assessment_helper.rb | Ruby | mit | 19 | main | 1,152 | # frozen_string_literal: true
module AssessmentHelper
def result_styles(is_pass)
if is_pass
{ grid_bg: 'bg-secondary-dark', grid_item_bg: 'bg-secondary-light' }
else
{ grid_bg: 'bg-danger', grid_item_bg: 'bg-danger-light' }
end
end
def start_btn_text(attempt)
attempt == 1 ? t('assess... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/my_profiles_helper.rb | Ruby | mit | 19 | main | 414 | # frozen_string_literal: true
module MyProfilesHelper
def linkedin_share_url(certificate_uuid)
app_url = Rails.application.credentials.dig(:app, :base_url)
certificate_url = "#{app_url}/certificates/#{certificate_uuid}"
"https://www.linkedin.com/sharing/share-offsite/?url=#{certificate_url}"
end
de... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/learning_partners_helper.rb | Ruby | mit | 19 | main | 2,673 | # frozen_string_literal: true
module LearningPartnersHelper
def learning_partner_menu_items(learning_partner)
[
edit_partner_item(learning_partner),
activate_partner_item(learning_partner),
payment_plan_item(learning_partner),
certificate_templates_item(learning_partner),
impersonat... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/programs_helper.rb | Ruby | mit | 19 | main | 981 | # frozen_string_literal: true
module ProgramsHelper
def program_menu_items(program, show_delete: true, learner_mode: false)
items = []
if learner_mode
items << ViewComponent::MenuComponentHelper::MenuItem.new(
label: t('programs.edit_details'),
url: program_path(program, mode: Program:... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/questions_helper.rb | Ruby | mit | 19 | main | 601 | # frozen_string_literal: true
module QuestionsHelper
def current_tab
params[:tab] || 'all'
end
def tab_name_with_count(key, count)
QuestionsBank::TABS[key] + "(#{count})"
end
def tab_keys
QuestionsBank::TABS.keys
end
def tab_style(tab_key)
tab_name = tab_key.to_s
if tab_name == par... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/certificate_templates_helper.rb | Ruby | mit | 19 | main | 1,823 | # frozen_string_literal: true
module CertificateTemplatesHelper
def certificate_template_menu_items(learning_partner, template)
[
deactivate_certificate_template_item(learning_partner, template),
activate_certificate_template_item(learning_partner, template),
delete_certificate_template_item(le... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/sample_menu_helper.rb | Ruby | mit | 19 | main | 473 | # frozen_string_literal: true
module SampleMenuHelper
def sample_menu_items
[
ViewComponent::MenuComponent::MenuItem.new(
label: t('button.edit'),
type: :link
),
ViewComponent::MenuComponent::MenuItem.new(
label: 'Change team',
type: :link
),
ViewComp... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/dashboards_helper.rb | Ruby | mit | 19 | main | 682 | # frozen_string_literal: true
module DashboardsHelper
MenuItem = Struct.new(:label, :link)
def duration_menu_for(team)
@duration_menu_for ||= Dashboard::VALID_DURATIONS.map do |key, value|
MenuItem.new(value, dashboard_path(duration: key.to_s, team_id: team.id))
end
end
def selected_label(durati... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/courses_helper.rb | Ruby | mit | 19 | main | 7,342 | # frozen_string_literal: true
module CoursesHelper
def explore_title(tags)
title = t('course.explore')
return title unless tags && tags.count == 1
[title, t('course.preposition_on'), tags[0]].join(' ')
end
def enrolled_courses?(courses)
defined?(courses) && courses.present?
end
def availab... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/course_modules_helper.rb | Ruby | mit | 19 | main | 265 | # frozen_string_literal: true
module CourseModulesHelper
def module_delete_tooltip_message(course)
if course.published?
t('course.course_module.cannot_delete_published')
else
t('course.course_module.cannot_delete_enrolled')
end
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/teams_helper.rb | Ruby | mit | 19 | main | 3,362 | # frozen_string_literal: true
module TeamsHelper
def my_team_path
if current_user.is_admin?
'#'
else
team_path(current_user.team)
end
end
def team_list(root_team, team)
return [] if team.nil?
return [team] if team.parent_team.nil? || root_team.id == team.id
team_list = []
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/turbo_stream_actions_helper.rb | Ruby | mit | 19 | main | 205 | # frozen_string_literal: true
module TurboStreamActionsHelper
def redirect_to(url)
turbo_stream_action_tag :redirect_to, url:
end
end
Turbo::Streams::TagBuilder.prepend(TurboStreamActionsHelper) |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/lessons_helper.rb | Ruby | mit | 19 | main | 4,307 | # frozen_string_literal: true
module LessonsHelper
def lesson_back_link(lesson, is_admin)
course_module = lesson.course_module
course = course_module.course
is_admin ? course_module_path(course, course_module) : course_path(course)
end
def breadcrumbs_links(lesson, is_admin)
course_module = les... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/application_helper.rb | Ruby | mit | 19 | main | 3,453 | # frozen_string_literal: true
module ApplicationHelper
def header_options(opts = {})
default_header_options = {
title: nil,
header_extended: false
}
default_header_options.merge!(opts)
end
def active(name, link)
link == name ? 'active' : ''
end
def records_in_order(records, ord... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/users_helper.rb | Ruby | mit | 19 | main | 3,611 | # frozen_string_literal: true
module UsersHelper
def user_image(user)
return STATIC_ASSETS[:user_image] unless user.profile_picture.attached?
# HACK: for local testing with production dump data
return STATIC_ASSETS[:user_image] if Rails.env.local? && user.profile_picture.blob.service_name.start_with?('s3... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/onboarding_helper.rb | Ruby | mit | 19 | main | 812 | # frozen_string_literal: true
module OnboardingHelper
def local_languages
LocalContent::SUPPORTED_LANGUAGES.values.slice(0, 7)
end
def other_local_language(selected_language)
local_languages.include?(selected_language) ? '' : selected_language
end
def show_selected_option(language)
return false... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/commons_helper.rb | Ruby | mit | 19 | main | 852 | # frozen_string_literal: true
module CommonsHelper
def payment_plan_days_remaining(start_date, end_date)
start_date = start_date.to_date
end_date = end_date.to_date
(end_date - start_date).to_i
end
def activate_users_count(learning_partner)
learning_partner.payment_plan.total_seats - learning_p... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/helpers/settings_helper.rb | Ruby | mit | 19 | main | 415 | # frozen_string_literal: true
module SettingsHelper
def settings_list
[
{
label: t('tags.label'),
description: t('settings.description'),
icon: 'icon-tag',
path: tags_path
},
{
label: t('components.title'),
description: t('components.label'),
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/adapters/scorm_adapter.rb | Ruby | mit | 19 | main | 258 | # frozen_string_literal: true
class ScormAdapter
attr_reader :course, :scorm_token
def initialize(course, scorm_token)
@course = course
@scorm_token = scorm_token
end
def process
ScormService::Course.new(course, scorm_token)
end
end |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/reports_controller.rb | Ruby | mit | 19 | main | 960 | # frozen_string_literal: true
class ReportsController < ApplicationController
def new
authorize :report
@team = Team.find params[:team_id]
@report = Report.new(name: "New report", team_id: @team.id, generated_by: current_user.id)
end
def create
authorize :report
@team = Team.find(create_repo... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/impersonations_controller.rb | Ruby | mit | 19 | main | 862 | class ImpersonationsController < ApplicationController
def create
authorize :impersonation
learning_partner = LearningPartner.find(params[:id])
service = Impersonations::FindOrCreateSupportUserService.instance
support_user = service.find_or_create_user(learning_partner)
sign_in support_user
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/notifications_controller.rb | Ruby | mit | 19 | main | 722 | # frozen_string_literal: true
class NotificationsController < ApplicationController
def index
@notifications = notification_service.pending_notification_for(current_user)
end
def count
@notifications_count = notification_service.notifications_count_for(current_user)
end
def clear
notification_s... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/my_profiles_controller.rb | Ruby | mit | 19 | main | 3,280 | # frozen_string_literal: true
class MyProfilesController < ApplicationController
before_action :set_course_certificates
before_action :set_course_certificate, only: :share_certificate
before_action :set_enrollment, only: :generate_certificate
def show
authorize :my_profile
@course_certificates = @cour... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/users_controller.rb | Ruby | mit | 19 | main | 3,257 | # frozen_string_literal: true
class UsersController < ApplicationController
before_action :set_user
def show
authorize @user
@enrolled_courses = @user.courses.includes(:tags, :banner_attachment)
@enrollments_by_course_id = @user.enrollments.indexed_by_course(@enrolled_courses)
service = UserStatist... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/payment_plans_controller.rb | Ruby | mit | 19 | main | 1,673 | # frozen_string_literal: true
class PaymentPlansController < ApplicationController
before_action :set_learning_partner
before_action :set_payment_plan, only: %i[edit update]
def new
authorize @learning_partner, policy_class: PaymentPlanPolicy
@payment_plan = PaymentPlan.default_plan
end
def create
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/course_modules_controller.rb | Ruby | mit | 19 | main | 3,487 | # frozen_string_literal: true
class CourseModulesController < ApplicationController
include CourseNavContext
before_action :set_course, only: %i[new create show edit update destroy moveup movedown summary redo_quiz]
before_action :set_course_module, only: %i[show edit update destroy moveup movedown summary redo... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/scorms_controller.rb | Ruby | mit | 19 | main | 969 | class ScormsController < ApplicationController
include CourseNavContext
before_action :set_course
before_action :set_learning_partners, only: :new
def new
authorize :scorm
@scorm = Scorm.new
end
def create
authorize :scorm
@download_link = "#{request.original_url}/download?learning_partne... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/local_contents_controller.rb | Ruby | mit | 19 | main | 955 | # frozen_string_literal: true
class LocalContentsController < ApplicationController
include LessonsHelper
before_action :set_local_content
def retry
authorize @local_content
@lesson = @local_content.lesson
@course_module = @lesson.course_module
@course = @course_module.course
blob = @loca... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/user_searches_controller.rb | Ruby | mit | 19 | main | 628 | # frozen_string_literal: true
class UserSearchesController < ApplicationController
def index
load_users
end
def create
load_users
end
private
def load_users
@team = Team.find(search_params[:team_id])
@all_members = search_params[:all_members] == 'true'
@term = search_params[:term]
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/issues_controller.rb | Ruby | mit | 19 | main | 570 | # frozen_string_literal: true
class IssuesController < ApplicationController
before_action :set_issue
def new
authorize @issue
render partial: "form", locals: { issue: @issue }
end
def create
authorize @issue
@issue.description = params[:description]
if @issue.save && @issue.question.... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/pages_controller.rb | Ruby | mit | 19 | main | 344 | # frozen_string_literal: true
class PagesController < ApplicationController
layout 'devise'
# NOTE: No route added in route definition
# Can be used for building a landing page in future
def index; end
# No route added for these pages these pages should not be accessed directly
def unauthorized
rende... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/assessments_controller.rb | Ruby | mit | 19 | main | 2,213 | class AssessmentsController < ApplicationController
include CourseNavContext
skip_before_action :authenticate_user!, only: :intro
before_action :store_user_location!, only: :show
before_action :authenticate_user!, except: :intro
before_action :set_assessment
before_action :set_course_certificate, only: %i... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/invites_controller.rb | Ruby | mit | 19 | main | 3,290 | # frozen_string_literal: true
# Invites Controller is used to invite new members by the manager or owners.
# This is not meant for inviting other admins.
class InvitesController < ApplicationController
include CommonsHelper
def new
authorize :invite
@team = Team.find(params[:team_id])
# check if use... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/tags_controller.rb | Ruby | mit | 19 | main | 1,535 | # frozen_string_literal: true
class TagsController < ApplicationController
include PaginationConcern
before_action -> { @active_nav = 'settings' }
before_action :set_tag, only: [:edit, :update, :destroy]
def new
authorize :tag
@tag = Tag.new
end
def index
authorize :tag
@tags = Tag.page(... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/lessons_controller.rb | Ruby | mit | 19 | main | 6,637 | # frozen_string_literal: true
class LessonsController < ApplicationController
include LessonsHelper
include CourseNavContext
before_action :set_course
before_action :set_course_module
before_action :set_enrollment, only: %i[show complete]
before_action :set_lesson, only: %i[show edit update destroy comple... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/teams_controller.rb | Ruby | mit | 19 | main | 1,615 | # frozen_string_literal: true
class TeamsController < ApplicationController
before_action :set_team, only: %i[show edit update sub_teams]
before_action :set_parent_team, only: :create
def new
authorize :team
@team = Team.new(parent_team_id: params[:parent_team_id])
end
def show
authorize @team
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/searches_controller.rb | Ruby | mit | 19 | main | 644 | # frozen_string_literal: true
class SearchesController < ApplicationController
include SearchContextHelper
def index
@courses = load_courses.page(params[:page]).per(Course::PER_PAGE_LIMIT)
end
def load_more
@courses = load_courses.page(params[:page]).per(Course::PER_PAGE_LIMIT)
end
def list
... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/courses_controller.rb | Ruby | mit | 19 | main | 7,840 | # frozen_string_literal: true
class CoursesController < ApplicationController
include CourseAssociationsPreloader
before_action :set_course, only: %i[show edit update destroy enroll unenroll proceed publish unpublish]
before_action :set_course_active_nav, only: %i[show]
before_action :set_tags, only: %i[new c... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/questions_controller.rb | Ruby | mit | 19 | main | 2,588 | class QuestionsController < ApplicationController
include CommonsHelper
before_action :set_course
before_action :set_question, only: %i[edit update destroy verify unverify]
before_action :build_question_bank, only: %i[index destroy verify unverify]
before_action :build_new_question, only: %i[new]
def inde... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/logins_controller.rb | Ruby | mit | 19 | main | 1,698 | # frozen_string_literal: true
class LoginsController < ApplicationController
layout 'devise'
before_action :user_exists?, only: %i[otp create]
skip_before_action :authenticate_user!
def new; end
def otp
service = LoginWithOtpService.instance
if @user_exists
user = User.where(phone: @mobile_... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/application_controller.rb | Ruby | mit | 19 | main | 1,307 | # frozen_string_literal: true
class ApplicationController < ActionController::Base
include Pundit::Authorization
include HandleNotFound
include UserOnboarding
include Impersonation
before_action :authenticate_user!
before_action :set_back_link
before_action :set_active_nav
rescue_from Pundit::NotAuth... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/direct_uploads_controller.rb | Ruby | mit | 19 | main | 710 | # frozen_string_literal: true
class DirectUploadsController < ActiveStorage::DirectUploadsController
protect_from_forgery with: :null_session
before_action :authenticate_user!
def create
blob = ActiveStorage::Blob.create_before_direct_upload!(**upload_blob_attributes)
render json: direct_upload_json(b... |
github | openvitae-tech/blackboard-lms | https://github.com/openvitae-tech/blackboard-lms | app/controllers/learning_partners_controller.rb | Ruby | mit | 19 | main | 4,720 | # frozen_string_literal: true
class LearningPartnersController < ApplicationController
helper_method :country_dropdown_options
before_action :set_learning_partner, only: %i[show edit update destroy activate deactivate]
# GET /learning_partners or /learning_partners.json
def index
authorize :learning_part... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.