class Classes
Attributes
course_unit_id[R]
course_unit_short_name[R]
full_name[R]
lective_semester_id[R]
main_teacher[R]
main_teacher_id[R]
main_teacher_short_name[R]
max_group_size[R]
Public Class Methods
new(json_info)
click to toggle source
Initiate an instance of Classes
based upon +json_info* that can be an hash or a JSON string.
Calls superclass method
Element::new
# File lib/Appolo/Models/main_model/classes.rb, line 22 def initialize(json_info) json_data = check_json_info json_info super(json_data[ModelUtils::ID], json_data[ModelUtils::CLASS_NAME], json_data[ModelUtils::LINKS], @@type_of_links) @full_name = json_data[ModelUtils::FULL_NAME] @course_unit_short_name = json_data[ModelUtils::COURSE_UNIT_SHORT_NAME] @main_teacher_short_name = json_data[ModelUtils::MAIN_TEACHER_SHORT_NAME] @course_unit_id = json_data[ModelUtils::COURSE_UNIT_ID] @lective_semester_id = json_data[ModelUtils::LECTIVE_SEMESTER_ID] @main_teacher_id = json_data[ModelUtils::MAIN_TEACHER_ID] @max_group_size = json_data[ModelUtils::MAX_GROUP_SIZE] #TODO aceder ao Links do super e retirar de la´ o link respectivo teacher_self_link = json_data[ModelUtils::LINKS] teacher_self_link = teacher_self_link[ModelUtils::MAIN_TEACHER] unless teacher_self_link.nil? #TODO get the id and check if a request has been made in the past teacher_self_response = RestClient.get teacher_self_link @main_teacher = Teacher.new teacher_self_response end end
Public Instance Methods
lectures()
click to toggle source
Returns all the lectures related to this class.
# File lib/Appolo/Models/main_model/classes.rb, line 72 def lectures response_all_lectures = RestClient.get @links.lectures all_lectures = JSON.parse response_all_lectures temp = [] all_lectures['classLectures'].each do |lecture| temp.push(Lecture.new(lecture)) end #Parallel.each(all_lectures['classLectures'], :in_processes => 1){ # |lecture| temp.push(Lecture.new(lecture)) #} temp end
participants()
click to toggle source
Returns all the students related to this class.
# File lib/Appolo/Models/main_model/classes.rb, line 57 def participants response_all_participants = RestClient.get @links.participants all_participants = JSON.parse response_all_participants temp = [] all_participants['students'].each do |participant| temp.push(Student.new(participant)) end #temp = Parallel.each(all_participants['students'], :in_processes => 1){ # |participant| temp.push(Student.new(participant)) #} temp end
resources()
click to toggle source
Returns all the resources related to a certain class.
# File lib/Appolo/Models/main_model/classes.rb, line 89 def resources response_all_resources = RestClient.get @links.resources all_resources = JSON.parse response_all_resources temp = Array.new all_resources['classResources'].each do |resource| temp.push(Resource.new(resource)) end #Parallel.each(all_resources['classResources'], :in_processes => 1){ # |resource| temp << Resource.new(resource) #} temp end
to_s()
click to toggle source
Small representation of the Classes
object
# File lib/Appolo/Models/main_model/classes.rb, line 51 def to_s "#{@id} - #{@full_name} - #{@main_teacher_short_name}" end