;; this allows us to use Java primitives written using the NetLogo API. ;; see the NetLogo Features section in the information tab for more information. __import "Polling Advanced.jar" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; The hard coded sample questions are the first section of code ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Variable and Breed declarations ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; globals [ current-question ;; index of the current question in the question list question-list ;; list of all the questions. Each question is itself a list. steps-locked? ;; are the clients locked to the host's question? voted?-color ;; color of turtles which have voted not-voted?-color ;; color of turtles which haven't voted activity ;; how many votes have been cast since last autosave? auto-saving? ;; autosave poll data? auto-save-file ;; base file name for the autosave files auto-save-directory ;; directory for autosave files auto-saving-web? auto-save-web ;; full directory information for auto-saving polls as HTML web-response-file web-responding? web-response-data web-response-how-many? web-processing? web-questions names-showing? ;; are client names being shown in the graphics window? graphics-display ;; what mode is the graphics display in? plot-showing? ;; are the votes being shown in the plot? plot-dirty? ;; does the plot need a redraw? plot-first ;; first item included in the special mode data plot plot-last ;; last item included in the special mode data plot plot-mode-is? ;; what plot mode is the model in? sort-up ;; used to sort turtles up / down according to if the word is in their string response sort-right ;; used to sort turtles right / left according to if the word is in their string response save-state-var save-state-value tmp1 tmp2 tmp3 tmp4 ] breeds [ poll-clients non-clients ] turtles-own [ user-id ;; unique id, input by the client when they log in, to identify each student turtle slider-value ;; the value of the client's choice slider my-choices ;; list of my choices for each question my-current-question ;; which question is the student currently on? ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Sample Questions Section ;;;;;; at the beginning to make them easy to find and edit ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to load-sample-questions set question-list [ ["Sample Question 1" "Poller"] ["Sample Question 2" "Web Text"] ["Sample Question 3" "Likert" 5] ["Sample Question 4" "Web Number"] ] set current-question 0 ask turtles [clear-my-data set-my-current-question 0] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Setup Functions ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Startup ONLY runs when the model is first loaded. It initializes the ;; model's network capabilities and clears everything. to startup setup end ;; give the user some information about what the setup button does so they can ;; know whether they want to proceed before actually doing the setup ;; If you are tired of this prompt, change the code in the SETUP button from ;; setup-prompt to setup. to setup-prompt if user-yes-or-no? ("The SETUP button should only be used when starting " + "over with a new group and new questions (such as a" + "different course) since ALL data is lost.\n" + "Are you sure you want to SETUP?") [ setup ] end ;; Initializes the display and variables. ;; Also loads the data lists, if so desired. ;; Only called by SETUP-PROMPT, which is called by the setup button, and STARTUP. to setup hubnet-set-client-interface "COMPUTER" [ "clients/Polling Advanced client.nlogo" ] hubnet-reset ca cc setup-vars load-questions-prompt ; load-sample-questions ;this is here to make life easier on Walter end to walkthrough startup-walkthrough setup-vars-walkthrough end to startup-walkthrough if user-yes-or-no? "Would you like to load questions?" [load-questions-prompt] ifelse user-yes-or-no? "Would you like to AUTOSAVE world data?" [auto-save-prompt] [set auto-save? false] end to setup-vars-walkthrough ifelse user-yes-or-no? "Allow students to change their responses?" [ set allow-change? true] [ set allow-change? false] ifelse user-yes-or-no? "Plot student responses?" [ set show-data? true set plot-showing? show-data?] [ set show-data? false set plot-showing? show-data?] ifelse user-yes-or-no? "Allow students to see questions at their own pace?" [ set lock-step? false set steps-locked? false] [ set lock-step? true set steps-locked? true] ifelse user-yes-or-no? "See student names?" [ set see-names? true] [ set see-names? false] end ;; initialize global variables to setup-vars set not-voted?-color green - 2 set voted?-color red + 2 set plot-showing? show-data? set plot-dirty? true set steps-locked? lock-step? set activity 0 set auto-saving? false set auto-save-file "" set auto-save-directory "" set auto-saving-web? false set auto-save-web "" set names-showing? see-names? set graphics-display Turtle-display set plot-mode "Histogram" set plot-mode-is? plot-mode set sort-up "" set sort-right "" set web-response-file "" set web-responding? false set web-responses? false ;this is to prevent problems in startup, as there's no "web-page-exists?" reporter set web-processing? false set web-questions [] clear-all-data-and-questions end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Clearing Data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; give the user some information about what the clear clients button does so they can ;; know whether they want to proceed before actually doing the setup ;; If you are tired of this prompt, change the code in the CLEAR CLIENTS button from ;; clear-clients-prompt to clear-clients. to clear-clients-prompt if user-yes-or-no? ("The CLEAR CLIENTS button should only be used when starting " + "over with a new group (such as a new set of students) since " + "all STUDENT data is lost, but questions are saved.\n" + "Are you sure you want to CLEAR CLIENTS?") [ clear-clients ] end ;; Clears the plots, clears the command center, and kills all turtles and patches. ;; Clients are dead in the water - they must exit and relogin. to clear-clients clear-plot cg cc end ;; give the user some information about what the clear questions button does so they can ;; know whether they want to proceed before actually doing the clear questions ;; If you are tired of this prompt, change the code in the CLEAR QUESTIONS button from ;; clear-all-data-and-questions-prompt to clear-all-data-and-questions-clients. to clear-all-data-and-questions-prompt if user-yes-or-no? ("The CLEAR QUESTIONS button should only be used when starting " + "over with the same students but new questions since " + "all question and poll data is lost, but clients are saved.\n" + "Are you sure you want to CLEAR QUESTIONS?") [ clear-all-data-and-questions ] end to clear-all-data-and-questions clear-plot hubnet-broadcast "Question" "" hubnet-broadcast "Question Two" "" hubnet-broadcast "Question Three" "" hubnet-broadcast "Question Number" "" hubnet-broadcast "Current Choice" "" hubnet-broadcast "Typed-Response" "Click on the CHANGE button\n(in the top right corner of this widget)\nto type a response." set activity 0 set current-question 0 set question-list [] set sort-up "" set sort-right "" ask turtles [ clear-my-data ] end to clear-my-data ;; turtle procedure set color not-voted?-color set my-choices [] repeat length question-list [ set my-choices lput false my-choices ] ifelse length question-list = 0 [ set my-current-question -1] [ set my-current-question 0] end ;; give the user some information about what the clear current data button does so they can ;; know whether they want to proceed before actually doing the clear current data ;; If you are tired of this prompt, change the code in the CLEAR CURRENT DATA button from ;; clear-current-data-prompt to clear-current-data. to clear-current-data-prompt if user-yes-or-no? ("The CLEAR CURRENT DATA button should only be used when clearing " + "the responses to the question that the TEACHER is currently viewing. " + "Student responses to this question will be lost, but the question" + "itself and student logins are unchanged.\n" + "Are you sure you want to CLEAR CURRENT DATA?") [ clear-current-data ] end to clear-current-data clear-plot ask turtles [ set my-choices replace-item current-question my-choices false if my-current-question = -1 [set-my-current-question 0] ] set-current-question current-question end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Runtime Procedures ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to go lock-step-listener see-names-listener see-typed-listener ;; Anything from the clients? if length question-list > 0 [listen-clients] plot-mode-listener every 0.5 [ ;; The turtles do whatever MOVEMENTS they're gonna do. turtle-movement-listener show-data-listener ] auto-save-listener if auto-saving? or auto-saving-web? [ if activity >= auto-save-every [ auto-save ] ] web-response-listener every check-web-every * 60 [ if web-responding? [ web-responses-get ] ] end to lock-step-listener ;;check to see if lock-step? status has changed. If it has changed to TRUE, then adjust clients. if lock-step? = true and steps-locked? = false [ set steps-locked? true ask turtles [ set-my-current-question current-question ] ] if lock-step? = false and steps-locked? = true [ set steps-locked? false ] end to see-names-listener ifelse see-names? [ if not names-showing? [ ask turtles [ set label user-id + " "] set names-showing? see-names? ] ] [ if names-showing? [ ask turtles [ set label ""] set names-showing? see-names? ] ] end to see-typed-listener locals [ show-teacher] if mouse-down? [ wait .35 ;this wait is necessary to keep the popup from interrupting the mouse-down? reporter, ;which would prevent it from resetting to false if any? turtles-at mouse-xcor mouse-ycor [ ask random-one-of turtles-at mouse-xcor mouse-ycor [ set show-teacher item current-question my-choices ] user-message show-teacher ] wait .25 ] end to plot-mode-listener if plot-mode-is? != plot-mode [ if plot-mode = "Average" [ plot-average-prompt ] set plot-mode-is? plot-mode set plot-dirty? true ] end to show-data-listener ;; Check to see if the poll data is to be displayed. ifelse show-data? [ if not plot-showing? [ set plot-showing? true set plot-dirty? true ] if plot-dirty? [ set plot-dirty? false do-plot ] ] [ if plot-showing? [ set plot-showing? false clear-plot ] ] end to turtle-movement-listener if not (graphics-display = Turtle-display) [ set graphics-display Turtle-display if graphics-display = "Word-Sort" [ if sort-up = "" [set sort-up user-input "Sort up / down word -"] if sort-right = "" [set sort-right user-input "Sort right / left word -"] ] ] if graphics-display = "Sit" [ ask turtles [sit] ] if graphics-display = "Wander" [ ask turtles [wander] ] if graphics-display = "Line-Up" [ ask turtles [line-up] ] if graphics-display = "Word-Sort" [ ask turtles [word-sort] ] end to auto-save-listener if auto-save? and not auto-saving? [ set auto-saving? auto-save? auto-save-prompt ] if auto-saving? and not auto-save? [ ifelse user-yes-or-no? "Do you really want to turn off auto-save world data?" [ set auto-saving? false] [ set auto-save? true ] ] if auto-save-web? and not auto-saving-web? [ set auto-saving-web? auto-save-web? auto-save-web-prompt ] if auto-saving-web? and not auto-save-web? [ ifelse user-yes-or-no? "Do you really want to turn off auto-save responses to web page?" [ set auto-saving-web? false] [ set auto-save-web? true ] ] end to web-response-listener if web-responses? and not web-responding? [ set web-responding? web-responses? load-web-prompt web-responses-get ] if web-responding? and not web-responses? [ ifelse user-yes-or-no? "Do you really want to turn off web-responses?" [ set web-responding? false] [ set web-responses? true ] ] end to save-button-prompt locals [option] set option user-choice ("save QUESTIONS\n" + "save all responses to a WEB page\n" + "save INDividual responses to separate web pages\n" + "save ALL data to a file\n" + "auto-save NOW\n" + "CANCEL" ) ["QUESTIONS" "WEB" "IND" "ALL" "NOW" "CANCEL"] if option = "QUESTIONS" [save-questions-prompt] if option = "WEB" [save-all-responses-web-prompt] if option = "IND" [save-individual-web-prompt] if option = "ALL" [save-world-prompt] if option = "NOW" [auto-save-now] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Turtle Movement procedures ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to sit ifelse color = voted?-color [ while [count turtles-here > 1 or xcor <= 0] [ setxy random-int-or-float screen-edge-x random-int-or-float screen-size-y] ] [ while [count turtles-here > 1 or xcor >= 0] [ setxy (0 - random-int-or-float screen-edge-x) random-int-or-float screen-size-y] ] end to wander ;; turtle procedure rt 90 * random-int-or-float 4 ifelse color = voted?-color [ if xcor <= 0 [ set heading 90 ] ] [ if xcor >= 0 [ set heading 270] ] if not ((any? turtles-at dx dy) or (abs (xcor + dx) > screen-edge-x) or (abs (ycor + dy) > screen-edge-y)) [ fd 1 ] end to line-up set heading 0 ifelse is-number? item current-question my-choices [ ifelse min values-from turtles [item current-question my-choices] < 0 or max values-from turtles [item current-question my-choices] > 10 [ set xcor ((1 + item current-question my-choices - min values-from turtles [item current-question my-choices]) * screen-size-x / (1 + max values-from turtles [item current-question my-choices] - min values-from turtles [item current-question my-choices]) - screen-edge-x)] [ set xcor ((1 + item current-question my-choices) * screen-size-x / 12 - screen-edge-x)] ] [ set xcor -1 * screen-edge-x ] if count turtles-here > 1 [ jump random-int-or-float 4 ] if ((count turtles-at 0 -1 = 0) and (ycor > -1 * screen-edge-y)) [back 1] end to word-sort ifelse not is-string? item current-question my-choices [ while [(count turtles-here > 1) or not (abs xcor <= 3 and abs ycor <= 3) ] [setxy random-int-or-float 7 - 3 random-int-or-float 7 - 3] ] [ if not (sort-up = "") [ ifelse member? sort-up (item current-question my-choices) [ while [(count turtles-here > 1) or (ycor <= 0) or (abs xcor <= 3 and ycor >= 0)] [ set ycor (random-int-or-float screen-edge-y) + 1 set xcor xcor - 1 + random-int-or-float 3 ] ] [ while [(count turtles-here > 1) or (ycor >= 0) or (abs xcor <= 3 and ycor <= 0)] [ set ycor (random-int-or-float screen-edge-y) - screen-edge-y - 1 set xcor xcor - 1 + random-int-or-float 3 ] ] ] if not (sort-right = "") [ ifelse member? sort-right item current-question my-choices [ while [(count turtles-here > 1) or (xcor <= 0) or (xcor >= 0 and abs ycor <= 3)] [ set xcor (random-int-or-float screen-edge-x) + 1 set ycor ycor - 1 + random-int-or-float 3 ] ] [ while [(count turtles-here > 1) or (xcor >= 0) or (xcor <= 0 and abs ycor <= 3)] [ set xcor (random-int-or-float screen-edge-x) - screen-edge-x - 1 set ycor ycor - 1 + random-int-or-float 3 ] ] ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Client Message Processing Procedures ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to listen-clients while [hubnet-message-waiting?] [ hubnet-fetch-message ifelse hubnet-enter-message? [ execute-create ] [ ifelse hubnet-exit-message? [ ask turtles with [user-id = hubnet-message-source] [ die ] set plot-dirty? true ] [ ;; If the client hits the Choose button, then run this code. if hubnet-message-tag = "Choose" [ execute-choose ] ;; Whenever the client adjusts the slider Choice, run this code. if hubnet-message-tag = "Choice" [ change-choice ] if hubnet-message-tag = "Typed-Response" [ execute-type ] ;; If the clients can view questions as they like, then run this code. if steps-locked? = false [ ;; When the client hits the PREV button if hubnet-message-tag = "< 0 [ set-my-current-question my-current-question - 1] ] end to execute-next ask poll-clients with [user-id = hubnet-message-source] [ if my-current-question + 1 < length question-list [ set-my-current-question my-current-question + 1] ] end to update-my-choice-list while [length my-choices < length question-list] ;;be sure that my-choices has enough spots [ set my-choices lput false my-choices ] end to set-my-current-question [n] if n >= 0 and n < length question-list ;;check to be sure that the question number is valid [ update-my-choice-list set my-current-question n ;;if it is, adjust the number the turtle has if breed = poll-clients [ hubnet-send user-id "Question Number" my-current-question send-question (item 0 item my-current-question question-list) ifelse (item my-current-question my-choices) = false ;;display the current choice on the client [ hubnet-send user-id "Current Choice" "" hubnet-send user-id "Typed-Response" "Click on the CHANGE button\n(in the top right corner of this widget)\nto type a response." ] [ if is-number? item my-current-question my-choices [ hubnet-send user-id "Current Choice" (item my-current-question my-choices) hubnet-send user-id "Typed-Response" "Click on the CHANGE button\n(in the top right corner of this widget)\nto type a response." ] if is-string? item my-current-question my-choices [ hubnet-send user-id "Current Choice" "" hubnet-send user-id "Typed-Response" (item my-current-question my-choices) ] ] ] ] end to send-question [question] ifelse length question <= 80 [ hubnet-send user-id "Question" question hubnet-send user-id "Question Two" "" hubnet-send user-id "Question Three" "" ] [ ifelse length question > 80 and length question <= 160 [ hubnet-send user-id "Question" substring question 0 80 hubnet-send user-id "Question Two" substring question 80 (length question) hubnet-send user-id "Question Three" "" ] [ hubnet-send user-id "Question" substring question 0 80 hubnet-send user-id "Question Two" substring question 80 160 hubnet-send user-id "Question Three" substring question 160 (length question) ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Host Questions ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to-report build-question [what-type?] ifelse what-type? = "Likert" [ report (sentence (user-input "Input new question?") (list "Likert" read-from-string user-input "How many items?"))] [ report sentence user-input "Input new question?" what-type? ] end to add-question [what-type?] ;; If the question list is empty as indicated with "", then set to empty list. ;; Add the typed question to question-list ;; Set the host viewed question to be the one just entered. Is this necessary? set question-list lput (build-question what-type?) question-list set-current-question (length question-list - 1) clear-current-data end to set-current-question [n] if n >= 0 and n < length question-list [ set current-question n ask turtles [ ;; If all the clients are supposed to be on the same question, ;; then they switch to the host's question. ;; If not, they only check to be sure that ifelse steps-locked? = true [ set-my-current-question current-question] [ update-my-choice-list ] ifelse (item current-question my-choices) = false [ set color not-voted?-color ] [ set color voted?-color ] ] if plot-showing? [ set plot-dirty? true ] ] end to prev-question if current-question > 0 [ set-current-question current-question - 1] end to next-question if current-question + 1 < length question-list [ set-current-question current-question + 1] end to edit-question locals [option] set option user-choice ("REPLACE - replace this question with a new one. This will clear the poll results for the question\n" + "INSERT - insert a new question and move the current question one position later in the list\n" + "DELETE - delete this question and it's poll results\n") ["REPLACE" "INSERT" "DELETE" "CANCEL"] if option = "REPLACE" [replace-question] if option = "INSERT" [insert-question] if option = "DELETE" [delete-question] end to-report choose-type locals [option] set option user-choice ("What type of question?\n" + "POLLER \n" + "web TEXT \n" + "LIKERT scale \n" + "web NUMBER \n") ["POLLER" "TEXT" "LIKERT" "NUMBER"] if option = "POLLER" [report "Poller"] if option = "TEXT" [report "Web Text"] if option = "LIKERT" [report "Likert"] if option = "NUMBER" [report "Web Number"] end to replace-question set question-list replace-item current-question question-list build-question choose-type clear-current-data ask turtles [set-my-current-question my-current-question] end to insert-question set question-list (sentence (lput (build-question choose-type) (items 0 current-question question-list)) (items current-question length question-list question-list)) ask turtles [ set my-choices sentence (sentence items 0 current-question my-choices false) items current-question length my-choices my-choices if my-current-question >= current-question and steps-locked? = false [set my-current-question my-current-question + 1] ] clear-current-data ask turtles [set-my-current-question my-current-question] end to delete-question set question-list sentence (items 0 current-question question-list) (items (current-question + 1) (length question-list) question-list) ask turtles [ set my-choices sentence (items 0 current-question my-choices) (items (current-question + 1) (length my-choices) my-choices) ] if current-question = length question-list [set current-question (length question-list - 1)] ask turtles [ if my-current-question > current-question [set my-current-question (my-current-question - 1)]] set-current-question current-question ask turtles [set-my-current-question my-current-question] if length question-list = 0 [ clear-all-data-and-questions] end ;; reports items x through y - 1 of the list somelist ;; if x and y are the same, it reports an empty list to-report items [x y somelist] locals [n buildlist] set n 0 set buildlist [] repeat (y - x) [ set buildlist lput (item (x + n) somelist) buildlist set n n + 1 ] report buildlist end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Plotting Procedures ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to do-plot if plot-mode-is? = "Histogram" [do-one-item-histogram] if plot-mode-is? = "Average" [do-multi-item-average] end to do-one-item-histogram locals [current-data] clear-plot if length filter [is-number? ?] values-from turtles [item current-question my-choices] > 0 [ if max values-from turtles [item current-question my-choices] > 10 [ set-plot-x-range plot-x-min (ceiling max values-from turtles [item current-question my-choices] + 1) ] if min values-from turtles [item current-question my-choices] < 0 [ set-plot-x-range (floor min values-from turtles [item current-question my-choices]) plot-x-max] set current-data values-from turtles [item current-question my-choices] if not empty? remove false current-data [ set-current-plot-pen "data" histogram-list current-data ;; set-current-plot-pen "mean" ;; plot-vline mean current-data ;; set-current-plot-pen "median" ;; plot-vline median current-data ;; set-current-plot-pen "mode" ;; plot-modes current-data ] ] end to plot-vline [value] plotxy value 0 plotxy value plot-y-max end to plot-modes [lst] locals [values counts i n modess] set lst remove false lst set values remove-duplicates lst ifelse length values = length lst [ histogram-list lst ] ;; no duplicates so all items are modes [ set counts [] set i 0 repeat length values [ set counts lput ((length lst) - (length remove (item i values) lst)) counts set i i + 1 ] set n max counts ;; how many votes for the most frequent choice(s)? while [member? n counts] [ set values (replace-item (position n counts) values false) set counts (replace-item (position n counts) counts 0) ] set values remove false values set i 0 repeat length values [ set lst (remove (item i values) lst) set i i + 1 ] histogram-list lst ] end to plot-average-prompt locals [startitem enditem] set startitem read-from-string user-input "First Question Number?" set enditem read-from-string user-input "Last Question Number?" if startitem >= 0 and enditem >= startitem and enditem < length question-list [ set plot-first startitem set plot-last enditem set show-data? true ] if startitem > enditem or enditem >= length question-list [ set plot-mode plot-mode-is?] end to do-multi-item-average locals [index] clear-plot set-plot-x-range (plot-first) (plot-last + 1) set-plot-y-range 0 10 set index plot-first while [index <= plot-last] [ if count turtles with [is-number? item index my-choices] > 0 [ plotxy index ((sum values-from turtles with [is-number? item index my-choices] [item index my-choices]) / (count turtles with [is-number? item index my-choices]))] set index index + 1 ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Saving Questions ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Saving questions ;ALWAYS makes a web page. Poller data is hidden in comments at the bottom. to save-questions-prompt locals [option] user-message "Select the directory and filename for your questions. You should add an extension - either .htm or .html\nIf you don't add an extension, NetLogo will automatically add .html" set option user-choose-new-file ifelse is-string? option [ if not (substring option (length option - 5) (length option) = ".html") [ if not (substring option (length option - 4) (length option) = ".htm") [ set option option + ".html" ] ] save-questions-page option ] [ user-message "Save has been cancelled." ] end to save-questions-page [web-page] locals [counter-f counter-q counter-l] if file-exists? web-page [ file-delete web-page ] file-open web-page file-print "" file-print "" file-print "Poller Questions " + substring remove ":" get-date-and-time 0 6 + "" file-print "" file-print "" file-print "
" file-print "

" file-print "

" file-print "

User name (identical to NetLogo username)" file-print "

" ;this will later be read as item 4 in the list, when responses are read in from the web set counter-q 0 set counter-f 2 repeat length question-list [ file-print "

" + item 0 item counter-q question-list + "

" if item 1 item counter-q question-list = "Web Text" [ file-print "

" set counter-f counter-f + 1 ] if item 1 item counter-q question-list = "Likert" [ set counter-l 0 file-print "

" repeat item 2 item counter-q question-list [ file-print "" + counter-l set counter-l counter-l + 1 ] set counter-f counter-f + 1 ] if item 1 item counter-q question-list = "Web Number" [ file-print "

" set counter-f counter-f + 1 ] file-print "

" set counter-q counter-q + 1 ] file-print "<--------->" file-print "

" file-print "" file-print "" file-print "" file-close end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Loading Questions ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to load-questions-prompt locals [ chosen load-file] set chosen user-choice ("Load questions from a local FILE\n" + "Load questions from a WEB page\n" + "Load the BUILT-IN questions\n" + "Load NO questions") ["FILE" "WEB" "BUILT-IN" "NO"] if chosen = "FILE" [ user-message "Select the saved questions file." set load-file user-choose-file ifelse is-string? load-file [ load-local load-file ] [ set chosen "NO" ] ] if chosen = "WEB" [ load-web-prompt ] if chosen = "BUILT-IN" [ load-sample-questions ] if chosen = "NO" [ ;do nothing, just end ] end ;load the data file locally, and extract the question information from it to load-local [from-where?] locals [z-data] ifelse file-exists? from-where? [ file-open from-where? set z-data "" show "load-local ---- " + z-data while [not file-at-end?] [ set z-data z-data + file-read-characters 100 show "load-local ---- " + z-data ] file-close clear-all-data-and-questions show read-setup z-data set web-questions which-questions-are-web? question-list set-current-question 0 ask turtles [ clear-my-data set-my-current-question 0 ] ] [ user-message "NetLogo can't load a non-existent file. Load canceled." ] end to load-web-prompt locals [option] set option user-choice ("The current web-response file is:\n\n" + web-response-file + "\n\n Is this ok?") ["Cancel" "No" "OK"] if option = "Cancel" [ stop ] if option = "No" [ set web-response-file user-input "Web response file (don't forget http://)" ] load-web web-response-file end ;load the data file from the web, and extract the question information from it to load-web [from-where?] locals [z-data] set z-data read-url from-where? ifelse is-string? z-data [ if not (read-setup z-data) [ scrounge-setup from-where? ] set web-questions which-questions-are-web? question-list set web-responses? true set-current-question 0 ask turtles [clear-my-data set-my-current-question 0] ] [ user-message "Invalid URL. Load canceled." ] end ;to-report is-url? [str] ; ifelse ("" = __check-syntax ("show read-url \"" + str + "\"")) ; [ report true ] ; [ report false ] ;end ;does all of the setting of variables and stuff. ;ALSO, reports true is successful, false if not to-report read-setup [some-data] locals [z-data z-start z-end] set z-start position "" some-data ifelse is-number? z-end [ set z-data substring some-data z-start z-end clear-all-data-and-questions set question-list read-from-string z-data set-current-question 0 ask turtles [ clear-my-data set-my-current-question 0 ] set question-list read-from-string z-data report true ] [ report false ] ] [ report false ] end ;look for questions in web response file. This will cause a crash if the file isn't there! to scrounge-setup [from-where?] locals [response-list questions index] set response-list split-tab-delim-string (read-url web-data-where from-where?) ;find the list that has the string "QUESTIONS" as item 4 set questions filter [item 4 ? = "QUESTIONS"] response-list ifelse length questions > 0 [ set questions item 0 questions set index 5 if (is-list? questions) [ clear-all-data-and-questions while [not (item index questions = "Submit")] [ set question-list lput (list (item index questions) "Web Text") question-list set index index + 1 ] ] ] [ set questions item 0 response-list if length questions >= 6 [ set index 0 clear-all-data-and-questions repeat (length questions - 6) [ set question-list lput (list ("Web Question " + index) "Web Text") question-list set index index + 1 ] ] ] end to-report web-data-where [response-file] if substring response-file (length response-file - 5) (length response-file) = ".html" [ report substring response-file 0 (length response-file - 5) + ".fs"] if substring response-file (length response-file - 4) (length response-file) = ".htm" [ report substring response-file 0 (length response-file - 4) + ".fs"] report response-file end to-report which-questions-are-web? [z-list] locals [a-list index] set a-list [] set index 0 repeat length z-list [ if not (item 1 item index z-list = "Poller") [ set a-list lput index a-list ] set index index + 1 ] report a-list end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Loading Responses from Web-page ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to web-responses-get locals [web-data] set web-data read-url web-data-where web-response-file if is-string? web-data [ web-responses-process web-data ] end to web-responses-process [web-data] locals [index-who index-item submission which-user response-list] set web-processing? true set response-list split-tab-delim-string web-data set index-who 0 repeat length response-list [ set submission item index-who response-list set which-user item 4 submission if not (which-user = "QUESTIONS") [ if not any? turtles with [user-id = which-user] [ create-custom-non-clients 1 [ set user-id which-user set my-choices n-values length question-list [false] ] ] set index-item 0 while [not (item (index-item + 5) submission = "Submit")] [ ask turtles with [user-id = which-user] [ set my-choices replace-item (item index-item web-questions) my-choices (safer-read-from-string item (index-item + 5) submission) ; if (item 1 item (item index-item web-questions) question-list = "Likert") or (item 1 item (item index-item web-questions) question-list = "Web Number") ; [ set my-choices replace-item (item index-item web-questions) my-choices (safer-read-from-string item (item index-item web-questions) my-choices) ; ] if item (item index-item web-questions) my-choices = "" [ set my-choices replace-item (item index-item web-questions) my-choices false ] ] set index-item index-item + 1 ] ] set index-who index-who + 1 ] set-current-question current-question ask turtles [set-my-current-question my-current-question] set web-processing? false end to-report safer-read-from-string [str] ifelse ("" = __check-syntax ("show read-from-string \"\" + " + str)) [ report (read-from-string str) ] [ report str ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Save World (to capture EVERYTHING that is going on) ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to save-world-prompt locals [ save-file] user-message "Select the directory and filename for your saved world. The extension .csv will be automatically added." set save-file user-choose-new-file + ".csv" ifelse is-string? save-file [ export-world save-file ] [ user-message "Save has been cancelled." ] end to load-world-prompt locals [ load-file] if user-yes-or-no? ("LOAD WORLD will clear all current data and remove all students.\n\n" + "Do you want to continue?") [ user-message "Select the saved world file." set load-file user-choose-file ifelse is-string? load-file [ import-world load-file ] [ user-message "Load world has been cancelled." ] ] end to auto-save-prompt if ((auto-save-directory = "") or (not is-string? auto-save-directory)) [ auto-save-directory-change ] if is-string? auto-save-directory [ if ((auto-save-file = "") or (not is-string? auto-save-file)) [ auto-save-file-change ] ifelse ((auto-save-file = "") or (not is-string? auto-save-file)) [ user-message "Auto-save setup has been cancelled. Use the AUTO-SAVE? switch to turn on the autosave feature." set auto-save? false ] [ set auto-saving? true ] ] end to auto-save-directory-change locals [option] set option false user-message "Select a directory for the auto-save files. " set option user-choose-directory ifelse is-string? option [ set auto-save-directory option] [ user-message "World auto save directory has been left UNCHANGED"] end to auto-save-file-change locals [option] set option false user-message "Choose a new base file name for the auto-save files. " set option user-input "Base filename" ifelse is-string? option [ set auto-save-file option] [ user-message "World auto save base filename has been left UNCHANGED"] end to auto-save if auto-saving? [ export-world auto-save-directory + "/" + auto-save-file + substring remove ":" get-date-and-time 0 6 + ".csv"] if auto-saving-web? [ save-all-responses-as-web auto-save-web] set activity 0 end to auto-save-now if not auto-saving? [ set auto-save? user-yes-or-no? "Auto-save all data to file?" if auto-save? [ auto-save-prompt ] ] if not auto-saving-web? [ set auto-save-web? user-yes-or-no? "Auto-save responses to a web-page?" if auto-save-web? [ auto-save-web-prompt ] ] if auto-saving? [ export-world auto-save-directory + "/" + auto-save-file + substring remove ":" get-date-and-time 0 6 + "NOW.csv" ] if auto-saving-web? [ save-all-responses-as-web auto-save-web ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Saving poll responses as a web page ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to auto-save-web-prompt auto-save-web-change ifelse is-string? auto-save-web [ set auto-saving-web? true ] [ set auto-save-web? false ] end to auto-save-web-change locals [option] user-message "Create a new file for the auto-save web page." set option user-choose-new-file ifelse is-string? option [ set auto-save-web option if not (substring auto-save-web (length auto-save-web - 5) (length auto-save-web) = ".html" or substring auto-save-web (length auto-save-web - 4) (length auto-save-web) = ".htm") [ set auto-save-web auto-save-web + ".html" ] ] [ user-message "Auto-save to web-page setup has been cancelled." ] end to save-all-responses-web-prompt locals [option] user-message "Select the directory and filename for your saved poll results. You may want to add an extension (like .htm or .html)" set option user-choose-new-file ifelse is-string? option [ save-all-responses-as-web option ] [ user-message "Save has been cancelled."] end to save-all-responses-as-web [web-page] locals [counter-t counter-q] if file-exists? web-page [ file-delete web-page ] file-open web-page file-print "" file-print "" file-print "Poller Responses " + substring remove ":" get-date-and-time 0 6 + "" file-print "" file-print "" set counter-q 0 repeat length question-list [ file-print "

" + item 0 item counter-q question-list + "

" file-print "" set counter-q counter-q + 1 ] file-print "" file-print "" file-close end to save-individual-web-prompt locals [target-directory] user-message "Choose a folder for every turtle to save it's responses to." set target-directory user-choose-directory ask turtles [ save-responses target-directory] end to save-responses [to-where?] locals [my-file counter-q] set my-file to-where? + "/" + user-id + substring remove ":" get-date-and-time 0 6 + ".html" if file-exists? my-file [ file-delete my-file ] file-open my-file file-print "" file-print "" file-print "Poller Responses " + user-id + " " + substring remove ":" get-date-and-time 0 6 + "" file-print "" file-print "" file-print "" set counter-q 0 repeat length question-list [ file-print "" file-print "" file-print "" file-print "" set counter-q counter-q + 1 ] file-print "
" file-print "" + item 0 item counter-q question-list + "" file-print "" file-print item counter-q my-choices file-print "
" file-print "" file-print "" file-close end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Export poll responses as spreadsheet file ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to save-polls-prompt locals [ save-file] user-message "Select the directory and filename for your saved poll results. You may want to add an extension (like .txt or .poll)" set save-file user-choose-new-file ifelse is-string? save-file [ save-polls save-file ] [ user-message "Save has been cancelled." ] end to save-polls [ towhere? ] locals [ counter-q counter-t] if count turtles > 0 [ file-open towhere? file-type "User-ID\t" set counter-t 0 repeat count turtles [ file-type value-from turtle counter-t [ user-id ] file-type "\t" set counter-t counter-t + 1 ] file-print "" set counter-q 0 repeat length question-list [ file-type item 0 item counter-q question-list file-type "\t" set counter-t 0 repeat count turtles [ file-type value-from turtle counter-t [item counter-q my-choices] file-type "\t" set counter-t counter-t + 1 ] file-print "" set counter-q counter-q + 1 ] file-close ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;; Pop Up Help ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to help-autosave user-message ("HELP: Autosave settings\n\n" + "When turned on, autosave will periodically automatically save your classroom data.\n" + "The slider 'auto-save-every' determines how often auto-save happens. " + "You can autosave all of the current data (student data and your current viewing settings) " + "using the regular auto-save feature. You can turn this on using 'auto-save?'\n" + "You can also autosave questions and students responses to an html file, for viewing on the web. " + "You can turn this on using 'auto-save-web?'") end to help-save user-message ("HELP: Save options : Page 1 of 2\n\n" + "You can save all of the current data (student data and your current viewing settings) " + "using the 'Save ALL' button. This saves data in the same format as 'auto-save' above.\n" + "You can load this data for later viewing using the 'Load ALL' button. This will overwrite " + "everything in the current model, so you may want to save current data before using this.") user-message ("HELP: Save options : Page 2 of 2\n\n" + "'Save RESPONSES as SPREADSHEET' will save the questions and student responses in a format " + "readable by most spreadsheet programs.\n\n" + "'Save RESPONSES as WEBPAGE' saves all questions and student responses to an html file. " + "This file can be viewed in any web browser, and is the same format used by 'auto-save-web?' above.\n\n" + "'Save INDIVIDUAL responses' saves each students responses (along with the questions) to a separate " + "html file.") end to help-web user-message ("HELP: Web Response settings : Page 1 of 2\n\n" + "This tool can read responses that students have submitted to a web page " + "(also generated by the dicussion tool)\n" + "When you have 'web-responses?' on, this tool will periodically check for new submissions " + "to the web page. The web pages generated by this tool require that you use Formsaver " + "(a free application for Macintosh servers) This is not an endorsement of said product, but a " + "historical artifact of the originating project.") user-message ("HELP: Web Response settings : Page 2 of 2\n\n" + "To use web questions in class, you must first prepare the questions. Go to the third panel " + "(scroll to the right) to find the preparation section. After the questions are prepared, you " + "must put the web page on the server, where students can access the page. You should also prepare " + "the page by submitting a set of default responses. In class, when you setup the activity, you can " + "choose to load the questions from a web page. Put in the URL for this question page, and NetLogo " + "will automatically load the questions you prepared and the students' responses.") end to help-prepare user-message ("HELP: Preparation : Page 1 of 3\n\n" + "In this screen, you can prepare questions for class. You can prepare in class questions that " + "use HubNet to gather real time responses from your students, and you can prepare web-based " + "questions to allow students to give responses out of class, too " + "(or to share information not easily shared using the in class polling)\n\n" + "'SETUP' will clear everything in the current activity, and give you the option of loading an existing " + "set of questions.\n\n" + "'New Poller Question' will generate a new question that uses the HubNet client. " + "Using the HubNet client, students will be able to share integer responses from 0 to 50 and typed " + "responses in real-time in class.\n\n" + "'New Web Text Question' creates a new web based text entry question. Students will be able to go to the " + "web page and submit a typed response to this question.\n\n") user-message ("HELP: Preparation : Page 2 of 3\n\n" + "'New Likert Scale Question' creates a question for which students choose a number from 0 to n.\n\n" + "New Web Number Question' creates a question for which students supply a typed number response." + "The arrow buttons allow you to move between the questions you've created.\n\n" + "'Edit Question' allows you to Delete, Replace, or Insert a new question at the current " + "spot in the question list.\n\n" + "'Clear Questions' clears all of the current questions.") user-message ("HELP: Preparation : Page 3 of 3\n\n" + "When you are satisfied with the question list, hit 'PREPARATIONS FINISHED.' " + "This will generate an html file in which you can view the questions (and to which you can add " + "pictures or other materials). This file also contains the question data in a format that this " + "NetLogo model can work with.\n\n" + "If you have web based questions, you should copy this preparation file to a Formsaver equipped " + "web server. You should then go to that page in your web browser and submit a sample set of responses " + "using the name QUESTIONS. If you do not have web based questions, just be sure to remember where you " + "put the file.\n\n" + "In class, when the activity starts up, you can choose to load a question file. If you used " + "web questions, then choose WEB. If you did not, just load a LOCAL file. Either way, tell " + "NetLogo where to find your file. It will automatically load the questions, and you'll be ready to go.") end ; *** NetLogo Model Copyright Notice *** ; ; This activity and associated models and materials was created as part of the projects: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and ; INTEGRATED SIMULATION AND MODELING ENVIRONMENT. ; These projects gratefully acknowledge the support of the ; National Science Foundation (REPP & ROLE programs) -- grant numbers ; REC #9814682 and REC-0126227. ; ; Copyright 2002 by Uri Wilensky & Walter Stroup. Updated 2003. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from the copyright holders. ; Contact the copyright holders for appropriate licenses for redistribution ; for profit. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. & Stroup, W. (2002). NetLogo HubNet Polling model. ; http://ccl.northwestern.edu/netlogo/models/HubNetPolling. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; *** End of NetLogo Model Copyright Notice*** @#$#@#$#@ GRAPHICS-WINDOW 317 142 600 446 10 10 13.0 1 10 1 1 1 CC-WINDOW 1828 237 2318 422 Command Center BUTTON 270 10 380 63 GO go T 1 T OBSERVER T PLOT 10 142 310 396 Data choice count 0.0 11.0 0.0 5.0 true false PENS "data" 1.0 1 -16777216 true "mean" 1.0 0 -11352576 true "median" 1.0 0 -16776961 true "mode" 1.0 1 -65536 true SWITCH 587 69 719 102 allow-change? allow-change? 0 1 -1000 MONITOR 64 78 461 127 Current Question item 0 item current-question question-list 3 1 BUTTON 2010 184 2111 217 Clear Questions clear-all-data-and-questions-prompt NIL 1 T OBSERVER T BUTTON 462 78 517 127 <<< prev-question NIL 1 T OBSERVER T BUTTON 518 78 573 127 >>> next-question NIL 1 T OBSERVER T SWITCH 10 403 148 436 show-data? show-data? 0 1 -1000 SWITCH 587 102 719 135 lock-step? lock-step? 1 1 -1000 BUTTON 967 259 1165 292 Save RESPONSES as SPREADSHEET save-polls-prompt NIL 1 T OBSERVER T BUTTON 1904 184 2005 217 Edit Question edit-question NIL 1 T OBSERVER T MONITOR 9 78 65 127 Number current-question 0 1 SWITCH 601 142 720 175 see-names? see-names? 1 1 -1000 CHOICE 602 179 721 224 Turtle-Display Turtle-Display "Sit" "Wander" "Line-Up" "Word-Sort" 0 MONITOR 602 227 721 276 Who is it? user-id-of random-one-of turtles-at mouse-xcor mouse-ycor 0 1 SWITCH 815 55 979 88 auto-save? auto-save? 1 1 -1000 SLIDER 815 115 979 148 auto-save-every auto-save-every 5 100 5 5 1 votes BUTTON 817 259 886 292 Save ALL save-world-prompt NIL 1 T OBSERVER T BUTTON 887 259 954 292 Load ALL load-world-prompt NIL 1 T OBSERVER T CHOICE 171 403 309 448 plot-mode plot-mode "Histogram" "Average" 0 BUTTON 8 10 102 62 SETUP setup-prompt NIL 1 T OBSERVER T BUTTON 106 10 214 62 LOAD QUESTIONS load-questions-prompt NIL 1 T OBSERVER T BUTTON 434 10 536 62 ADD QUESTION add-question "Poller" NIL 1 T OBSERVER T BUTTON 614 10 719 62 SAVE save-button-prompt NIL 1 T OBSERVER T BUTTON 602 335 720 368 ^ CHANGE ^ set sort-up user-input "Sort up / down word -"\nset Turtle-Display "Word-Sort" NIL 1 T OBSERVER T BUTTON 602 421 720 454 ^ CHANGE ^ set sort-right user-input "Sort right / left word -"\nset Turtle-Display "Word-Sort" NIL 1 T OBSERVER T BUTTON 1346 260 1521 293 Save RESPONSES as WEBPAGE save-all-responses-web-prompt NIL 1 T OBSERVER T MONITOR 602 286 720 335 NIL sort-up 0 1 MONITOR 602 372 720 421 NIL sort-right 0 1 SWITCH 815 344 999 377 web-responses? web-responses? 0 1 -1000 BUTTON 1608 235 1785 268 New Poller Question add-question "Poller" NIL 1 T OBSERVER T BUTTON 1608 269 1785 302 New Web Text Question add-question "Web Text" NIL 1 T OBSERVER T BUTTON 1608 304 1785 337 New Web Likert Scale add-question "Likert" NIL 1 T OBSERVER T MONITOR 1669 133 2201 182 Current Question item 0 item current-question question-list 3 1 MONITOR 1605 133 1668 182 Number current-question 3 1 BUTTON 1741 184 1804 217 <<< prev-question NIL 1 T OBSERVER T BUTTON 1807 184 1870 217 >>> next-question NIL 1 T OBSERVER T MONITOR 1070 55 1529 104 Auto-save directory auto-save-directory 3 1 BUTTON 987 55 1068 104 CHANGE -> auto-save-directory-change NIL 1 T OBSERVER T MONITOR 1070 106 1222 155 Auto-save base name auto-save-file 3 1 BUTTON 987 106 1068 155 CHANGE -> auto-save-file-change NIL 1 T OBSERVER T MONITOR 1070 157 1527 206 Auto-save web page auto-save-web 3 1 BUTTON 987 156 1068 206 CHANGE -> auto-save-web-change NIL 1 T OBSERVER T BUTTON 1608 391 1786 424 PREPARATIONS FINISHED save-questions-prompt NIL 1 T OBSERVER T MONITOR 2203 133 2312 182 Type item 1 item current-question question-list + ifelse-value (item 1 item current-question question-list = "Likert") [" " + item 2 item current-question question-list] [""] 3 1 SLIDER 815 378 999 411 check-web-every check-web-every 0.5 10 0.5 0.5 1 minutes BUTTON 1001 353 1076 402 CHANGE -> load-web-prompt NIL 1 T OBSERVER T MONITOR 1078 354 1463 403 Web Responses Location web-response-file 3 1 BUTTON 815 10 1529 43 AUTOSAVE SETTINGS help-autosave NIL 1 T OBSERVER T BUTTON 815 306 1522 339 WEB RESPONSE SETTINGS help-web NIL 1 T OBSERVER T BUTTON 817 217 1522 250 SAVE OPTIONS help-save NIL 1 T OBSERVER T SWITCH 816 172 979 205 auto-save-web? auto-save-web? 1 1 -1000 BUTTON 1602 19 2308 52 PREPARE FOR CLASS help-prepare NIL 1 T OBSERVER T BUTTON 1608 339 1785 372 New Web Number add-question "Web Number" NIL 1 T OBSERVER T BUTTON 1836 76 1961 109 SETUP setup-prompt NIL 1 T OBSERVER T MONITOR 1463 354 1521 403 LOADING web-processing? 3 1 BUTTON 1176 260 1343 293 Save INDIVIDUAL responses NIL NIL 1 T OBSERVER T @#$#@#$#@ WHAT IS IT? ----------- This model can be used to poll data from a set of students using HubNet Clients or web page submissions. The teacher can input questions to ask and then the students can input their numerical choice (from 0 to 50) in response to the question. The collective data can then be plotted. HOW TO USE IT ------------- The simplest way to use this tool is to hit the GO button (to allow students to place their votes) and use the NEW QUESTION button repeatedly to input questions. With the default settings, students will respond at their own pace, and their responses will be histogrammed in the plot. The teacher can use the <<< and >>> buttons to move among the questions and see the students' responses. However, this activity has many features that can be useful in preparing for discussion, inciting discussion, and later analyzing discussions. Preparation: The teacher can load this model before class and prepare questions for loading in class. By scrolling the window to the right-most screen, the teacher can use the Preparation features. The teacher can create questions that use the HubNet Client (New Poller Question) or various web questions (New Web Text Question, New Likert Scale, and New Web Number). After entering a set of questions and editing them as necessary (using the Edit Question button) the teacher can save those questions in a web-ready HTML file (using the PREPARATIONS FINISHED button). Then, in class, the teacher can load the questions using the LOAD QUESTIONS button to load the questions either from the local harddrive or the web. If the teacher makes a mistake while typing a question, he can correct it using the EDIT QUESTION button. He can insert a question before the current one, re-type the current question, or delete a question. (These can all be done in class, on the fly, as well) After creating a set of questions that includes some web responses, the teacher needs to remember to put the web page on a server that has the Formsaver software. Of course, teachers can edit the procedures save-questions-page, web-responses-process, and web-data-where to suit the particular quirks of their server software. Inciting Discussion: In the default settings, students can move through questions at their own pace, they can change their answers as often as they want, and the class results are histogrammed on the teacher's computer in real time. What if the teacher wants students to make their decisions without seeing what their classmates have chosen? The teacher can turn off SHOW-DATA?. The teacher can show the average response to several questions side-by-side by changing PLOT-MODE to "Average." If the teacher wants to call everyone's attention to a particular question, he can turn on LOCK-STEP?. If the teacher wants students to place a vote and stick to it, he can turn off ALLOW-CHANGE?. The ability for students to give anonymous responses can help fuel discussions. Teachers should feel free to allow students to log in with fake names, or turn off SEE-NAMES? When students see that others share their opinions, they tend to be more willing to discuss the reasoning behind their views, and avoid the classic problems of "I don't want to seem stupid" or "I don't want to seem smart." In addition to the plot, turtle positions can be used to present information about students' responses. By setting the TURTLE-DISPLAY chooser to "Sit" or "Wander", the teacher can have the turtles sort left and right according to if they've voted or not. "Line Up" causes the turtles to duplicate a histogram of their choices. "Word Sort" will cause the turtles to sort left / right and up /down according to the presence of a string in their responses (so, for example, all of the students who included the word "gravity" would move to the top half of the graphics window, and all the students who included the word "air resistance" would move to the right, if the teacher chose those words for the sorting). While students are voting, the teacher can have the model automatically save their data, allowing for later analysis or use in discussion. When the teacher turns on AUTO-SAVE?, prompts help him pick the directory and file name for the saved data. Analyzing Discussion: After a discussion has occurred, the teacher can load the class data from different times in the discussion and view the responses. The teacher can also export the data in a format that can be conveniently opened in any spreadsheet. Just LOAD "world data" to revisit the students' responses in the tool, and use "save RESPONSES to SPREADSHEET" to save interesting data to a spreadsheet readable format. The teacher can also save student responses to a web page. "Save RESPONSES as WEBPAGE" will save all the questions and student responses to a single web page. "Save INDIVIDUAL responses" will have each turtle generate a web page with questions and responses for that individual. WIDGETS: -------- Screen 1 (left) SETUP - clears everything including logged in clients. This should only be pressed when starting out with a new group of users since all data and questions are lost. Presents the load questions menu LOAD QUESTIONS - presents a menu of options for loading questions GO - processes data from the clients. THIS MUST BE ON to receive responses or use the interface. ADD QUESTION - adds a new HubNet Client question SAVE - presents a menu of options for saving questions and student responses Number - shows the current question number (starts at 0) Current Question - shows the current question being voted on by the clients <<< - changes the current question to the previous question >>> - changes the current question to the next question. allow-change? - controls whether clients are able to change their choices after they've chosen. Can be changed at any time. lock-step? - controls whether clients are forced to view only the question the teacher is currently viewing. Can be changed at any time. show-data? - controls whether the data collected are shown in the plot window. Can be changed at any time plot-mode - controls whether a histogram of current responses is shown, or a plot showing the average to several questions see-names? - controls whether the turtle shows the corresponding user ID. Can be changed at any time turtle-display - controls how the turtles position themselves. With "sit" and "wander," turtles who have voted move to the right half of the screen. With "line up," the turtles line up according to the number value of their responses (and turtles who haven't voted or who have a string response move to the far left). With "word sort," turtles are sorted up / down and right / left according to the presence of a substring in their string response (turtles who've not voted or who have a numerical response gather in the middle) Who Is It? - shows the user id of the turtle under the mouse Sort-Up - shows the word used to sort turtles up / down ^ CHANGE ^ - changes the sort-up value Sort-Right - shows the word used to sort turtles right / left ^ CHANGE ^ - changes the sort-right value Screen 2 (middle) auto-save? - determines whether autosave is on or off auto-save-web? - determines whether the model autosaves student responses to a web page auto-save-every - determines how often the model autosaves, based on the number of votes cast between saves auto-save directory - the directory in which autosave files are written auto-save base name - the base name for autosave files. The time is added to this name. auto-save web page - the html file to which student responses are autosaved. Save ALL - save all of the current information - questions, student responses, interface settings. This is the format used by auto-save Load ALL - load an ALL file Save RESPONSES as SPREADSHEEET - saves student questions and responses in a spreadsheet compatible format Save INDIVIDUAL responses - creates a web page for each student with the questions and that individual's responses Save RESPONSES as WEBPAGE - creates a web page with all the questions and responses web-responses? - determines whether the model is checking a web site for responses check-web-every - determines how often the model checks the web site for responses. While processing the data, the model stops for several seconds web responses location - the URL of the web response file loading - shows if the model is currently loading a set of web responses Screen 3 (right) SETUP - clears everything including logged in clients. This should only be pressed when starting out with a new group of users since all data and questions are lost. Presents the load questions menu Number - shows the current question number (starts at 0) Current Question - shows the current question Type - shows the type of the current questions (Poller, Web Text, Likert, or Web Number) <<< - changes the current question to the previous question >>> - changes the current question to the next question. Edit Question - calls a menu of options for editing the current question. REPLACE replaces the current question, DELETE deletes it, and INSERT inserts a new question Clear Questions - clears all of the questions New Poller Question - adds a new HubNet Client question New Web Text Question - adds a new question that will expect a typed string response New Web Likert Scale - adds a new question of the "Pick a number between 0 and n" variety New Web Number - adds a new question that will expect a typed numerical response Preparations Finished - this button saves the questions and generates a web page EXTENDING THE MODEL ------------------- There are many more ways the turtles could be used to convey information. Change the model so they set their shape according to type of response they have to the current question. Or have the turtles adjust their size according to how many responses they have. There could also be a turtle-display mode where they sit according to their responses to two questions. Currently, the web submissions features work only with a server that uses Formsaver. The data files have the same filename as the parent web page, but with the .fs extension instead of .html. Also, it saves the submissions in a tab delimited file and appends some information at the head of each submission. If the servers you have access to are configured differently, you'll need to adjust several procedures in this model to use the web submission feature. NETLOGO FEATURES ---------------- We use the experimental __import primitive at the top of the procedures tab to allow us to use primitives that we wrote using the NetLogo API. This is a new feature that allows users to write primitives in Java code and then use the primitives in models. In this model we import the a jar that has two primitives, split-tab-delim-string, and read-url. read-url allows you to read in data from a network resource such as a web page. split-tab-delim-string string reports the string into a list of lists (split by tabs). CREDITS AND REFERENCES ---------------------- This activity and associated models and materials was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and INTEGRATED SIMULATION AND MODELING ENVIRONMENT. These projects gratefully acknowledge the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Copyright 2002 by Uri Wilensky & Walter Stroup. All rights reserved. Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed: a) this copyright notice is included. b) this model will not be redistributed for profit without permission from the copyright holders. Contact the copyright holders for appropriate licenses for redistribution for profit. To refer to this model in academic publications, please use: Wilensky, U. & Stroup, W. (2002). NetLogo HubNet Polling model. http://ccl.northwestern.edu/netlogo/models/HubNetPolling. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 android false 0 Rectangle -7566196 true true 105 74 210 239 Polygon -7566196 true true 104 78 34 129 47 148 114 89 Polygon -7566196 true true 198 81 274 108 258 142 192 104 Polygon -7566196 true true 115 239 115 289 133 289 133 237 Polygon -7566196 true true 176 235 176 287 192 287 192 234 Rectangle -7566196 true true 119 12 194 73 Rectangle -16777216 true false 129 22 147 36 Rectangle -16777216 true false 164 23 184 37 Rectangle -16777216 true false 151 113 163 125 Rectangle -16777216 true false 153 142 164 154 Rectangle -16777216 true false 154 171 166 184 big boat false 0 Polygon -6524078 true false 1 196 43 296 193 296 297 194 Rectangle -1 true false 135 14 149 194 Polygon -7566196 true true 151 14 173 18 193 30 211 48 239 88 251 118 271 170 271 184 253 176 227 170 199 172 177 180 161 190 165 160 169 122 165 78 Polygon -7566196 true true 133 36 115 50 77 86 47 122 7 152 33 156 57 164 77 178 91 188 Rectangle -7566196 true true 30 206 234 220 Rectangle -7566196 true true 52 224 234 236 Rectangle -7566196 true true 78 240 234 250 butterfly true 0 Polygon -16777216 true false 151 76 138 91 138 284 150 296 162 286 162 91 Polygon -7566196 true true 164 106 184 79 205 61 236 48 259 53 279 86 287 119 289 158 278 177 256 182 164 181 Polygon -7566196 true true 136 110 119 82 110 71 85 61 59 48 36 56 17 88 6 115 2 147 15 178 134 178 Polygon -7566196 true true 46 181 28 227 50 255 77 273 112 283 135 274 135 180 Polygon -7566196 true true 165 185 254 184 272 224 255 251 236 267 191 283 164 276 Line -7566196 true 167 47 159 82 Line -7566196 true 136 47 145 81 Circle -7566196 true true 165 45 8 Circle -7566196 true true 134 45 6 Circle -7566196 true true 133 44 7 Circle -7566196 true true 133 43 8 car true 15 Circle -1 false true 185 55 60 Circle -1 false true 183 186 61 Polygon -1 true true 214 52 214 22 182 26 162 38 144 74 138 102 100 120 99 161 102 201 118 246 152 267 190 275 210 251 187 240 178 200 204 182 215 181 214 118 193 112 182 98 181 72 198 52 circle false 0 Circle -7566196 true true 35 35 230 nu false 0 Rectangle -7566196 true true 16 31 60 285 Rectangle -7566196 true true 120 31 164 285 Rectangle -7566196 true true 182 31 226 285 Rectangle -7566196 true true 256 31 298 285 Rectangle -7566196 true true 214 241 274 285 Polygon -7566196 true true 60 31 118 209 120 281 60 105 Rectangle -7566196 true true 110 211 140 249 pickup truck false 0 Polygon -7566196 true true 285 208 285 178 279 164 261 144 229 132 217 132 213 106 199 84 171 68 149 68 129 68 129 148 1 148 1 156 19 164 19 222 285 222 283 174 283 176 283 176 Circle -16777216 true false 40 185 71 Circle -16777216 true false 192 191 66 Circle -7566196 true true 195 194 59 Circle -7566196 true true 43 188 64 Polygon -16777216 true false 197 94 149 94 157 128 209 128 205 112 203 102 197 94 Polygon -7566196 true true 21 142 139 142 139 136 13 136 sick android false 0 Rectangle -7566196 true true 105 74 210 239 Polygon -7566196 true true 104 78 34 129 47 148 114 89 Polygon -7566196 true true 198 81 274 108 258 142 192 104 Polygon -7566196 true true 115 239 115 289 133 289 133 237 Polygon -7566196 true true 176 235 176 287 192 287 192 234 Rectangle -7566196 true true 119 12 194 73 Rectangle -16777216 true false 129 22 147 36 Rectangle -16777216 true false 164 23 184 37 Rectangle -16777216 true false 151 113 163 125 Rectangle -16777216 true false 153 142 164 154 Rectangle -16777216 true false 154 171 166 184 Circle -65536 true false 4 125 112 sick big boat false 0 Polygon -6524078 true false 1 196 43 296 193 296 297 194 Rectangle -1 true false 135 14 149 194 Polygon -7566196 true true 151 14 173 18 193 30 211 48 239 88 251 118 271 170 271 184 253 176 227 170 199 172 177 180 161 190 165 160 169 122 165 78 Polygon -7566196 true true 133 36 115 50 77 86 47 122 7 152 33 156 57 164 77 178 91 188 Rectangle -7566196 true true 30 206 234 220 Rectangle -7566196 true true 52 224 234 236 Rectangle -7566196 true true 78 240 234 250 Circle -65536 true false 1 134 123 sick butterfly true 0 Polygon -16777216 true false 151 76 138 91 138 284 150 296 162 286 162 91 Polygon -7566196 true true 164 106 184 79 205 61 236 48 259 53 279 86 287 119 289 158 278 177 256 182 164 181 Polygon -7566196 true true 136 110 119 82 110 71 85 61 59 48 36 56 17 88 6 115 2 147 15 178 134 178 Polygon -7566196 true true 46 181 28 227 50 255 77 273 112 283 135 274 135 180 Polygon -7566196 true true 165 185 254 184 272 224 255 251 236 267 191 283 164 276 Line -7566196 true 167 47 159 82 Line -7566196 true 136 47 145 81 Circle -7566196 true true 165 45 8 Circle -7566196 true true 134 45 6 Circle -7566196 true true 133 44 7 Circle -7566196 true true 133 43 8 Circle -65536 true false 167 99 128 sick car true 15 Circle -1 false true 185 55 60 Circle -1 false true 183 186 61 Polygon -1 true true 214 52 214 22 182 26 162 38 144 74 138 102 100 120 99 161 102 201 118 246 152 267 190 275 210 251 187 240 178 200 204 182 215 181 214 118 193 112 182 98 181 72 198 52 Circle -65536 true false 19 167 82 sick circle false 0 Circle -7566196 true true 35 35 230 Circle -65536 true false 101 104 98 sick nu false 0 Rectangle -7566196 true true 16 31 60 285 Rectangle -7566196 true true 120 31 164 285 Rectangle -7566196 true true 182 31 226 285 Rectangle -7566196 true true 256 31 298 285 Rectangle -7566196 true true 214 241 274 285 Polygon -7566196 true true 60 31 118 209 120 281 60 105 Rectangle -7566196 true true 110 211 140 249 Circle -65536 true false 110 147 121 sick pickup truck false 0 Polygon -7566196 true true 285 208 285 178 279 164 261 144 229 132 217 132 213 106 199 84 171 68 149 68 129 68 129 148 1 148 1 156 19 164 19 222 285 222 283 174 283 176 283 176 Circle -16777216 true false 40 185 71 Circle -16777216 true false 192 191 66 Circle -7566196 true true 195 194 59 Circle -7566196 true true 43 188 64 Polygon -16777216 true false 197 94 149 94 157 128 209 128 205 112 203 102 197 94 Polygon -7566196 true true 21 142 139 142 139 136 13 136 Circle -65536 true false 22 111 66 sick square true 0 Rectangle -7566196 true true 45 45 255 255 Circle -65536 true false 100 97 102 sick thin wedge true 0 Polygon -7566196 true true 133 20 70 252 127 148 177 245 Circle -65536 true false 165 140 87 sick uu false 0 Rectangle -7566196 true true 58 44 104 226 Rectangle -7566196 true true 88 178 194 224 Rectangle -7566196 true true 180 44 222 224 Rectangle -7566196 true true 122 74 168 284 Rectangle -7566196 true true 124 240 250 286 Rectangle -7566196 true true 240 76 284 286 Circle -65536 true false 43 208 93 sick wide wedge true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 Circle -65536 true false 202 65 90 square true 0 Rectangle -7566196 true true 48 27 253 222 thin wedge true 0 Polygon -7566196 true true 133 20 70 252 127 148 177 245 uu false 0 Rectangle -7566196 true true 58 44 104 226 Rectangle -7566196 true true 88 178 194 224 Rectangle -7566196 true true 180 44 222 224 Rectangle -7566196 true true 122 74 168 284 Rectangle -7566196 true true 124 240 250 286 Rectangle -7566196 true true 240 76 284 286 wide wedge true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 2.0.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@