Last active
May 17, 2017 18:55
-
-
Save joewiz/761e1def4b0e5f138880b314b8449169 to your computer and use it in GitHub Desktop.
Use XQuery tumbling windows to create groups of topics to be covered in class meetings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
(: Use tumbling windows to group topics into the number of class meetings for a section of a course. | |
Our case in this example: | |
We have an intensive summer course that needs to cover 12 topics in 3 weeks. It has two sections. | |
The first section meets once per week, so we need to cover 4 topics in each meeting. | |
The query below tells us which topics should be covered at each meeting. | |
For the second section, which meets twice per week, can cover 2 topics at each meeting. | |
(Here, topics listed are the major Chinese dynasties, as sung at https://www.youtube.com/watch?v=xJis9TSw1rE.) | |
:) | |
let $all-topics := ('Shang', 'Zhou', 'Qin', 'Han', 'Sui', 'Tang', 'Song', 'Yuan', 'Ming', 'Qing', 'Republic', 'Mao Zedong') | |
let $topics-per-week := 4 | |
for tumbling window $meeting-topics in $all-topics | |
start at $starting-pos when true() | |
only end at $ending-pos when $ending-pos - $starting-pos + 1 eq $topics-per-week | |
return <meeting-topics>{ string-join($meeting-topics, ', ') }</meeting-topics> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- $topics-per-week: 4 --> | |
<meeting-topics>Shang, Zhou, Qin, Han</meeting-topics> | |
<meeting-topics>Sui, Tang, Song, Yuan</meeting-topics> | |
<meeting-topics>Ming, Qing, Republic, Mao Zedong</meeting-topics> | |
<!-- $topics-per-meeting: 2 --> | |
<meeting-topics>Shang, Zhou</meeting-topics> | |
<meeting-topics>Qin, Han</meeting-topics> | |
<meeting-topics>Sui, Tang</meeting-topics> | |
<meeting-topics>Song, Yuan</meeting-topics> | |
<meeting-topics>Ming, Qing</meeting-topics> | |
<meeting-topics>Republic, Mao Zedong</meeting-topics> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment