app/models/guide.rb in mumuki-laboratory-5.6.1 vs app/models/guide.rb in mumuki-laboratory-5.6.2
- old
+ new
@@ -70,10 +70,12 @@
Exercise.class_for(e['type']).new(guide_id: self.id, bibliotheca_id: e['id'])
exercise.import_from_json! (i+1), e
end
- self.exercises.where('number > ?', json['exercises'].size).destroy_all
+ new_ids = json['exercises'].map { |it| it['id'] }
+ self.exercises.where.not(bibliotheca_id: new_ids).destroy_all
+
reload
end
def as_lesson_of(topic)
topic.lessons.find_by(guide_id: id) || Lesson.new(guide: self, topic: topic)