PageRenderTime 32ms CodeModel.GetById 20ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/rep.php

https://github.com/RootLoudDev/fluency_tool
PHP | 569 lines | 517 code | 43 blank | 9 comment | 81 complexity | f6b18e458d1cdf298a6d3b5fb5508a87 MD5 | raw file
  1<?php
  2include_once('includes/_bootstrap.php');
  3session_start();
  4checkLogin('associate');
  5
  6$userassociate = $_SESSION['user_name'];
  7$associateid = $_SESSION['user_id'];
  8
  9// Set up recorder 
 10$userDir=$userassociate;
 11$uploadsDir = "./uploads/" . $userDir;
 12
 13// Get user data
 14$currentUser = new User;
 15$currentUser->setUserFromID($_SESSION['user_id']);
 16$currentUser->getScenarios();
 17
 18//// Update scenario results
 19for ($i=1; $i<=7; $i++)
 20{
 21	$scenario[$i] = $currentUser->scenarios[($i-1)];
 22}
 23
 24	
 25// Get feedback data
 26$queryfeedback = "SELECT fbscenario, fbtext, fbtype, firstname, lastname FROM feedback, users
 27						WHERE associateid='$associateid' AND 
 28								(feedback.managerid = users.ID)";
 29$resultfeedback = mysql_query($queryfeedback);
 30if (mysql_num_rows($resultfeedback) >= 1)
 31{
 32	while ($rowfeedback = mysql_fetch_array($resultfeedback))
 33	{
 34		$scn = $rowfeedback['fbscenario'];
 35		$txt = $rowfeedback['fbtext'];
 36		$type = $rowfeedback['fbtype'];
 37		$fname = $rowfeedback['firstname'];
 38		$lname = $rowfeedback['lastname'];
 39		$fbText[$scn] .= $fname." ".$lname." - ".$txt.'\n';
 40	}
 41}
 42
 43// Get peerreview status
 44$querypeer = "SELECT * FROM peerreview WHERE reviewer='$associateid'";
 45$resultpeer = mysql_query($querypeer);
 46if (mysql_num_rows($resultpeer) >= 1)
 47{
 48	$userIsReviewer = 1;
 49} else {
 50	$userIsReviewer = 0;
 51}
 52?>
 53
 54<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 55<html xmlns="http://www.w3.org/1999/xhtml">
 56<head>
 57<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 58<title>PULMOZYME: Associate Screen</title>
 59<link href="styles.css" rel="stylesheet" type="text/css" />
 60
 61<link href="css/start/jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
 62<script type="text/javascript" src="script/jquery-min.js"></script>
 63<script type="text/javascript" src="script/jquery-ui-1.8.2.custom.min.js"></script>
 64<script type="text/javascript">
 65	$(function() {
 66		$("#accordion").accordion();
 67	});
 68	</script>
 69
 70<script language="javascript">
 71	var scenarioDone=new Array(7);
 72		scenarioDone[1] = "<?php echo $scenario[1] ?>"
 73		scenarioDone[2] = "<?php echo $scenario[2] ?>"
 74		scenarioDone[3] = "<?php echo $scenario[3] ?>"
 75		scenarioDone[4] = "<?php echo $scenario[4] ?>"
 76		scenarioDone[5] = "<?php echo $scenario[5] ?>"
 77		scenarioDone[6] = "<?php echo $scenario[6] ?>"
 78		scenarioDone[7] = "<?php echo $scenario[7] ?>"
 79	var fileName = "";
 80	var uploadsDir = "<?php echo $uploadsDir?>";
 81	var fileExtension = ".spx";
 82	var userIsReviewer = "<?php echo $userIsReviewer?>";
 83	
 84	function scenarioNameDisplay()
 85	{
 86		var fileNameDisplay = fileName.replace(fileExtension, "");
 87		fileNameDisplay = fileNameDisplay.substring(0,8) + " " + fileNameDisplay.substring(8);	
 88		return fileNameDisplay;
 89	}
 90	
 91	function loadPlayer(playFilename, displayName)
 92	{
 93		var d = new Date();
 94		var playString = playFilename + "?time=" + d.getTime();
 95		var display = displayName
 96		document.ListenUpPlayer.loadRecording(playString);	
 97		document.getElementById("nowplaying").innerHTML = display;		
 98	}
 99
100	function selectScenarioPlayable ()
101	{
102		var playString = uploadsDir + "/" + fileName
103//		var fileNameDisplay = fileName.replace(fileExtension, "");
104//		fileNameDisplay = fileNameDisplay.substring(0,8) + " " + fileNameDisplay.substring(8);
105		var fileNameDisplay = scenarioNameDisplay();
106		loadPlayer(playString, fileNameDisplay);
107		document.getElementById('loadIdealResponse').disabled = false;	
108	}
109	
110	function selectScenarioUnplayable (scenarioChanged)
111	{
112		var scenarioChanged = scenarioChanged;
113		document.getElementById('loadIdealResponse').disabled = true;
114		if (scenarioChanged == true)
115		{
116			document.ListenUpPlayer.erase();
117			document.getElementById("nowplaying").innerHTML = "Scenario not uploaded.";		
118		}
119	}
120	
121	function selectScenario(scenario)
122	{
123		var playable = document.JavaSonicRecorderUploader.isPlayable();
124		var scenarioChanged = false;
125		switch (scenario)
126		{
127		case 'one':
128			if (fileName != "Scenario1" + fileExtension)
129			{
130				scenarioChanged = true;
131			}
132			if (playable && scenarioChanged == true) 
133			{
134				document.JavaSonicRecorderUploader.erase();
135			}
136			fileName = "Scenario1.spx";
137			document.getElementById('notes').value = "<?php echo $fbText[1]; ?>";
138			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
139			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
140			if (scenarioDone[1] == 1) { 
141				selectScenarioPlayable();	
142			}else{
143				selectScenarioUnplayable(scenarioChanged);
144			}
145			break;
146		case 'two':
147			if (fileName != "Scenario2" + fileExtension)
148			{
149				scenarioChanged = true;
150			}
151			if (playable && scenarioChanged == true) 
152			{
153				document.JavaSonicRecorderUploader.erase();
154			}
155			fileName = "Scenario2.spx";
156			document.getElementById('notes').value = "<?php echo $fbText[2]; ?>";
157			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
158			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
159			if (scenarioDone[2] == 1) { 
160				selectScenarioPlayable();	
161			}else{
162				selectScenarioUnplayable(scenarioChanged);
163			}
164			break;
165		case 'three':
166			if (fileName != "Scenario3" + fileExtension)
167			{
168				scenarioChanged = true;
169			}
170			if (playable && scenarioChanged == true) 
171			{
172				document.JavaSonicRecorderUploader.erase();
173			}
174			fileName = "Scenario3.spx";
175			document.getElementById('notes').value = "<?php echo $fbText[3]; ?>";
176			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
177			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
178			if (scenarioDone[3] == 1) { 
179				selectScenarioPlayable();	
180			}else{
181				selectScenarioUnplayable(scenarioChanged);
182			}
183			break;
184		case 'four':
185			if (fileName != "Scenario4" + fileExtension)
186			{
187				scenarioChanged = true;
188			}
189			if (playable && scenarioChanged == true) 
190			{
191				document.JavaSonicRecorderUploader.erase();
192			}
193			fileName = "Scenario4.spx";
194			document.getElementById('notes').value = "<?php echo $fbText[4]; ?>";
195			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
196			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
197			if (scenarioDone[4] == 1) { 
198				selectScenarioPlayable();	
199			}else{
200				selectScenarioUnplayable(scenarioChanged);
201			}
202			break;
203		case 'five':
204			if (fileName != "Scenario5" + fileExtension)
205			{
206				scenarioChanged = true;
207			}
208			if (playable && scenarioChanged == true) 
209			{
210				document.JavaSonicRecorderUploader.erase();
211			}
212			fileName = "Scenario5.spx";
213			document.getElementById('notes').value = "<?php echo $fbText[5]; ?>";
214			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
215			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
216			if (scenarioDone[5] == 1) { 
217				selectScenarioPlayable();	
218			}else{
219				selectScenarioUnplayable(scenarioChanged);
220			}
221			break;
222		case 'six':
223			if (fileName != "Scenario6" + fileExtension)
224			{
225				scenarioChanged = true;
226			}
227			if (playable && scenarioChanged == true) 
228			{
229				document.JavaSonicRecorderUploader.erase();
230			}
231			fileName = "Scenario6.spx";
232			document.getElementById('notes').value = "<?php echo $fbText[6]; ?>";
233			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
234			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
235			if (scenarioDone[6] == 1) { 
236				selectScenarioPlayable();	
237			}else{
238				selectScenarioUnplayable(scenarioChanged);
239			}
240			break;
241		case 'seven':
242			if (fileName != "Scenario7" + fileExtension)
243			{
244				scenarioChanged = true;
245			}
246			if (playable && scenarioChanged == true) 
247			{
248				document.JavaSonicRecorderUploader.erase();
249			}
250			fileName = "Scenario7.spx";
251			document.getElementById('notes').value = "<?php echo $fbText[7]; ?>";
252			document.JavaSonicRecorderUploader.addNameValuePair("scenario", fileName);
253			document.getElementById("nowrecording").innerHTML = scenarioNameDisplay();		
254			if (scenarioDone[7] == 1) { 
255				selectScenarioPlayable();	
256			}else{
257				selectScenarioUnplayable(scenarioChanged);
258			}
259			break;
260		}
261	}
262	
263	function scenarioUpload () {
264		var scenariofile = fileName;
265		selectScenarioPlayable();
266		document.JavaSonicRecorderUploader.addNameValuePair("scenario", scenariofile);
267		switch (scenariofile)
268		{
269		case 'Scenario1.spx':
270		scenarioDone[1]="1";
271		break;
272		case 'Scenario2.spx':
273		scenarioDone[2]="1";
274		break;
275		case 'Scenario3.spx':
276		scenarioDone[3]="1";
277		break;
278		case 'Scenario4.spx':
279		scenarioDone[4]="1";
280		break;
281		case 'Scenario5.spx':
282		scenarioDone[5]="1";
283		break;
284		case 'Scenario6.spx':
285		scenarioDone[6]="1";
286		break;
287		case 'Scenario7.spx':
288		scenarioDone[7]="1";
289		break;		}
290	}
291
292function loadYourResponse()
293{
294	document.getElementById('loadIdealResponse').disabled = false;
295	document.getElementById('loadResponse').disabled = true;
296	var playString = uploadsDir + "/" + fileName
297	var fileNameDisplay = scenarioNameDisplay();
298	loadPlayer(playString, fileNameDisplay);
299}
300
301function loadIdealResponse()
302{
303	var bestScenarioFileName = "Optimal" + fileName;
304	var bestDir = "exampleAudio/"
305	var playString = bestDir + bestScenarioFileName;
306	var fileNameDisplay = "Ideal " + scenarioNameDisplay();
307	loadPlayer(playString, fileNameDisplay);
308	document.getElementById('loadIdealResponse').disabled = true;
309// Only allow load your response if you've actually uploaded a response
310	var num = fileName.substring(8,9);
311	if (scenarioDone[num] == "1") {
312		document.getElementById('loadResponse').disabled = false;
313	}
314}
315
316function recorderStateChange( previousState, newState)
317{
318	if (newState == "recording" && fileName == "")
319	{
320		document.JavaSonicRecorderUploader.erase();
321		alert("Please select a scenario before recording");
322	}
323	if (previousState == "recording" && fileName != "")
324	{
325		document.getElementById('loadIdealResponse').disabled = false;
326	}
327	
328}
329	
330function appletLoaded()
331{
332	if( !document.ListenUpPlayer.isActive() )
333	{
334		// Wait 100 milliseconds and try again.
335		setTimeout('appletLoaded()', 100 );
336	} else if ( !document.JavaSonicRecorderUploader.isActive()) 
337	{
338		setTimeout('appletLoaded()', 100 );
339	} else {
340		document.JavaSonicRecorderUploader.setUploadCompletionScript("scenarioUpload();");
341		animatedcollapse.init();
342		selectScenario('one_response');
343	}
344}	
345</script>
346</head>
347
348<body onLoad="appletLoaded();" rel="toggle[scen1]">
349<div id="container">
350<div class="blue" name="navmenu" id="navmenu" style="width: 100px; float: right;"><a href="logout.php"> Log Out </a>
351</div>
352<img src="images/logo.gif" width="303" height="98" alt="Pulmozyme" />
353<div id="content" align="center">
354 <table width="839" border="0">
355  <tr>
356    <td width="420" rowspan="3" valign="top">
357      <div id="column-wide">
358        <div id="menu-bar3" style="text-align:center;"> Scenarios</div>
359        <div class="contentInterior">
360          <div class="scenario">
361            <form action="" method="" name="territoryForm" id="territoryForm" onsubmit="">
362              <table border="0" cellspacing="1" cellpadding="0">
363                <tr>
364                  <td width="562" class="blue">
365
366                  <div id="instructions" class="drop" style="text-align:left"><strong>Instructions</strong>
367                    <p>Follow these instructions to get started:</p>
368  <ol>
369    <li>Read the first scenario presented.</li>
370    <li>Record your audio response. </li>
371    <li>Listen to your response. </li>
372    <li>Listen to an ideal response to the scenario.</li>
373    <li>Re-record until you are satisfied with your response.</li>
374    <li>Upload your audio response.</li>
375    <li>Continue this process until you have responded to all seven scenarios.</li>
376  </ol>
377</div>
378
379<!-- Begin Scenarios -->
380
381<div id="accordion">
382<?php
383  $results = mysql_query("SELECT * FROM scenarios");
384while($row = mysql_fetch_row($results)){
385
386    $id = $row[0];
387    $scenarioTitle = $row[1];
388    $scenarioDescription = $row[2];
389    $scenarioResource = $row[3];
390    ?>
391<h3><a href="#"><?=$scenarioTitle?></a></h3>
392    <div>
393        <p><strong>Description of the Situation</strong></p>
394        <?=$scenarioDescription?>
395        <p>
396        <strong>Description of Resources and Response</strong></p>
397        <p><?=$scenarioResource?></p>
398        <p><strong><u>Resources</u></strong></p>
399            <ul>
400            <?php $resource1Results = mysql_query("SELECT resource from resources WHERE scenarioID = '$id' AND resourceType = 1");
401                while ($row1 = mysql_fetch_array($resource1Results)) {
402                    $resource1 = $row1[0];
403                    ?>
404                    <li><?=$resource1?></li>
405                    <?php
406                }
407            ?>
408
409            </ul>
410        <p>For your background information only: Reprint Binder</p>
411            <ul>
412            <?php $resource2Results = mysql_query("SELECT resource from resources WHERE scenarioID = '$id' AND resourceType = 2");
413                while ($row2 = mysql_fetch_array($resource2Results)) {
414                    $resource2 = $row2[0];
415                    ?>
416                    <li><?=$resource2?></li>
417                    <?php
418                }
419            ?>
420
421            </ul>
422    </div>
423
424<?php
425}
426
427?>
428
429
430</div>
431
432
433<!--  End Scenarios -->
434                  </td>
435                </tr>
436                </table>
437              </form>
438            </div>
439          </div>
440      </div></td>
441    <td height="113" valign="top">
442    
443    <div id="column-wide">
444      <div id="menu-bar3" style="text-align:center;"> Record</div>
445      <div class="contentInterior" >
446	    <div id="nowrecording" style="text-align:center;" class="blue">Loading, please wait...</div>      
447      <!-- Recorder Applet -->
448<applet 
449    CODE="com.softsynth.javasonics.recplay.RecorderUploadApplet"
450	mayscript = "true"
451    CODEBASE="./codebase"
452    ARCHIVE="JavaSonicsListenUp.jar,OggXiphSpeexJS.jar"
453    NAME="JavaSonicRecorderUploader"
454    WIDTH="386" HEIGHT="130">
455	<param name="background" value="ffffff">
456	<param name="foreground" value="000000">
457	<param name="waveBackground" value="DCDCF6">
458	<param name="waveForeground" value="03175C">
459	<param name="skin" value="./images/DiddlySkin1.jpg">
460	<param name="bevelSize" value="0">
461    <param name="uploadURL" value="handle_upload_simple.php">
462    <param name="uploadFileName" value="upload.spx">
463	<param name="showLogo" value="no">
464	<param name="sendButtonText" value="Upload">
465	<param name="requestStateChanges" value="yes">
466	<param name="stateChangeCallback" value="recorderStateChange">
467	<param name="format" value="speex">
468	<param name="frameRate" value="8000">
469	
470	<param name="fieldName_1" value="userDir">
471	<param name="fieldRows_1" value="0">
472	<param name="fieldDefault_1" value="<?php echo $userDir ?>">
473
474	<param name="fieldName_2" value="scenario"> -->
475	<param name="fieldRows_2" value="0"> -->
476	<param name="fieldDefault_2" value="Scenario1.spx"> -->
477	
478	<param name="fieldName_3" value="userId">
479	<param name="fieldRows_3" value="0">
480	<param name="fieldDefault_3" value="<?php echo $associateid ?>">	
481	
482</applet>
483<!-- End Recorder Applet -->
484        <div id="scenario2" class="drop">
485            <table border="0" cellspacing="1" cellpadding="0">
486              <tr>
487                <td width="562" class="blue" style="text-align:left">Using the controls above, you can record and upload your audio response. First, select a scenario from the ones to the left.  Then click the microphone button to begin recording. Click “Upload” when you are done recording. Be sure to upload your recording BEFORE changing scenarios or your work will be lost.  Once you have recorded your response, you will be able to listen to an ideal response in the Listen section below. </td>
488              </tr>
489            </table>
490		</div>
491      </div>
492      <div id="menu-bar3" style="text-align:center;"> Listen</div>
493        <div class="contentInterior">
494          <div id="nowplaying" style="text-align:center;" class="blue">Scenario not uploaded.</div>      
495<!-- Player Applet -->
496<applet 
497    CODE="com.softsynth.javasonics.recplay.PlayerApplet"
498	mayscript = "true"
499    CODEBASE="./codebase"
500    ARCHIVE="JavaSonicsListenUp.jar,OggXiphSpeexJS.jar"
501    NAME="ListenUpPlayer"
502    WIDTH="386"
503    HEIGHT="90">
504	<param name="background" value="ffffff">
505	<param name="foreground" value="000000">
506	<param name="waveBackground" value="DCDCF6">
507	<param name="waveForeground" value="03175C">
508	<param name="skin" value="./images/DiddlySkin1.jpg">
509	<param name="bevelSize" value="0">
510	<param name="showTimeText" value="yes">
511	<param name="showLogo" value="no">
512</applet>
513<!-- End Applet -->	
514
515<input type="button" id="loadResponse" value="Load Your Response" disabled=true onclick="loadYourResponse()">
516<input type="button" id="loadIdealResponse" value="Load Ideal Response" disabled=true onclick="loadIdealResponse()">
517<p>
518        <div id="scenario2" class="drop">
519          <table border="0" cellspacing="1" cellpadding="0">
520            <tr>
521              <td width="562" class="blue" style="text-align:left">Using the controls above, you can listen to your uploaded response and an ideal response.  Your response is automatically loaded for listening immediately after upload or when you select a scenario you have already uploaded a response for.  "Load Ideal Response" will be available for a scenario after you have recorded your response.  Click "Load Ideal Response" to load the ideal response for your review. Once you listen to the ideal response, you may choose to re-record your response to the scenario by going back to the Record section (above). Remember to upload your response each time you re-record.  Only the last response recorded will be available for evaluation.</td>
522            </tr>
523          </table>
524        </div>
525      </div>
526        <div id="menu-bar3" style="text-align:center;"> Feedback</div>
527      <div class="contentInterior">
528        <div id="scenario2" class="drop">
529          <table border="0" cellspacing="1" cellpadding="0" >
530            <tr>
531              <td width="562" align="center" class="blue" ><form id="form1" name="form1" method="post" action="">
532                <label>
533                  <textarea name="notes" cols="40" rows="9" id="notes" disabled=true></textarea>
534                </label>
535              </form></td>
536            </tr>
537          </table>
538        </div>
539      </div>
540    </div></td>
541  </tr>
542  <tr>
543    <td height="200" valign="bottom">
544  
545</td>
546  </tr>
547  <tr>
548    <td width="409" height="2" valign="bottom"></td>
549    </tr>
550  </table>
551</div>
552</div>
553
554<script>
555if (userIsReviewer == "1")
556{	
557	document.getElementById("navmenu").innerHTML = '<?=$currentUser->username?> <a href="logout.php">Log Out </a><br/><br/><a href="manager.php"> Peer Review </a>';
558} else {
559document.getElementById("navmenu").innerHTML = '<?=$currentUser->username?> <a href="logout.php"> Log Out </a>';
560} 
561</script>
562
563<div id="footer1">
564  <p>THIS INFORMATION IS CONFIDENTIAL AND FOR INTERNAL EDUCATIONAL PURPOSES ONLY. 
565    <br />
566    SOME OF THE CONTENT WITHIN THIS CASE STUDY MAY NOT BE CONSISTENT WITH THE U.S. PRESCRIBING INFORMATION. </p>
567</div>
568</body>
569</html>