-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy paththreadz.php
More file actions
executable file
·532 lines (501 loc) · 27.3 KB
/
Copy paththreadz.php
File metadata and controls
executable file
·532 lines (501 loc) · 27.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
<?php
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Name: Threadz
// Author: Matt Lewis
// Organization: Eastern Washington University - Instructional Technology
// Copyright: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
// Version: 1.0
// Page Description: This page displays the HTML for the LTI.
// Uses: ajax.php, d3-visuals.js
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ini_set('session.gc_maxlifetime', 1800);
session_start();
$topic_id = $_POST['topic_id'];
$_SESSION['graph'] = $_POST['graph'];
$domainThreadz = $_SESSION['domainThreadz'];
$js_topic_id =$_SESSION['js_topic_id'];
$discussionData = json_encode($_SESSION['d3_'.$js_topic_id]);
//Hide content depending on if there are any discussion topics in course.
if($_SESSION['countOfTopic'] > 0 ){
$topicsAvaliable = "$('#noTopics').hide();";
}else{
$topicsAvaliable = "$('#topics').hide();";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Threadz - Topic List</title>
<meta charset="utf-8">
<meta name="description" content="Visualize Canvas LMS discussions with various social network graphs.">
<meta name="author" content="Matt Lewis">
<meta name="robots" content="noindex,nofollow">
<!--Stylesheets-->
<link rel="stylesheet" href="<?php echo $domainThreadz ?>/css/base.css?<?php echo date('YmdHis') ?>"/>
<link href='https://fonts.googleapis.com/css?family=Volkhov:400,400italic' rel='stylesheet' type='text/css'>
<!--D3 Stylesheets-->
<link rel="stylesheet" href="<?php echo $domainThreadz ?>/css/d3-viz.css?<?php echo date('YmdHis') ?>"/>
<!--Jquery Stylesheets-->
<link rel="stylesheet" href="<?php echo $domainThreadz ?>/css/tablesorter/blue/style.css"/>
<link rel="stylesheet" href="<?php echo $domainThreadz ?>/css/overcastBluesky/jquery-ui.css"/>
<!--<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">-->
<!--Jquery Libraries-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/jquery/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/jquery/jquery.tableToCSV.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/jquery/jquery.inlineStyler.min.js"></script>
<!--[if !IE]> -->
<script type="text/javascript" async src="<?php echo $domainThreadz ?>/lib/js/jquery/excanvas.min.js"></script>
<!-- <![endif]-->
<!--D3 Libraries -->
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/d3/d3.v3.min.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/d3/d3-mapper.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/d3/underscore.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/d3/d3.layout.cloud.js"></script>
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/d3/d3-visuals.js?<?php echo date('YmdHis') ?>"></script>
<!--JSNetworkX Library -->
<script type="text/javascript" src="<?php echo $domainThreadz ?>/lib/js/jsnetworkx.js"></script>
</head>
<body>
<h2 id='beta'>Threadz</h2>
<div id='topics'>
<div id="welcome">
<p>Getting Started: Select a discussion from the list of published discussion titles.</p>
</div>
<div id="selectTopic">
<form name='formTopics' id='formTopics' action="" method="Post">
Discussion Topic Name: <select name='topic_id' id='topic_list'>
<option value='0'>Select a Discussion</option>
<?php echo $_SESSION['select_list_option']; ?>
</select>
</form>
</div>
<div id='topNav'><br>
<a href="index.php"><span>Index</span></a>
</div>
<div id="vis_container">
<ul>
<li><a href="#network"><span>Network</span></a></li>
<!--<li><a href="#chord"><span>Chord</span></a></li>-->
<li><a href="chord.php"><span>Chord</span></a></li>
<li><a href="#timeline"><span>Timeline</span></a></li>
<li><a href="#statistics"><span>Statistics</span></a></li>
<li><a href="#dataset"><span>Data Set</span></a></li>
<li><a href="help.php"><span>Help</span></a></li>
<!--<li><a href="#cloud"><span>Word Cloud</span></a></li>-->
<!--<li><a href="#matrix"><span>Matrix</span></a></li>-->
<!--<li><a href="#stream"><span>Stream</span></a></li>-->
<!-- <li><a href="about.php"><span>About</span></a></li>-->
<!-- <li><a href="help.php"><span>Help</span></a></li>-->
<!-- <li><a href="roadmap.php"><span>Road Map</span></a></li>-->
</ul>
<div id="network">
<div id="nodeType">
<input type="radio" name="nodeTypeDisplay" value='threads' id="radio1" checked="checked"><label for="radio1">Display by User</label>
<input type="radio" name="nodeTypeDisplay" value='people' id="radio2"><label for="radio2">Display by Posts/Replies</label>
</div>
<!--<div id='nodeType'>
<button id='nodeType-posts'>Display by Posts/Replies</button>
<button id='nodeType-people'>Display by User</button>
</div>-->
<div id='networkSize'>Size by:
<select id="nodeSize">
<option value="sent">Posts/Replies Sent</option>
<option value="received">Replies Received</option>
<option value="total">Total Posts/Replies</option>
<option value="word">Word Count</option>
<!--<option value="word_avg">Word Count Avg</option>-->
<!--<option value="betweenness">Betweenness Score</option>-->
</select>
</div>
<div id='networkColor'>Highlight:
<select id="nodeColor">
<option value="none"></option>
<option value="length">Post/Reply Length</option>
<option value="late">Late Posts/Replies</option>
<option value="unread">Unread Posts/Replies</option>
<option value="isolated">Isolated Learners</option>
<!--<option value="pcount">Count</option>
<option value="likes">Likes</option>
<option value="users">Users</option>-->
</select>
</div>
<div class='d3-visual'>
<div id='networkDirected'></div>
<div id='missing'></div>
</div>
<div id='right-container'>
<h4>Network Diagram</h4>
<p>The network visualization shows a typical line/node graph that connects users together. </p>
<p>This visualization is useful to quickly discern any individual or group that is isolated or is a driving hub within the forum.</p>
<p>The nodes in this chart are movable to help single out individuals or groups when the network of connections gets too complex visually.</p>
<p>To manipulate a node, click and drag a node circle to another part of the page. To release the node, double click.</p>
<h4>Key</h4>
<div id='userKey'>
<p>Each node represents a different user in the discussion and each line represents a connection from one user to another. The relative size of the circles (nodes) changes to represent the quantity of number of posts/replies sent, replies received, or total of sent/received. </p>
</div>
<div id='threadKey'>
<p>Each node represents a different post in the discussion. Darker colors signify the original post of the thread, lighter shades show replies. Orange circles (nodes) represent highlighted students or posts depending on selection.</p>
<div><img src='images/blue-dot1.png' align="middle" width=20px heigth=20px alt="dark blue dot"><i>original thread post</i></div>
<div><img src='images/blue-dot2.png' align="middle" width=20px heigth=20px alt="light blue dot"><i>response to a post</i></div>
<div><img src='images/orange-dot1.png' align="middle" width=20px heigth=20px alt="dark orange dot"><i>late, unread, or isolated learner</i></div>
</div>
<div id='missing>'></div>
</div>
<div class='discussionLink'></div>
</div>
<div id="chord"></div>
<div id="timeline">
<div class='d3-visual'>
<div id="timeBar"></div>
<div id="timeArea"></div>
</div>
<div id='right-container'>
<h4>Timeline</h4>
<p>The timeline visualization displays the count of discussion posts by date. This visual can help you determin the rate of submissions and determin if there are any patterns to those submissions.</p>
</div>
<div class='discussionLink'></div>
</div>
<!--<div id="matrix" class='matrix'>
<div id='matrixOrder'>Order By:
<select id="order">
<option value="name">Name</option>
<option value="count">Frequency</option>
<option value="post_count">Posts Sent</option>
<option value="posts_received">Posts Received</option>
</select>
</div>
<div class='d3-visual'><div id='matrixHeatmap'></div></div>
<div id='right-container'>
<h4>Matrix Heatmap</h4>
<p>The matrix visualization the number of communications a person was a part of.</p>
<p>The color of the cell between two students shows the frequency of connections. The darker the cell the higher the frequency.</p>
<p>The order of the matrix can be set to the total frequency of connections, number of posts sent, number of posts recieved, or name.</p>
</div>
<div class='discussionLink'></div>
</div> -->
<div id="statistics">
<div id="genStats">
<div id="tPart"></div>
<div id="tPost"></div>
<div id="tDeleted"></div>
<div id="tThread"></div>
</div>
<br><div id="userStats" class="statTable"></div>
<br><div id="threadStats" class="statTable"></div>
<!--<div id="dataWord"><br/>Thread Word Counts - ratio of original thread word count to total posts in thread</div>-->
</div>
<div id="dataset">
<br><div id="snaRaw" clas="statTable"></div>
</div>
<div id="cloud">
<div class='d3-visual'><div id='wordCloud'></div></div>
</div>
<!--<div id="stream">
<div class='d3-visual'><div id='networkStream'></div></div>
<div id='right-container'>
<h4>Network Stream</h4>
<p>This network visualization shows ...</p>
</div>
<div class='discussionLink'></div>
</div>-->
<!--<div id="about"></div>-->
<!--<div id="roadmap"></div>-->
<div id="help"></div>
</div>
<div id='saveImage'>
<button class="btn btn-success" id="save_as_svg" value="">Save as SVG</button>
<button class="btn btn-success" id="save_as_pdf" value="">Save as PDF</button>
<button class="btn btn-success" id="save_as_png" value="">Save as High-Res PNG</button>
</div>
<div id="svgdataurl"></div>
<!-- Hidden <FORM> to submit the SVG data to the server, which will convert it to SVG/PDF/PNG downloadable file.
The form is populated and submitted by the JavaScript below. -->
<form id="svgform" method="post" action="/cgi-bin/svgDownload.pl">
<input type="hidden" id="output_format" name="output_format" value="">
<input type="hidden" id="data" name="data" value="">
</form>
</div>
<div id='noTopics'>
<h3>No Discussion Topics Avaliable</h3>
<p>Before you can use Threadz, there must be at minimum of one published disucssion in your course with one or more submitted posts. Please check to make sure that your course meets these requirments.</p>
</div>
<script>
//jquery submit Discussion Topic choice on change
$(function() {
//hide the network and matrix forms until a discussion has been selected.
$('#networkSize').hide();
$('#matrixOrder').hide();
$('#saveImage').hide();
<?php echo $topicsAvaliable ?>
//submit the topic list dropdown menu on change
$('#topic_list').change(function() {
$('#formTopics').submit();
});
$('#formTopics').submit(function() {
var dtype = $("#topic_list option:selected").attr("class");
var disabled = [];
var activeTab = 0;
//Types of discussions are 'side_comment' or 'threaded'
//If this is a threaded discussion, you can disable tabs if desired.
//if(dtype!="threaded"){
// var disabled = [0,1,3,4];
// var activeTab = 5;
//}
$.ajax({
type: "POST",
url: "ajax.php",
data: $("#formTopics").serialize(), // serializes the form's elements.
dataType: 'json',
success: function(data){
if(data == "Expired Session, please reauthenticate Threadz."){
//console.log(data)
$('topics').html(data);
}else{
d3data = data;
$('#networkDirected').html(d3data);
$('#dataTest').html(d3data);
$('#networkDirected').append(makeForceDirected(d3data));
$('#welcome').hide();
$('#networkSize').show();
$('#networkColor').hide();
$('#userKey').show();
$('#threadKey').hide();
$('#nodeType-posts').show();
$('#nodeType-people').hide();
$('#matrixOrder').show();
$('#vis_container').tabs('option', 'disabled',disabled);
$('#vis_container').tabs({active: activeTab});
$('.discussionLink').html("<a class='mini' target='_blank' href='" + d3data.topic.topic_url + "'>go to Discussion</a>");
$('#saveImage').show();
$('input:radio[name="nodeTypeDisplay"][value="threads"]').prop('checked',true);
$('#nodeSize').val('sent');
$('#nodeColor').val('none');
}
}
//dataType: 'json',
//encode: true
});
//the json data returned from ajax.php
//.done(function(data){
// var arrData = data;
// console.log(data);
// //$('#network').html(JSON.stringify(data));
// $('#network').html(data);
// $('#network').append('did it work?<br/>');
//});
return false;
//event.preventDefault();
});
//submit the topic list dropdown menu on change
//$('#nodeType-posts').click(function() {
// $('#networkDirected').append(makeFDposts(d3data));
// $('#networkColor').show();
// $('#networkSize').hide();
// $('#nodeType-posts').hide();
// $('#nodeType-people').show();
// });
//
//$('#nodeType-people').click(function(){
// $('#networkDirected').append(makeForceDirected(d3data));
// $('#networkColor').hide();
// $('#networkSize').show();
// $('#nodeType-posts').show();
// $('#nodeType-people').hide();
// });
$('input:radio[name="nodeTypeDisplay"]').change(
function(){
var valRadio = $('input:radio[name="nodeTypeDisplay"]:checked').val();
if( valRadio == 'threads'){
$('#nodeSize').val('sent');
$('#networkDirected').append(makeForceDirected(d3data));
$('#networkColor').hide();
$('#networkSize').show();
$('#userKey').show();
$('#threadKey').hide();
}else if(valRadio == 'people'){
$('#nodeColor').val('none').change();
$('#networkDirected').append(makeFDposts(d3data));
$('#networkColor').show();
$('#networkSize').hide();
$('#userKey').hide();
$('#threadKey').show();
}
});
//create tabs navigation for the visualization data
$('#vis_container').tabs({
beforeActivate: function (event, ui) {
var runD3 = ui.newPanel.attr('id');
switch(runD3){
case 'network':
$('line').css({"stroke": "#eee", "stroke-width": "1.5px"});
var valRadio = $('input:radio[name="nodeTypeDisplay"]:checked').val();
if( valRadio == 'threads'){
$('#nodeSize').val('sent');
$('#networkDirected').append(makeForceDirected(d3data));
$('#networkColor').hide();
$('#networkSize').show();
}else if(valRadio == 'people'){
$('#nodeColor').val('none').change();
$('#networkDirected').append(makeFDposts(d3data));
$('#networkColor').show();
$('#networkSize').hide();
}
//$('#networkDirected').append(makeForceDirected(d3data));
//$('#nodeSize').val('sent');
$('#right-container').show();
$('#saveImage').show();
$('#nodeType-posts').show();
$('#nodeType-people').hide();
break;
////Due to an issue with the timing of the d3 rendering, the chord diagram needs to be created from its own page.
////The function getComputedTextLength() is used within makeChodMatrix() on the d3-visulas.js page to calculate the length
////of text taken up by the name of the user. This is then used to determin if the name will fit in the display space or not.
////Unfortunately to be useful, that function has to be called after the chart is rendered, otherwise it will always return a
////length of zero. To render the chart in a timely manner, the Chord Diagram is no longer being generated via this jquery script
////and is now being called from chord.php.
//case 'chord':
// $('#chord').append(makeChordMatrix(d3data));
// break;
case 'timeline':
//$('#timeline').append(makeTimeline1(d3data));
$('#timeline').append(makeTimeline2(d3data));
$('#saveImage').show();
break;
case 'matrix':
$('line').css({"stroke": "#fff", "stroke-width": ".5px"});
$('text.active').css({"fill": "red"});
$('#matrix').append(makeBetween(d3data));
//$('#matrix').append(makeAdjMatrix(d3data));
$('#saveImage').show();
break;
case 'statistics':
$('#statistics').append(makeStatistics(d3data));
$('#saveImage').hide();
break;
case 'dataset':
$('#dataset').append(makeDataSet(d3data));
$('#saveImage').hide();
break;
case 'stream':
//$('#stream').append(makeStream(d3data));
//$('#stream').append(makeFDposts(d3data));
break;
case 'cloud':
$('#cloud').append(makeCloud(d3data));
break;
}
}
//beforeLoad: function( event, ui ) {
// ui.jqXHR.error(function() {
// ui.panel.html(
// "Please select a discussion from the list above." );
// });
//}
});
//set About tab as start and disable all graph tabs
$('#vis_container').tabs({
disabled: [0,1,2,3,4],
active: 5
});
});
</script>
<script>
//(function ($) {
// $.extend($.fn, {
// makeCssInline: function () {
// this.each(function (idx, el) {
// var style = el.style;
// var properties = [];
// for (var property in style) {
// if ($(this).css(property)) {
// properties.push(property + ':' + $(this).css(property));
// }
// }
// this.style.cssText = properties.join(';');
// $(this).children().makeCssInline();
// });
// }
// });
//}(jQuery));
//http://d3export.housegordon.org/
//https://github.com/agordon/d3export_demo
/*
Utility function: populates the <FORM> with the SVG data
and the requested output format, and submits the form.
*/
function submit_download_form(output_format)
{
//https://gist.github.com/devinus/415179
//gistfile1.js
(function ($) {
var svgText =($('svg')[0]);
//NOTE: if the order of the stylesheets changes then the reference number to the d3-viz stylesheet will also need to change below.
//This can be changed by looping through the document.styleSheets looking for 'd3-viz' in [0].href
var rules = document.styleSheets[2].cssRules;
for (var idx = 0, len = rules.length; idx < len; idx++) {
//$(rules[idx].selectorText).each(function (i, elem) {
$('svg').find(rules[idx].selectorText).each(function (i, elem) {
elem.style.cssText += rules[idx].style.cssText;
});
}
$('style').remove();
$('script').remove();
})(jQuery);
// Get the d3js SVG element
// Extract the data as SVG text string
var svg = $('svg')[0];
var svg_xml = (new XMLSerializer).serializeToString(svg);
// Submit the <FORM> to the server.
// The result will be an attachment file to download.
var form = document.getElementById("svgform");
form['output_format'].value = output_format;
form['data'].value = svg_xml ;
form.submit();
}
/*
One-time initialization
*/
$(document).ready(function() {
// Attached actions to the buttons
$("#save_as_svg").click(function() { submit_download_form("svg"); });
$("#save_as_pdf").click(function() { submit_download_form("pdf"); });
$("#save_as_png").click(function() { submit_download_form("png"); });
});
</script>
<script>
//http://blog.eliacontini.info/post/79860720828/export-to-csv-using-javascript-the-download
//https://github.com/EliaContini/js-experiments/blob/master/exportToCSV/index.html
// prepare CSV data
function save2CSV(data, fileName){
var csvData = new Array();
//csvData.push('"Book title","Author"');
data.forEach(function(item, index, array) {
csvData.push('"' + item.title + '","' + item.author + '"');
});
// download stuff
//var fileName = "data.csv";
var buffer = csvData.join("\n");
var blob = new Blob([buffer], {
"type": "text/csv;charset=utf8;"
});
var link = document.createElement("a");
if(link.download !== undefined) { // feature detection
// Browsers that support HTML5 download attribute
link.setAttribute("href", window.URL.createObjectURL(blob));
link.setAttribute("download", fileName);
}
else if(navigator.msSaveBlob) { // IE 10+
navigator.msSaveBlob(blob, fileName);
}
else {
// it needs to implement server side export
link.setAttribute("href", "http://www.example.com/export");
}
link.innerHTML = "Export to CSV";
document.body.appendChild(link);
}
</script>
</body>
</html>