forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 18
Coursegraph Queries
Tony Kim edited this page Aug 31, 2018
·
21 revisions
For information on how to write queries in Cypher (Neo4j's query language), reference the following:
- EdX's Introduction to Coursegraph
- Neo4j's Intro to Cypher
- Neo4j Cypher Refcard
- Cypher Section of Neo4j Developer Manual
For EdX's sample queries, look here.
What follows is a list of queries that can be run on our courses in addition to EdX's list.
MATCH (n)
SET n.name = n.display_name
RETURN n
These queries are primitive and will need more refinement.
MATCH (c:course) -[:PARENT_OF*]-> (n:sequential)
WHERE
n.due > c.start
AND n.due <= c.end
RETURN n.display_name as valid_due_dates
MATCH (c:course) -[:PARENT_OF*]-> (n:sequential)
WHERE
n.due <= c.start
AND n.due > c.end
RETURN n.display_name as invalid_due_dates
MATCH (n)
WHERE EXISTS(n.advanced_modules)
RETURN n.course_key as course_name, n.advanced_modules as modules
MATCH
(c:course) -[:PARENT_OF*]-> (o:openassessment)
RETURN
count(o)
MATCH
(c:course) -[:PARENT_OF*]-> (n:item)
RETURN
distinct(n.block_type) as blockType,
count(n.block_type) as number
order by
number DESC
** To localize query to one course in particular, add a WHERE c.course_key = "INSERT COURSE KEY HERE"
before RETURN
.
MATCH
(c:course)-[:PARENT_OF*]->(h:item)
WHERE
h.data CONTAINS 'modal-content'
RETURN
distinct(h.course_key)
MATCH
(c:course)-[:PARENT_OF*]->(h:item)
WHERE
h.data CONTAINS 'modal-content'
RETURN
h.course_key,
h.data,
"https://studio.stage.lagunita.stanford.edu/container/" + h.location as link
MATCH
(c:course) -[:PARENT_OF*]-> (n:item)
WHERE
c.course_key = "course-v1:edX+DemoX+Demo_Course"
AND n.edited_on >= '2018-08-01' // or any recent date
RETURN
n.block_type as block_type,
n.display_name as display_name,
n.location as location
LIMIT 25
MATCH
(c:course) -[:PARENT_OF*]-> (n:item)
WHERE
n.edited_on >= '2018-08-01' // or any recent date
RETURN
n.block_type as block_type,
n.display_name as display_name,
n.course_key as course_key,
n.location as location
LIMIT 25
MATCH
sibs = (c:course)-[:PARENT_OF*]->()-[r:PRECEDES]->()
WHERE
c.course_key = "course-v1:edX+DemoX+Demo_Course"
RETURN
count(sibs)
MATCH
sibs = (c:course)-[:PARENT_OF]->(n:item)-[:PARENT_OF]->()-[:PRECEDES]->()
WHERE
c.course_key = "course-v1:edX+DemoX+Demo_Course"
RETURN
(n)-[:PARENT_OF]->()
MATCH
sibs = (c:course)-[:PARENT_OF]->(n:item)-[:PARENT_OF]->()-[:PRECEDES]->()
WHERE
c.course_key = "course-v1:edX+DemoX+Demo_Course"
RETURN
sibs