Class: LUSI::API::Course::ModuleBase Abstract
- Inherits:
-
Object
- Object
- LUSI::API::Course::ModuleBase
- Extended by:
- LUSI::API::Core::Endpoint
- Defined in:
- lib/lusi_api/course.rb
Overview
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
The abstract base class of Module and SchemeOfStudy
Direct Known Subclasses
Instance Attribute Summary collapse
-
#category_level ⇒ String?
The category (e.g. ‘UG’, ‘PG’).
-
#cohorts ⇒ Array<LUSI::API::Course::Cohort>?
The list of associated cohorts.
-
#course_departments ⇒ Array<LUSI::API::Course::CourseDepartment>?
The list of associated course departments.
-
#course_documents ⇒ Array<LUSI::API::Course::CourseDocument>?
The list of associated course documents.
-
#credit ⇒ String?
The credit point value.
-
#delivery_mode ⇒ LUSI::API::Core::Code?
The mode of delivery.
-
#display_long_title ⇒ String?
The long course title.
-
#display_short_title ⇒ String?
The short course title.
-
#enrolled_students ⇒ Integer?
The number of enrolled students.
-
#external_course_identity ⇒ String?
The external course identity.
-
#identity ⇒ LUSI::API::Course::Identity?
The course identity.
-
#identity_class ⇒ Object
readonly
Returns the value of attribute identity_class.
-
#learning_hours ⇒ Integer?
The total number of learning hours.
-
#mnemonic ⇒ String?
The mnemonic for the course.
-
#status ⇒ String?
The status (‘Live’, ‘Dormant’, ‘Draft’ etc.).
-
#syllabus_rules ⇒ Array<LUSI::API::Course::SyllabusRule>?
The list of associated syllabus rules.
-
#teaching_institution ⇒ LUSI::API::Organisation::Unit?
The teaching institution.
-
#title ⇒ String?
The title.
-
#year ⇒ String?
The academic year.
Class Method Summary collapse
-
.get_instance(api, lookup = nil, **kwargs) {|obj| ... } ⇒ <Array<LUSI::API::Course::Module, LUSI::API::Course::SchemeOfStudy>] the list of matching instances
Returns an array of instances matching the specified search criteria.
-
.get_instance_params(**kwargs) ⇒ Hash<String, String>
Returns a hash of parameters for the LUSI API call.
Instance Method Summary collapse
-
#enrolment_lookup_indices ⇒ Object
Returns an array of enrolment lookup table indices to search for this module/scheme of study.
-
#enrolment_lookup_keys ⇒ Array<String>
Returns an array of enrolment lookup table keys for this module/scheme of study.
-
#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) ⇒ void
constructor
Initialises a new ModuleBase instance.
-
#major_departments ⇒ Array<LUSI::API::Course::CourseDepartment>
Returns the major departments for the module/scheme of study.
Methods included from LUSI::API::Core::Endpoint
lusi_ws_endpoint, lusi_ws_method, lusi_ws_path, lusi_ws_xml_root
Constructor Details
#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) ⇒ void
Initialises a new ModuleBase instance
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# 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 |
Instance Attribute Details
#category_level ⇒ String?
Returns the category (e.g. ‘UG’, ‘PG’).
94 95 96 |
# File 'lib/lusi_api/course.rb', line 94 def category_level @category_level end |
#cohorts ⇒ Array<LUSI::API::Course::Cohort>?
Returns the list of associated cohorts.
98 99 100 |
# File 'lib/lusi_api/course.rb', line 98 def cohorts @cohorts end |
#course_departments ⇒ Array<LUSI::API::Course::CourseDepartment>?
Returns the list of associated course departments.
102 103 104 |
# File 'lib/lusi_api/course.rb', line 102 def course_departments @course_departments end |
#course_documents ⇒ Array<LUSI::API::Course::CourseDocument>?
Returns the list of associated course documents.
106 107 108 |
# File 'lib/lusi_api/course.rb', line 106 def course_documents @course_documents end |
#credit ⇒ String?
Returns the credit point value.
110 111 112 |
# File 'lib/lusi_api/course.rb', line 110 def credit @credit end |
#delivery_mode ⇒ LUSI::API::Core::Code?
Returns the mode of delivery.
114 115 116 |
# File 'lib/lusi_api/course.rb', line 114 def delivery_mode @delivery_mode end |
#display_long_title ⇒ String?
Returns the long course title.
118 119 120 |
# File 'lib/lusi_api/course.rb', line 118 def display_long_title @display_long_title end |
#display_short_title ⇒ String?
Returns the short course title.
122 123 124 |
# File 'lib/lusi_api/course.rb', line 122 def display_short_title @display_short_title end |
#enrolled_students ⇒ Integer?
Returns the number of enrolled students.
126 127 128 |
# File 'lib/lusi_api/course.rb', line 126 def enrolled_students @enrolled_students end |
#external_course_identity ⇒ String?
Returns the external course identity.
130 131 132 |
# File 'lib/lusi_api/course.rb', line 130 def external_course_identity @external_course_identity end |
#identity ⇒ LUSI::API::Course::Identity?
Returns the course identity.
134 135 136 |
# File 'lib/lusi_api/course.rb', line 134 def identity @identity end |
#identity_class ⇒ Object (readonly)
Returns the value of attribute identity_class.
138 139 140 |
# File 'lib/lusi_api/course.rb', line 138 def identity_class @identity_class end |
#learning_hours ⇒ Integer?
Returns the total number of learning hours.
142 143 144 |
# File 'lib/lusi_api/course.rb', line 142 def learning_hours @learning_hours end |
#mnemonic ⇒ String?
Returns the mnemonic for the course.
146 147 148 |
# File 'lib/lusi_api/course.rb', line 146 def mnemonic @mnemonic end |
#status ⇒ String?
Returns the status (‘Live’, ‘Dormant’, ‘Draft’ etc.).
150 151 152 |
# File 'lib/lusi_api/course.rb', line 150 def status @status end |
#syllabus_rules ⇒ Array<LUSI::API::Course::SyllabusRule>?
Returns the list of associated syllabus rules.
154 155 156 |
# File 'lib/lusi_api/course.rb', line 154 def syllabus_rules @syllabus_rules end |
#teaching_institution ⇒ LUSI::API::Organisation::Unit?
Returns the teaching institution.
158 159 160 |
# File 'lib/lusi_api/course.rb', line 158 def teaching_institution @teaching_institution end |
#title ⇒ String?
Returns the title.
162 163 164 |
# File 'lib/lusi_api/course.rb', line 162 def title @title end |
#year ⇒ String?
Returns the academic year.
166 167 168 |
# File 'lib/lusi_api/course.rb', line 166 def year @year end |
Class Method Details
.get_instance(api, lookup = nil, **kwargs) {|obj| ... } ⇒ <Array<LUSI::API::Course::Module, LUSI::API::Course::SchemeOfStudy>] the list of matching instances
Returns an array of instances matching the specified search criteria
185 186 187 188 189 190 191 192 193 194 |
# 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 |
.get_instance_params(**kwargs) ⇒ Hash<String, String>
Returns a hash of parameters for the LUSI API call. Subclasses may extend or override this method.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# 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 |
Instance Method Details
#enrolment_lookup_indices ⇒ Object
Returns an array of enrolment lookup table indices to search for this module/scheme of study
169 170 171 |
# File 'lib/lusi_api/course.rb', line 169 def enrolment_lookup_indices [] end |
#enrolment_lookup_keys ⇒ Array<String>
Returns an array of enrolment lookup table keys for this module/scheme of study
175 176 177 |
# File 'lib/lusi_api/course.rb', line 175 def enrolment_lookup_keys self.cohorts.map { |cohort| "#{self.identity.lookup_key}-#{cohort.identity}" } end |
#major_departments ⇒ Array<LUSI::API::Course::CourseDepartment>
Returns the major departments for the module/scheme of study
288 289 290 |
# File 'lib/lusi_api/course.rb', line 288 def major_departments self.course_departments.select { |course_department| course_department.is_major_department } end |