Skip to content
Snippets Groups Projects
Commit 09954368 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

add method for find collections of a learning object and rendering json

parent c6ca05bd
No related branches found
No related tags found
No related merge requests found
class LearningObjectsController < ApplicationController
before_action :set_learning_object, only: [:show, :edit, :update, :destroy, :like, :bookmark]
before_action :set_learning_object, only: [:show, :edit, :update, :destroy, :like, :bookmarks, :collections]
after_action :increment_learning_object_views, only: [:show]
before_action :authenticate_user!, except: [:index, :show, :like]
before_action :set_complaint_messages, only: :show
......@@ -88,6 +88,11 @@ class LearningObjectsController < ApplicationController
end
end
# GET /learning_objects/1/collections.json
def collections
@collections = @learning_object.collections
end
private
# Use callbacks to share common setup or constraints between actions.
......
......@@ -16,6 +16,10 @@ class LearningObject
super(params.merge(defaults))
end
def collections
collection_repository.find_by_learning_object self
end
def like(user)
learning_object_repository.like user, self
end
......
......@@ -43,7 +43,16 @@ module OrientDb
def all(user)
query = sprintf("select * from (select expand(in('BelongsTo')) from %s) where name<>'Bookmarks'", user.rid)
objects = build_objects connection.query(query)
build_objects connection.query(query)
end
def find_by_learning_object(learning_object)
if learning_object.id.to_s.empty?
return []
end
query = sprintf("select * from %s where learning_objects contains %s", odb_class, learning_object.id)
build_objects connection.query(query)
end
def bookmarks(user)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment