Hotfix: parse oid when only one given

The function `show_detail` for courses was expecting an array of
lecturer oids. When it got only one and therefore not an array but an
int, the line `@lecturers_oid.each` would fail to parse the variable
because it is not an array.
This commit is contained in:
Tobias Eidelpes 2020-05-29 10:43:34 +02:00
parent ae217a60ea
commit cbcc7c3d25

View File

@ -29,12 +29,20 @@ class Crawlers::CoursesCrawlerController < Crawlers::TissCrawlerController
@lecturers_oid = @course['lecturers']['oid']
@lecturers_names = []
puts @lecturers_oid
if @lecturers_oid != nil
if @lecturers_oid.is_a?(Array)
# In case @lecturers_oid contains multiple items
@lecturers_oid.each do |item|
# For each org id get the associated name
puts TissCrawler.get_oid_name(item)
@lecturers_names << (TissCrawler.get_oid_name(item))
end
else
# In case @lecturers_oid only contains one item
@lecturers_names << (TissCrawler.get_oid_name(@lecturers_oid))
end
end
# Host is needed for image rendering