class LUSI::API::Course::ModuleBase
The abstract base class of Module
and SchemeOfStudy
@abstract Subclass and define:
identity_class = the class representing identity lusi_ws_endpoint = the LUSI API endpoint lusi_ws_method = the LUSI API method to retrieve instance data lusi_ws_path = the LUSI API URL path lusi_ws_xml_root = the root element name of the LUSI API XML response
Attributes
@!attribute [rw] category_level
@return [String, nil] the category (e.g. 'UG', 'PG')
@!attribute [rw] cohorts
@return [Array<LUSI::API::Course::Cohort>, nil] the list of associated cohorts
@!attribute [rw] course_departments
@return [Array<LUSI::API::Course::CourseDepartment>, nil] the list of associated course departments
@!attribute [rw] course_documents
@return [Array<LUSI::API::Course::CourseDocument>, nil] the list of associated course documents
@!attribute [rw] credit
@return [String, nil] the credit point value
@!attribute [rw] delivery_mode
@return [LUSI::API::Core::Code, nil] the mode of delivery
@!attribute [rw] display_long_title
@return [String, nil] the long course title
@!attribute [rw] display_short_title
@return [String, nil] the short course title
@!attribute [rw] enrolled_students
@return [Integer, nil] the number of enrolled students
@!attribute [rw] external_course_identity
@return [String, nil] the external course identity
@!attribute [rw] identity
@return [LUSI::API::Course::Identity, nil] the course identity
@!attribute [r] identity_class
@return [Class, nil] the class representing module/scheme of study identity
@!attribute [rw] learning_hours
@return [Integer, nil] the total number of learning hours
@!attribute [rw] mnemonic
@return [String, nil] the mnemonic for the course
@!attribute [rw] status
@return [String, nil] the status ('Live', 'Dormant', 'Draft' etc.)
@!attribute [rw] syllabus_rules
@return [Array<LUSI::API::Course::SyllabusRule>, nil] the list of associated syllabus rules
@!attribute [rw] teaching_institution
@return [LUSI::API::Organisation::Unit, nil] the teaching institution
@!attribute [rw] title
@return [String, nil] the title
@!attribute [rw] year
@return [String, nil] the academic year
Public Class Methods
Returns an array of instances matching the specified search criteria @param api [LUSI::API::Core::API] the LUSI
API
instance to use for searching @param (see get_instance_params) @return [<Array<LUSI::API::Course::Module, LUSI::API::Course::SchemeOfStudy>] the list of matching instances @yield [obj] Passes the instance to the block @yieldparam obj [LUSI::API::Course::Module, LUSI::API::Course::SchemeOfStudy] the instance
# File lib/lusi_api/course.rb, line 185 def self.get_instance(api, lookup = nil, **kwargs) # active_vle_spaces_only: nil) params = get_instance_params(**kwargs) xml = api.call(self.lusi_ws_path, self.lusi_ws_endpoint, self.lusi_ws_method, **params) LUSI::API::Core::XML.xml(xml, "xmlns:#{self.lusi_ws_xml_root}") do |m| obj = self.new(m, lookup) yield(obj) if block_given? obj end end
Returns a hash of parameters for the LUSI
API
call. Subclasses may extend or override this method. @param asp_identity [String, nil] return instances matching this academic significant period (ASP) @param cohort_identity (String, nil) return instances matching this cohort identity @param course_identity [String, nil] return instances matching this course identity @param department_identity (String, nil) return instances matching this department identity @param external_course_identity
[String, nil] return instances matching this external course identity @param include_course_documentation [Boolean, nil] include course documentation if true, otherwise omit it @param include_syllabus_rules [Boolean, nil] include syllabus rules if true, otherwise omit them @param live_only [Boolean, nil] return only live (active) instances if true, otherwise return all instances @param teaching_institution_id (String, nil) return instances matching this teaching institution @param year_identity (String, nil) return instances matching this year identity @return [Hash<String, String>] the parameter hash for the LUSI
API
call
# File lib/lusi_api/course.rb, line 265 def self.get_instance_params(**kwargs) result = { ASPIdentity: kwargs.fetch(:asp_identity, ''), CohortIdentity: kwargs.fetch(:cohort_identity, ''), CourseIdentity: kwargs.fetch(:course_identity, ''), DepartmentIdentity: kwargs.fetch(:department_identity, ''), ExternalCourseIdentity: kwargs.fetch(:external_course_identity, ''), IncludeCourseDocumentation: kwargs.fetch(:include_course_documentation, false) ? 'true' : 'false', IncludeSyllabusRules: kwargs.fetch(:include_syllabus_rules, false) ? 'true' : 'false', LiveOnly: kwargs.fetch(:live_only, true) ? 'true' : 'false', TeachingInstitutionId: kwargs.fetch(:teaching_institution_id, ''), YearIdentity: kwargs.fetch(:year_identity, '') } if self.lusi_ws_endpoint == 'General.asmx' # The General.asmx endpoint methods GetModuleDetails and GetSchemesOfStudy require an extra parameter result[:ActiveVLESpaceOnly] = kwargs.fetch(:active_vle_space_only, true) ? 'true' : 'false' end result end
Initialises a new ModuleBase
instance @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the module or scheme of study @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param category_level
[String, nil] the default category @param cohort [LUSI::API::Course::Cohort, nil] the default cohort @param course_departments
[Array<LUSI::API::Course::CourseDepartment>, nil] the default course departments @param course_documents
[Array<LUSI::API::Course::CourseDocument>, nil] the default course documents @param credit [String, nil] the default credit point value @param delivery_mode
[LUSI::API::Core::Code, nil] the default delivery mode @param display_long_title
[String, nil] the default long title @param display_short_title
[String, nil] the default short title @param enrolled_students
[Integer, nil] the default number of enrolled students @param external_course_identity
[String, nil] the default external course identity code @param identity [String, nil] the default identity code @param learning_hours
[Integer, nil] the default number of learning hours @param mnemonic [String, nil] the default mnemonic @param subjects [Array<LUSI::API::Course::Subject>, nil] the default subjects @param status [String, nil] the default status @param syllabus_rules
[Array<SyllabusRule>, nil] the default syllabus rules @param teaching_institution
[LUSI::API::Organisation::Unit, nil] the default teaching institution @param title [String, nil] the default title @param year [String, nil] the default year @return [void]
# File lib/lusi_api/course.rb, line 219 def initialize(xml = nil, lookup = nil, category_level: nil, cohort: nil, course_departments: nil, course_documents: nil, credit: nil, delivery_mode: nil, display_long_title: nil, display_short_title: nil, enrolled_students: nil, external_course_identity: nil, identity: nil, learning_hours: nil, mnemonic: nil, subjects: nil, status: nil, syllabus_rules: nil, teaching_institution: nil, title: nil, year: nil) @category_level = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:CategoryLevel', category_level) @cohorts = LUSI::API::Core::XML.xml(xml, 'xmlns:Cohorts/xmlns:Cohort', cohort) { |c| Cohort.new(c, lookup) } @course_departments = LUSI::API::Core::XML.xml(xml, 'xmlns:CourseDepartments/xmlns:CourseDepartment', course_departments) { |d| CourseDepartment.new(d, lookup) } @course_documents = LUSI::API::Core::XML.xml(xml, 'xmlns:CourseDocuments/xmlns:CourseDocument', course_documents) { |c| CourseDocument.new(c, lookup) } @credit = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Credit', credit) @delivery_mode = LUSI::API::Core::Code.new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:DeliveryMode', delivery_mode), lookup) @display_long_title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:DisplayLongTitle', display_long_title) @display_short_title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:DisplayShortTitle', display_short_title) @external_course_identity = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:ExternalCourseIdentity', external_course_identity) @identity = Identity.new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:Identity', identity), lookup) @learning_hours = LUSI::API::Core::XML.xml_int_at(xml, 'xmlns:LearningHours', learning_hours) @mnemonic = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Mnemonic', mnemonic) @status = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Status', status) @subjects = LUSI::API::Core::XML.xml(xml, 'xmlns:Subjects/xmlns:Subject', subjects) { |s| Subject.new(s, lookup) } @syllabus_rules = LUSI::API::Core::XML.xml(xml, 'xmlns:SyllabusRules/xmlns:SyllabusRule', syllabus_rules) { |s| SyllabusRule.new(s, lookup) } @teaching_institution = LUSI::API::Core::XML.lookup(xml, lookup, :institution, 'xmlns:TeachingInstitution/xmlns:Identity', teaching_institution) @title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Title', title) @year = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Year', year) end
Protected Class Methods
Returns the class representing module/scheme of study identity @return [Class] the identity class
# File lib/lusi_api/course.rb, line 296 def self.identity_class Identity end
@see (LUSI::API::Core::Endpoint#lusi_ws_endpoint
)
# File lib/lusi_api/course.rb, line 301 def self.lusi_ws_endpoint 'CourseManager.asmx' end
@see (LUSI::API::Core::Endpoint#lusi_ws_path
)
# File lib/lusi_api/course.rb, line 306 def self.lusi_ws_path 'LUSIReference' end
Public Instance Methods
Returns an array of enrolment lookup table indices to search for this module/scheme of study
# File lib/lusi_api/course.rb, line 169 def enrolment_lookup_indices [] end
Returns an array of enrolment lookup table keys for this module/scheme of study @return [Array<String>] the enrolment lookup table keys
# File lib/lusi_api/course.rb, line 175 def enrolment_lookup_keys self.cohorts.map { |cohort| "#{self.identity.lookup_key}-#{cohort.identity}" } end
Returns the major departments for the module/scheme of study @return [Array<LUSI::API::Course::CourseDepartment>] the major departments
# File lib/lusi_api/course.rb, line 288 def major_departments self.course_departments.select { |course_department| course_department.is_major_department } end