Class: SakaiInfo::QuizAttemptItemAttachment

Inherits:
SakaiObject
  • Object
show all
Includes:
ModProps
Defined in:
lib/sakai-info/quiz.rb

Instance Attribute Summary collapse

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModProps

included

Methods inherited from SakaiObject

all_serializations, #dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml

Constructor Details

#initialize(dbrow) ⇒ QuizAttemptItemAttachment

Returns a new instance of QuizAttemptItemAttachment.



1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
# File 'lib/sakai-info/quiz.rb', line 1047

def initialize(dbrow)
  @dbrow = dbrow

  @id = dbrow[:mediaid]
  @quiz_attempt_item_id = dbrow[:itemgradingid]
  @status = dbrow[:status]
  @filepath = dbrow[:location]
  @filename = dbrow[:filename]
  @filesize = dbrow[:filesize]
  @mimetype = dbrow[:mimetype]
  @description = dbrow[:description]
end

Instance Attribute Details

#dbrowObject (readonly)

Returns the value of attribute dbrow.



1033
1034
1035
# File 'lib/sakai-info/quiz.rb', line 1033

def dbrow
  @dbrow
end

#descriptionObject (readonly)

Returns the value of attribute description.



1034
1035
1036
# File 'lib/sakai-info/quiz.rb', line 1034

def description
  @description
end

#filenameObject (readonly)

Returns the value of attribute filename.



1033
1034
1035
# File 'lib/sakai-info/quiz.rb', line 1033

def filename
  @filename
end

#filepathObject (readonly)

Returns the value of attribute filepath.



1033
1034
1035
# File 'lib/sakai-info/quiz.rb', line 1033

def filepath
  @filepath
end

#filesizeObject (readonly)

Returns the value of attribute filesize.



1033
1034
1035
# File 'lib/sakai-info/quiz.rb', line 1033

def filesize
  @filesize
end

#mimetypeObject (readonly)

Returns the value of attribute mimetype.



1033
1034
1035
# File 'lib/sakai-info/quiz.rb', line 1033

def mimetype
  @mimetype
end

#quiz_attempt_item_idObject (readonly)

Returns the value of attribute quiz_attempt_item_id.



1034
1035
1036
# File 'lib/sakai-info/quiz.rb', line 1034

def quiz_attempt_item_id
  @quiz_attempt_item_id
end

#statusObject (readonly)

Returns the value of attribute status.



1033
1034
1035
# File 'lib/sakai-info/quiz.rb', line 1033

def status
  @status
end

Class Method Details

.clear_cacheObject



1042
1043
1044
# File 'lib/sakai-info/quiz.rb', line 1042

def self.clear_cache
  @@cache = {}
end

.find(id) ⇒ Object



1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
# File 'lib/sakai-info/quiz.rb', line 1069

def self.find(id)
  id = id.to_s
  if @@cache[id].nil?
    row = DB.connect[:sam_media_t].where(:mediaid => id).first
    if row.nil?
      raise ObjectNotFoundException.new(QuizAttemptItemAttachment, id)
    end

    @@cache[id] = QuizAttemptItemAttachment.new(row)
  end
  @@cache[id]
end

.find_by_quiz_attempt_item_id(quiz_attempt_item_id) ⇒ Object



1064
1065
1066
1067
# File 'lib/sakai-info/quiz.rb', line 1064

def self.find_by_quiz_attempt_item_id(quiz_attempt_item_id)
  DB.connect[:sam_media_t].where(:itemgradingid => quiz_attempt_item_id).
    all.collect { |row| QuizAttemptItemAttachment.new(row) }
end

Instance Method Details

#attempt_item_summary_serializationObject



1101
1102
1103
1104
1105
1106
# File 'lib/sakai-info/quiz.rb', line 1101

def attempt_item_summary_serialization
  {
    "id" => self.id,
    "filename" => self.filename
  }
end

#default_serializationObject



1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
# File 'lib/sakai-info/quiz.rb', line 1082

def default_serialization
  {
    "id" => self.id,
    "filename" => self.filename,
    "mimetype" => self.mimetype,
    "filesize" => self.filesize,
    "status" => self.status,
    "quiz_attempt_item" => self.quiz_attempt_item.serialize(:summary)
  }
end

#quiz_attempt_itemObject



1060
1061
1062
# File 'lib/sakai-info/quiz.rb', line 1060

def quiz_attempt_item
  @quiz_attempt_item ||= QuizAttemptItem.find(@quiz_attempt_item_id)
end

#summary_serializationObject



1093
1094
1095
1096
1097
1098
1099
# File 'lib/sakai-info/quiz.rb', line 1093

def summary_serialization
  {
    "id" => self.id,
    "filename" => self.filename,
    "quiz_attempt_item_id" => self.quiz_attempt_item_id
  }
end