PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/createResultObject.php

https://github.com/Jessicasoon/ProjectKentRidgeV2
PHP | 139 lines | 137 code | 2 blank | 0 comment | 6 complexity | 44372e9f07ccc04e73444beb7a133e7f MD5 | raw file
  1. <?php // get result number
  2. if(isset($_GET['load'])){
  3. $unikey = $_GET['unikey'];
  4. require('quizrooDB.php');
  5. $query = sprintf("SELECT result_id, result_title, result_description, result_picture FROM q_results WHERE fk_quiz_id = %d", GetSQLValueString($_GET['id'], "int"));
  6. $getQuery = mysql_query($query, $quizroo) or die(mysql_error());
  7. $row_getQuery = mysql_fetch_assoc($getQuery);
  8. $totalRows_getQuery = mysql_num_rows($getQuery);
  9. $result = 0;
  10. if($totalRows_getQuery > 0){
  11. do{ $count = 1;
  12. ?>
  13. <div id="r<?php echo $result; ?>" class="resultWidget">
  14. <input type="hidden" name="ur<?php echo $result; ?>" id="ur<?php echo $result; ?>" value="<?php echo $row_getQuery['result_id']; ?>" />
  15. <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">
  16. <tr>
  17. <th colspan="2" valign="top" scope="row"><a href="javascript:;" onclick="QuizResult.remove(<?php echo $result; ?>);"><img src="img/delete.png" alt="" width="16" height="16" border="0" align="absmiddle" title="Remove" /></a> Result</th>
  18. </tr>
  19. <tr>
  20. <th width="120" valign="top" scope="row"><label for="result_title_<?php echo $result; ?>">Title</label></th>
  21. <td><span id="sprytextfield-result_title_<?php echo $result; ?>" class="sprytextfield"><input type="text" name="result_title_<?php echo $result; ?>" id="result_title_<?php echo $result; ?>" value="<?php echo $row_getQuery['result_title']; ?>" /><span class="textfieldRequiredMsg">A value is required.</span></span>
  22. <span class="desc">Provide a title for this result!</span></td>
  23. </tr>
  24. <tr>
  25. <th width="120" valign="top" scope="row"><label for="result_description_<?php echo $result; ?>">Description</label></th>
  26. <td><span id="sprytextarea-result_description_<?php echo $result; ?>" class="sprytextarea"><textarea name="result_description_<?php echo $result; ?>" id="result_description_<?php echo $result; ?>" cols="45" rows="5"><?php echo $row_getQuery['result_description']; ?></textarea><span class="textareaRequiredMsg">Description should not be blank!</span></span>
  27. <span class="desc">Tell the quiz taker what this result means</span></td>
  28. </tr>
  29. <tr>
  30. <th width="120" rowspan="4" valign="top" scope="row"><label>Picture</label>
  31. <input name="result_picture_<?php echo $result; ?>" type="hidden" id="result_picture_<?php echo $result; ?>" value="<?php echo $row_getQuery['result_picture']; ?>" /></th>
  32. <td><div id="swfupload-control-<?php echo $result; ?>" class="swfupload-control">
  33. <script>initUploader("result_picture_<?php echo $result; ?>")</script>
  34. <table border="0" cellspacing="0" cellpadding="0">
  35. <tr>
  36. <td><input name="uploader-<?php echo $result; ?>" type="button" id="uploader-<?php echo $result; ?>" /></td>
  37. <td valign="middle" class="formDesc">Upload a new picture (jpg, gif or png); You can select more than 1 file!</td>
  38. </tr>
  39. </table>
  40. <table border="0" cellspacing="0" cellpadding="5">
  41. <tr>
  42. <td><div id="selected-image-<?php echo $result; ?>" class="selected-image"></div></td>
  43. <td><p id="queuestatus-<?php echo $result; ?>"></p></td>
  44. </tr>
  45. </table>
  46. <ol id="log-<?php echo $result; ?>" class="log">
  47. </ol>
  48. </div></td>
  49. </tr>
  50. <tr>
  51. <td><div id="pictureChoser_<?php echo $result; ?>"><?php if(sizeof(glob("../quiz_images/".$unikey."*")) > 0){ ?><table border="0" cellspacing="0" cellpadding="3">
  52. <tr>
  53. <td><span class="formDesc">OR click on a picture below to use it as the result picture</span></td>
  54. </tr>
  55. <tr>
  56. <td><?php // return uploaded images
  57. if($unikey != ""){ foreach(glob("../quiz_images/".$unikey."*") as $filename){ ?>
  58. <a href="javascript:;" onClick="selectImage(<?php echo $result; ?>, '<?php echo str_replace("'", "\\'", basename($filename)); ?>')"><img src="../quiz_images/imgcrop.php?w=80&h=60&f=<?php echo basename($filename); ?>" width="80" height="60" id="r<?php echo $result; ?>i<?php echo $count; ?>" class="selectImage"></a>
  59. <?php $count++; }} ?>
  60. </td>
  61. </tr>
  62. </table><?php } ?></div></td>
  63. </tr>
  64. </table>
  65. </div>
  66. <?php $result++;
  67. }while($row_getQuery = mysql_fetch_assoc($getQuery));
  68. }
  69. }elseif(isset($_GET['delete'])){
  70. // delete the result
  71. require('member.php');
  72. require('quiz.php');
  73. // also pass in the member id for security check
  74. $quiz = new Quiz($_GET['id']);
  75. $member = new Member();
  76. if(!$quiz->removeResult($_GET['result'], $member->id)){
  77. echo "Delete not authorized";
  78. }
  79. }else{
  80. $result = $_GET['resultNumber'];
  81. $unikey = $_GET['unikey'];
  82. $count = 1;
  83. ?>
  84. <div id="r<?php echo $result; ?>" class="resultWidget">
  85. <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0">
  86. <tr>
  87. <th colspan="2" valign="top" scope="row"><a href="javascript:;" onclick="QuizResult.remove(<?php echo $result; ?>);"><img src="img/delete.png" alt="" width="16" height="16" border="0" align="absmiddle" title="Remove" /></a> Result</th>
  88. </tr>
  89. <tr>
  90. <th width="120" valign="top" scope="row"><label for="result_title_<?php echo $result; ?>">Title</label></th>
  91. <td><span id="sprytextfield-result_title_<?php echo $result; ?>" class="sprytextfield"><input type="text" name="result_title_<?php echo $result; ?>" id="result_title_<?php echo $result; ?>" /><span class="textfieldRequiredMsg">A value is required.</span></span>
  92. <span class="desc">Provide a title for this result!</span></td>
  93. </tr>
  94. <tr>
  95. <th width="120" valign="top" scope="row"><label for="result_description_<?php echo $result; ?>">Description</label></th>
  96. <td><span id="sprytextarea-result_description_<?php echo $result; ?>" class="sprytextarea"><textarea name="result_description_<?php echo $result; ?>" id="result_description_<?php echo $result; ?>" cols="45" rows="5"></textarea><span class="textareaRequiredMsg">Description should not be blank!</span></span>
  97. <span class="desc">Tell the quiz taker what this result means</span></td>
  98. </tr>
  99. <tr>
  100. <th width="120" rowspan="4" valign="top" scope="row"><label>Picture</label>
  101. <input name="result_picture_<?php echo $result; ?>" type="hidden" id="result_picture_<?php echo $result; ?>" value="" /></th>
  102. <td><div id="swfupload-control-<?php echo $result; ?>" class="swfupload-control">
  103. <script>initUploader("result_picture_<?php echo $result; ?>")</script>
  104. <table border="0" cellspacing="0" cellpadding="0">
  105. <tr>
  106. <td><input name="uploader-<?php echo $result; ?>" type="button" id="uploader-<?php echo $result; ?>" /></td>
  107. <td valign="middle" class="formDesc">Upload a new picture (jpg, gif or png); You can select more than 1 file!</td>
  108. </tr>
  109. </table>
  110. <table border="0" cellspacing="0" cellpadding="5">
  111. <tr>
  112. <td><div id="selected-image-<?php echo $result; ?>" class="selected-image"></div></td>
  113. <td><p id="queuestatus-<?php echo $result; ?>"></p></td>
  114. </tr>
  115. </table>
  116. <ol id="log-<?php echo $result; ?>" class="log">
  117. </ol>
  118. </div></td>
  119. </tr>
  120. <tr>
  121. <td><div id="pictureChoser_<?php echo $result; ?>"><?php if(sizeof(glob("../quiz_images/".$unikey."*")) > 0){ ?><table border="0" cellspacing="0" cellpadding="3">
  122. <tr>
  123. <td><span class="formDesc">OR click on a picture below to use it as the result picture</span></td>
  124. </tr>
  125. <tr>
  126. <td><?php // return uploaded images
  127. if($unikey != ""){ foreach(glob("../quiz_images/".$unikey."*") as $filename){ ?>
  128. <a href="javascript:;" onClick="selectImage(<?php echo $result; ?>, '<?php echo basename($filename); ?>')"><img src="../quiz_images/imgcrop.php?w=80&h=60&f=<?php echo basename($filename); ?>" width="80" height="60" id="r<?php echo $result; ?>i<?php echo $count; ?>" class="selectImage"></a>
  129. <?php $count++; }} ?>
  130. </td>
  131. </tr>
  132. </table><?php } ?></div></td>
  133. </tr>
  134. </table>
  135. </div>
  136. <?php } ?>