course.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?PHP
  2. include "../pcdl/html_head.php";
  3. ?>
  4. <body>
  5. <?php
  6. require_once("../pcdl/head_bar.php");
  7. ?>
  8. <style>
  9. #main_video_win iframe{
  10. width:100%;
  11. height:100%;
  12. }
  13. </style>
  14. <link href='../lib/main.css' rel='stylesheet' />
  15. <script src='../lib/main.js'></script>
  16. <script>
  17. document.addEventListener('DOMContentLoaded', function() {
  18. var initialTimeZone = 'local';
  19. var timeZoneSelectorEl = document.getElementById('time-zone-selector');
  20. var loadingEl = document.getElementById('loading');
  21. var calendarEl = document.getElementById('calendar');
  22. var calendar = new FullCalendar.Calendar(calendarEl, {
  23. timeZone: initialTimeZone,
  24. headerToolbar: {
  25. left: 'prev,next today',
  26. center: 'title',
  27. right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
  28. },
  29. initialDate: '2020-09-12',
  30. navLinks: true, // can click day/week names to navigate views
  31. editable: true,
  32. selectable: true,
  33. dayMaxEvents: true, // allow "more" link when too many events
  34. events: {
  35. url: 'php/get-events.php',
  36. failure: function() {
  37. document.getElementById('script-warning').style.display = 'inline'; // show
  38. }
  39. },
  40. loading: function(bool) {
  41. if (bool) {
  42. loadingEl.style.display = 'inline'; // show
  43. } else {
  44. loadingEl.style.display = 'none'; // hide
  45. }
  46. },
  47. eventTimeFormat: { hour: 'numeric', minute: '2-digit', timeZoneName: 'short' },
  48. dateClick: function(arg) {
  49. console.log('dateClick', calendar.formatIso(arg.date));
  50. },
  51. select: function(arg) {
  52. console.log('select', calendar.formatIso(arg.start), calendar.formatIso(arg.end));
  53. }
  54. });
  55. calendar.render();
  56. // load the list of available timezones, build the <select> options
  57. // it's HIGHLY recommended to use a different library for network requests, not this internal util func
  58. FullCalendar.requestJson('GET', 'php/get-time-zones.php', {}, function(timeZones) {
  59. timeZones.forEach(function(timeZone) {
  60. var optionEl;
  61. if (timeZone !== 'UTC') { // UTC is already in the list
  62. optionEl = document.createElement('option');
  63. optionEl.value = timeZone;
  64. optionEl.innerText = timeZone;
  65. timeZoneSelectorEl.appendChild(optionEl);
  66. }
  67. });
  68. }, function() {
  69. // TODO: handle error
  70. });
  71. // when the timezone selector changes, dynamically change the calendar option
  72. timeZoneSelectorEl.addEventListener('change', function() {
  73. calendar.setOption('timeZone', this.value);
  74. });
  75. });
  76. </script>
  77. <?php
  78. //
  79. require_once "../path.php";
  80. require_once "../public/_pdo.php";
  81. require_once '../ucenter/function.php';
  82. require_once '../public/function.php';
  83. global $PDO;
  84. PDO_Connect("sqlite:"._FILE_DB_COURSE_);
  85. $query = "select * from course where id = '{$_GET["id"]}' limit 0,1";
  86. $Fetch = PDO_FetchAll($query);
  87. if(count($Fetch)==0)
  88. {
  89. echo "无法找到此课程。可能该课程已经被拥有者删除。";
  90. exit;
  91. }
  92. $course_info = $Fetch[0];
  93. echo "<div id='course_head_bar' style='background-color:var(--tool-bg-color1);padding:1em 10px 10px 10px;'>";
  94. echo "<div class='index_inner '>";
  95. echo "<div style='font-size:140%'>";
  96. echo "<a href='../uhome/course.php?userid={$course_info["teacher"]}'>";
  97. echo ucenter_getA($course_info["teacher"]);
  98. echo "</a>";
  99. echo " > ";
  100. echo $course_info["title"];
  101. echo "</div>";
  102. echo '<div class="summary" style="padding-bottom:5px;">'.$course_info["subtitle"].'</div>';
  103. echo '<div class="summary" style="">';
  104. echo '<button>'.$_local->gui->watch.'</button>';
  105. echo '<button>'.$_local->gui->sign_up.'</button>';
  106. echo '<button>'.$_local->gui->share.'</button></div>';
  107. echo "</div>";
  108. echo '</div>';
  109. echo "<div class='index_inner'>";
  110. echo '<div class="card" style="margin:1em;padding:10px;">';
  111. echo '<div class="title">';
  112. echo $_local->gui->introduction;
  113. echo '</div>';
  114. echo '<div id="course_summary" class="detail">';
  115. echo '</div>';
  116. echo '<div class="title">';
  117. echo $_local->gui->attachment;
  118. echo '</div>';
  119. echo '<div id="course_attachment" class="detail">';
  120. echo '</div>';
  121. echo '</div>';
  122. echo "<div id='lesson_list'>";
  123. echo "</div>";
  124. ?>
  125. </div>
  126. <script>
  127. $("#main_video_win").height($("#main_video_win").width()*9/16);
  128. $.get("../course/course_get.php",
  129. {
  130. id:"<?php echo $_GET["id"]; ?>"
  131. },
  132. function(data,status){
  133. let arrLesson = JSON.parse(data);
  134. if(arrLesson && arrLesson.length>0){
  135. let summary = "";
  136. try{
  137. summary = marked(arrLesson[0]["summary"]);
  138. }
  139. catch(e){
  140. }
  141. $("#course_summary").html(summary);
  142. let attachment = "";
  143. try{
  144. attachment = marked(arrLesson[0]["attachment"]);
  145. }
  146. catch(e){
  147. }
  148. $("#course_attachment").html(attachment);
  149. }
  150. });
  151. $.get("../course/lesson_list.php",
  152. {
  153. id:"<?php echo $_GET["id"]; ?>"
  154. },
  155. function(data,status){
  156. let arrLesson = JSON.parse(data);
  157. let html="";
  158. for(const lesson of arrLesson){
  159. html+= '<div class="card" style="display:flex;margin:1em;padding:10px;">';
  160. html+= '<div style="flex:7;">';
  161. html+= '<div class="pd-10">';
  162. html+= '<div class="title" style="padding-bottom:5px;font-size:200%;font-weight:600;"><a href="../course/lesson.php?id='+lesson["id"]+'" style="color:var(--main-color);">'+lesson["title"]+'</a></div>';
  163. html += '<div style="overflow-y: scroll;max-height: 20em;">';
  164. let summary = "";
  165. try{
  166. summary = marked(lesson["summary"]);
  167. }
  168. catch{
  169. }
  170. html+= '<div class="summary" style="padding-bottom:5px;">'+summary+'</div>';
  171. let live = "";
  172. try{
  173. //live = marked(lesson["live"]);
  174. }
  175. catch{
  176. }
  177. html+= '<div class="summary" style="padding-bottom:5px;">'+live+'</div>';
  178. let replay = "";
  179. try{
  180. //replay = marked(lesson["replay"]);
  181. }
  182. catch{
  183. }
  184. html+= '<div class="summary" style="padding-bottom:5px;">'+replay+'</div>';
  185. let attachment = "";
  186. try{
  187. attachment = marked(lesson["attachment"]);
  188. }
  189. catch{
  190. }
  191. html+= '<div class="summary" style="padding-bottom:5px;">'+attachment+'</div>';
  192. html+= '</div>';
  193. html+= '</div>';
  194. html+= '</div>';
  195. html+= '<div style="flex:3;max-width:15em;">';
  196. let d = new Date();
  197. d.setTime(lesson["date"]);
  198. let strData = d.toLocaleDateString();
  199. let strTime = d.toLocaleTimeString();
  200. html+= '<div >'+gLocal.gui.date+':'+strData +'</div>';
  201. html+= '<div >'+gLocal.gui.time+':'+strTime +'</div>';
  202. let dt = lesson["duration"]/60;
  203. let sdt = "";
  204. if(dt>59){
  205. sdt += Math.floor(dt/60)+"小时";
  206. }
  207. let m = (dt % 60);
  208. if(m>0){
  209. sdt +=(dt % 60)+"分钟";
  210. }
  211. html+= "<div >"+gLocal.gui.duration+":"+sdt+"</div>";
  212. let now = new Date();
  213. let lesson_time="";
  214. if(now<lesson["date"]){
  215. lesson_time = gLocal.gui.not_started;
  216. }
  217. else if(now>lesson["date"] && now<(lesson["date"]+dt*1000)){
  218. lesson_time = gLocal.gui.in_progress;
  219. }
  220. else{
  221. lesson_time = gLocal.gui.already_over;
  222. }
  223. html+= '<div ><span class="lesson_status">'+lesson_time+'</span></div>';
  224. html+= '</div>';
  225. html+= '</div>';
  226. }
  227. $("#lesson_list").html(html);
  228. });
  229. </script>
  230. <?php
  231. include "../pcdl/html_foot.php";
  232. ?>