Class: Mumuki::Classroom::Submission

Inherits:
Document
  • Object
show all
Extended by:
WithSubmissionProcess
Defined in:
lib/mumuki/classroom/models/submission.rb

Instance Method Summary collapse

Methods included from WithSubmissionProcess

assignment_from, assignment_query, assignment_without_submission_from, course_slug, exercise_from, find_student_from, find_submission_course!, guide_from, guide_progress_from, guide_progress_query, organization, process!, stats_from, student_from, student_stats_for, submission_from, uid, update_assignment, update_guide_progress, update_student_last_assignment, update_student_progress

Methods inherited from Document

inherited, whitelist_attributes

Instance Method Details

#add_message!(message) ⇒ Object



31
32
33
# File 'lib/mumuki/classroom/models/submission.rb', line 31

def add_message!(message)
  self.messages << Mumuki::Classroom::Message.new(message.as_json)
end

#evaluate_manually!(comment, status) ⇒ Object



26
27
28
29
# File 'lib/mumuki/classroom/models/submission.rb', line 26

def evaluate_manually!(comment, status)
  self.status = status
  self.manual_evaluation = comment
end

#expectation_resultsObject



35
36
37
38
39
# File 'lib/mumuki/classroom/models/submission.rb', line 35

def expectation_results
  self[:expectation_results]&.map do |expectation|
    {html: Mulang::Expectation.parse(expectation).translate, result: expectation['result']} # TODO translate with keywords
  end
end

#manual_evaluationObject



50
51
52
# File 'lib/mumuki/classroom/models/submission.rb', line 50

def manual_evaluation
  Mumukit::ContentType::Markdown.to_html(self[:manual_evaluation]) if self[:manual_evaluation]
end

#thread(language) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/mumuki/classroom/models/submission.rb', line 41

def thread(language)
  {
    status: status,
    content: Mumukit::ContentType::Markdown.to_html(Mumukit::ContentType::Markdown.highlighted_code language, content || ''),
    messages: messages,
    created_at: created_at
  } if messages.present?
end

#with_full_messages(user) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/mumuki/classroom/models/submission.rb', line 54

def with_full_messages(user)
  self.tap do |submission|
    submission[:messages] = messages.map do |message|
      message.with_full_messages user
    end
  end
end