Courses/EIMI 25WS/Queries

Revision as of 09:39, 14 November 2025 by Leonie (talk | contribs) (Create page and add inital query)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Total completions

Query gets the count of total number of completions for a node by students that participate in EIMI 25WS and show that counts using colors.

When commenting out the variable ?completions the sizing of the nodes is removed, but also the tooltips that show the number of completions of a node on hover


Items used: EIMI 25/26WS (Q2113)

Properties used: includes (P14), depends on (P1), has completed (P12), participates in (P25)

#defaultView:Graph
PREFIX wd: <https://graphit.ur.de/entity/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
SELECT distinct 
?topic ?topicLabel ?rgb1 
?completions # for sizing and value tooltip on hover
?dependency ?dependencyLabel
WHERE {
  # color items according to their number of completions

  { wd:Q2113 wdt:P14/wdt:P14 ?topic. 
    OPTIONAL { 
      ?topic wdt:P1 ?dependency 
      BIND (IF(EXISTS{?user wdt:P12 ?dependency}, "008F0E", "ffffff") as ?rgb2)
    }
  } UNION {
    # get all dependencies not directly included ( for sizing they need to be in the same column as ?topic ()
    wd:Q2113 wdt:P14/wdt:P14 ?item.
    ?item wdt:P1 ?topic.
    FILTER NOT EXISTS {  wd:Q2113 wdt:P14/wdt:P14 ?topic. } 
  }
  
  OPTIONAL {
    SELECT ?topic ?topicLabel (COUNT(DISTINCT ?student) AS ?completions) WHERE {
      ?student wdt:P25 wd:Q2113.
      ?student wdt:P12 ?topic.  
    } GROUP BY ?topic ?topicLabel
  }
  BIND(IF(!BOUND(?completions), 0, ?completions) as ?completions).
  
  # Styling
    bind (if(?completions > 50, "60BB3F",
          if(?completions > 35, "81D064",
          if(?completions > 20, "9FE586", # green
          if(?completions > 10 , "B7ECA5", 
          if(?completions > 5 , "CFF2C3", 
          if(?completions > 2 , "E7F9E1",
       "FFFFFF" )))))) as ?rgb1).
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!