Jump to content

Courses/CGBV SS24/Graph

Revision as of 11:53, 23 May 2024 by Leonie (talk | contribs) (→"Interests" and "Knowledge": convert to Try It!)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Contains queries about the graph of the "CGBV SS24" course to help debug and structure it.

All Sessions

Returns a graph containing all sessions included in the course, as well as all included topics. {{#widget:SPARQLquery|code=

  1. defaultView:Graph

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> select distinct ?session ?sessionLabel ?rgb ?shape ?date ?item ?itemLabel ?image # ?res ?resLabel where {

 wd:Q932 wdt:P14 ?session.
 ?session wdt:P3 wd:Q427.
 ?session wdt:P19 ?date.
 OPTIONAL {?session wdt:P14 ?item.
          OPTIONAL {?item wdt:P11 ?image } }
 
 # styling
 BIND("ECEDFF" as ?rgb)
 BIND("box" as ?shape)
 service wikibase:label { bd:serviceParam wikibase:language "en".}

} |caption=All existing CGBV SS24 sessions with included topics }}

All Categories

Returns a graph with all categories included in the course. See the query here

Indegrees

Returns a graph that uses the indegrees to size items. I.e. the size of a node depends on how many prerequisites it has. {{#widget:SPARQLquery|code=

  1. defaultView:Graph

PREFIX wd: <https://graphit.ur.de/entity/> PREFIX wdt: <https://graphit.ur.de/prop/direct/> SELECT distinct ?topic ?topicLabel ?rgb1 # ?shape1 ?dCount ?dependency ?dependencyLabel # ?rgb2 ?shape2 ?tCount

  1. ?category ?categoryLabel ?rgb3 ?shape3

WHERE {

 wd:Q932 wdt:P14/wdt:P14 ?topic.
 OPTIONAL { ?topic wdt:P1 ?dependency }
 
 OPTIONAL {
   SELECT ?topic ?topicLabel (COUNT(DISTINCT ?pre) as ?dCount) WHERE {
     ?pre wdt:P1 ?topic.
   } GROUP BY ?topic ?topicLabel
 } # number of items that -depend-on-> ?topic 
 BIND(IF(!BOUND(?dCount), 0, ?dCount) as ?dCount).
 
 # STYLING # 
 BIND (if(?dCount = 0, "FFFFFF", # white
         if(?dCount = 1, "e6e6e6", 
         if(?dCount = 2, "DFDFDF",
         if(?dCount = 3, "b3b3b3",  
         if(?dCount = 4, "9F9F9F",
         if(?dCount = 5, "808080", 
         if(?dCount = 6,  "606060", 
         if(?dCount = 7, "4d4d4d", 
         if(?dCount = 8, "333333", 
         if(?dCount = 9, "1919191", 
         if(?dCount = 10, "202020",  
         if(?dCount > 10, "292929",  
      "FFFFFF" )))))))))))) as ?rgb1).
 
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

} }} Nodes that aren't cicles are items, that are linked to course-items, but are themselves not included in the course.

Items

Orphans

Unlinked Items No dependencies
{{#widget:SPARQLquery|code=
  1. All items that don't link to another item (no dependency)
  2. defaultView:Table

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> SELECT DISTINCT ?item ?itemLabel # ?dependency WHERE {

 wd:Q932 wdt:P14/wdt:P14 ?item.
 
 MINUS {?dependency wdt:P1 ?item}. # Remove all items that have the ?source as a dependency
 MINUS {?item wdt:P1 ?dependency}. # Remove all ?source's that have a dependency
 
 service wikibase:label { bd:serviceParam wikibase:language "en" }

}

caption=Items that don't depend on and aren't depended on height=25vh

}}

{{#widget:SPARQLquery|code=
  1. defaultView:Table
  2. sources that don't -depend-on-> other item

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> SELECT DISTINCT ?item ?itemLabel # ?dependency WHERE {

 wd:Q932 wdt:P14/wdt:P14 ?item.
 MINUS {?item wdt:P1 ?dependency.}
 
 service wikibase:label { bd:serviceParam wikibase:language "en" }

}

caption=Items that don't depend on other items height=25vh

}}

Link to the query Link to the query

Resources

All Resources

Returns a table with all resources that are linked to from inside the course.

{{#if: CGBV 24SS (Q932) | Items used: CGBV 24SS (Q932) | }}

{{#if: includes (P14), resource (P21), url (P20), instance of (P3) | Properties used: includes (P14), resource (P21), url (P20), instance of (P3) | }}

{{#if:|
{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX p: <https://graphit.ur.de/prop/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX p: <https://graphit.ur.de/prop/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX q: <https://graphit.ur.de/prop/qualifier/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX q: <https://graphit.ur.de/prop/qualifier/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX v: <https://graphit.ur.de/prop/statement/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX v: <https://graphit.ur.de/prop/statement/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
|}}}}
}}#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT DISTINCT ?item ?itemLabel ?resource ?resourceLabel ?alias ?url ?type ?typeLabel # ?resLabelLength 
WHERE {
  wd:Q932 wdt:P14/wdt:P14 ?item.
  ?item wdt:P21 ?resource.
  OPTIONAL {?resource wdt:P20 ?link.
            BIND("true" as ?url) }
  
  OPTIONAL {?resource wdt:P3 ?type.}
  OPTIONAL {?resource skos:altLabel ?alias.}

  service wikibase:label { bd:serviceParam wikibase:language "en" }
} ORDER BY ASC(?resourceLabel)

Try it!


Items without Resources

Returns a table with all items in the CGBV 24SS course, that don't link to a resource. {{#widget:SPARQLquery|code=

  1. All CGBV-SS24 Items with no linked resources
  2. defaultView:Table

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> SELECT DISTINCT ?item ?itemLabel ?resource ?resourceLabel WHERE {

 wd:Q932 wdt:P14/wdt:P14 ?item. # select al course items
 MINUS {?item wdt:P21 ?resource.} # remove all with resources
 
 service wikibase:label { bd:serviceParam wikibase:language "en". }

} }}

"Interests" and "Knowledge"

{{#switch: {{{type}}} | warn = ⚠️ | info = ℹ️ | #default = ✒️ }} The plot doesn't really show overlapping points

{{#if: CGBV 24SS (Q932) | Items used: CGBV 24SS (Q932) | }}

{{#if: includes (P14), has completed (P12), interested in (P23) | Properties used: includes (P14), has completed (P12), interested in (P23) | }}

{{#if:|
{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX p: <https://graphit.ur.de/prop/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX p: <https://graphit.ur.de/prop/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX q: <https://graphit.ur.de/prop/qualifier/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX q: <https://graphit.ur.de/prop/qualifier/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX v: <https://graphit.ur.de/prop/statement/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX v: <https://graphit.ur.de/prop/statement/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
|}}}}
}}#defaultView:ScatterChart
PREFIX wd: <https://graphit.ur.de/entity/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>

SELECT DISTINCT ?known ?interests ?item ?itemLabel # ?known ?interests ?item ?itemLabel 
WHERE {
  wd:Q932 wdt:P14/wdt:P14 ?item.
  OPTIONAL {
    SELECT ?item ?itemLabel (COUNT(DISTINCT ?student) as ?known) WHERE {
      ?student wdt:P12 ?item.
    } GROUP BY ?item ?itemLabel
  }
  OPTIONAL {
    SELECT ?item ?itemLabel (COUNT(DISTINCT ?student) as ?interests) WHERE {
      ?student wdt:P23 ?item.
    } GROUP BY ?item ?itemLabel
  }.
  BIND (IF(!BOUND(?interests), 0, ?interest) as ?interests).
  BIND (IF(!BOUND(?known), 0, ?known) as ?known).
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!


Alternative Visualization {{#widget:SPARQLquery|code=

  1. defaultView:Graph

PREFIX wd: <https://graphit.ur.de/entity/> PREFIX wdt: <https://graphit.ur.de/prop/direct/>

SELECT DISTINCT ?sum ?item ?itemLabel ?rgb ?known ?interests WHERE {

 wd:Q932 wdt:P14/wdt:P14 ?item.
 OPTIONAL {
   SELECT ?item ?itemLabel (COUNT(DISTINCT ?student) as ?known) WHERE {
     ?student wdt:P12 ?item.
   } GROUP BY ?item ?itemLabel
 }
 OPTIONAL {
   SELECT ?item ?itemLabel (COUNT(DISTINCT ?student) as ?interests) WHERE {
     ?student wdt:P23 ?item.
   } GROUP BY ?item ?itemLabel
 }.
 BIND (IF(!BOUND(?interests), 0, ?interest) as ?interests).
 BIND (IF(!BOUND(?known), 0, ?known) as ?known).  
 BIND ( ?interests + ?known as ?sum)
 
 # STYLING # 
 BIND (if(?interests = 0 && ?known = 0, "FFFFFF", # white
         if(?interests = ?known, "DFDFDF", # grey
         if(?interests = 1 && ?known = 0, "e3ffd9", # light green
         if(?interests = 0 && ?known = 1, "F9DCDF", # light red
         if(?interests+1 = ?known,  "BECF96", # red+green -> both
         if(?interests < ?known, "9FE586", # green, bc. knowledge is "good" :D
         if(?interests > ?known, "F0A8AF", # red   
      "FFFFFF" ))))))) as ?rgb).
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

} ORDER BY DESC(?sum) }} Interests and knowledge are mapped to color and to size. The size equals to the sum of interest and knowledge.

A red node means that more students are interested in a topic. A green node means that more students know a topic.

A olive node means that one more student knows a topic than are interested in.

A gray node meant that the same amount of students know/are interested in a topic