You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

course.js 51 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
10 years ago
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604
  1. //配置课程信息
  2. function course_setting(id)
  3. {
  4. //alert(id);
  5. //$('#tb_'+id).removeClass().addClass("hwork_hovertab");
  6. //$('#tbc_0'+id).removeClass().addClass("dis");
  7. //$('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab");
  8. //$('#tbc_0'+(3-id)).removeClass().addClass("undis");
  9. for (var i = 1; i < 5; i++) {
  10. if (i == id) {
  11. $("#tb_" + i).removeClass().addClass("hwork_hovertab");
  12. $("#tbc_0" + i).removeClass().addClass("dis");
  13. }
  14. else {
  15. $("#tb_" + i).removeClass().addClass("hwork_normaltab");
  16. $("#tbc_0" + i).removeClass().addClass("undis");
  17. }
  18. }
  19. }
  20. $(function(){
  21. $("img").removeAttr("align");
  22. });
  23. ///////////////////////////////////////////////////////////////
  24. //添加分班
  25. function add_group(url,course_id) {
  26. var group_name = $('#group_name').val();
  27. $.get(
  28. url,
  29. { valid: "name",
  30. value: group_name,
  31. course_id: course_id },
  32. function (data) {
  33. if (data.valid) {
  34. $("#add_group_name").submit();
  35. }
  36. else
  37. {
  38. alert(data.message);
  39. }
  40. }
  41. );
  42. }
  43. //修改分班:修改分班时得考虑什么都不改但是点击确定的情况
  44. function edit_group(id,url,course_id,group_id)
  45. {
  46. var group_name = $('#'+id).val();
  47. var group_id = $('#'+group_id).val();
  48. $.get(
  49. url,
  50. {
  51. valid: "name",
  52. value: group_name,
  53. course_id: course_id,
  54. group_id: group_id
  55. },
  56. function (data) {
  57. if (data.valid) {
  58. $("#update_group_form").submit();
  59. }
  60. else
  61. {
  62. alert(data.message);
  63. }
  64. }
  65. );
  66. }
  67. function hidden_homework_score_form()
  68. {
  69. hideModal($("#user_score"));
  70. }
  71. ///////////////////////////////////////////////////////////////
  72. ///////////////////////////////////////////////////////////////新建课程相关
  73. //验证课程名称
  74. function regex_course_name(str)
  75. {
  76. var name = $.trim($("#"+str+"_course_name").val());
  77. var syl_title = "";
  78. if($("#new_syllabus_id").length > 0){
  79. syl_title = $("#new_syllabus_id").find("option:selected").text();
  80. } else{
  81. if(str == "edit"){
  82. syl_title = $("#edit_syllabus_id").html();
  83. } else{
  84. syl_title = $("#course_syllabus_title").html();
  85. }
  86. }
  87. if(name.length < 2)
  88. {
  89. $("#"+str+"_course_name_notice").show();
  90. return false;
  91. }
  92. else if(name.indexOf(syl_title) != 0){
  93. $("#"+str+"_course_name_notice").html("请参照正确示例规范,应该以课程名称开头命名");
  94. $("#"+str+"_course_name_notice").show();
  95. return false;
  96. }
  97. else
  98. {
  99. $("#"+str+"_course_name_notice").hide();
  100. return true;
  101. }
  102. }
  103. //验证课程学时
  104. function regex_course_class_period(str)
  105. {
  106. var class_period = $.trim($("#"+str+"_class_period").val());
  107. var regex = /^\d*$/;
  108. if(class_period.length == 0)
  109. {
  110. $("#"+str+"_course_class_period_notice").html("学时总数不能为空");
  111. $("#"+str+"_course_class_period_notice").show();
  112. return false;
  113. }
  114. else if (regex.test(class_period)) {
  115. if(parseInt(class_period) > 0)
  116. {
  117. $("#"+str+"_course_class_period_notice").html("");
  118. $("#"+str+"_course_class_period_notice").hide();
  119. return true;
  120. }
  121. else
  122. {
  123. $("#"+str+"_course_class_period_notice").html("学时总数必须大于0");
  124. $("#"+str+"_course_class_period_notice").show();
  125. return false;
  126. }
  127. }
  128. else
  129. {
  130. $("#"+str+"_course_class_period_notice").html("学时总数必须为正整数");
  131. $("#"+str+"_course_class_period_notice").show();
  132. return false;
  133. }
  134. }
  135. //验证开始学期和结束学期
  136. function regex_time_term(str){
  137. var obj_time = document.getElementById(str+"_time");
  138. var obj_end_time = document.getElementById(str+"_end_time");
  139. var obj_term = document.getElementById(str+"_term");
  140. var obj_end_term = document.getElementById(str+"_end_term");
  141. var time = obj_time.options[obj_time.selectedIndex];
  142. var end_time = obj_end_time.options[obj_end_time.selectedIndex];
  143. var term = obj_term.options[obj_term.selectedIndex];
  144. var end_term = obj_end_term.options[obj_end_term.selectedIndex];
  145. if(time.value == end_time.value) {
  146. if(set_term_val(term.value) > set_term_val(end_term.value)) {
  147. $("#"+str+"_course_time_term_notice").html("开始学期不能晚于结束学期");
  148. $("#"+str+"_course_time_term_notice").show();
  149. return false;
  150. } else {
  151. $("#"+str+"_course_time_term_notice").html("");
  152. $("#"+str+"_course_time_term_notice").hide();
  153. return true;
  154. }
  155. } else if(time.value < end_time.value) {
  156. $("#"+str+"_course_time_term_notice").html("");
  157. $("#"+str+"_course_time_term_notice").hide();
  158. return true;
  159. } else {
  160. $("#"+str+"_course_time_term_notice").html("开始学期不能晚于结束学期");
  161. $("#"+str+"_course_time_term_notice").show();
  162. return false;
  163. }
  164. }
  165. //学期转换为数字
  166. function set_term_val(val) {
  167. if(val == "春季学期"){
  168. return 1;
  169. } else if(val == "夏季学期"){
  170. return 2;
  171. } else if(val == "秋季学期"){
  172. return 3;
  173. }
  174. }
  175. //验证密码
  176. function regex_course_password(str)
  177. {
  178. var class_period = $.trim($("#"+str+"_course_course_password").val());
  179. var regex = /^\w+$/;
  180. if(class_period.length == 0)
  181. {
  182. $("#"+str+"_course_course_password_notice").html("课程密码不能为空");
  183. $("#"+str+"_course_course_password_notice").show();
  184. return false;
  185. }
  186. else if (regex.test(class_period)) {
  187. $("#"+str+"_course_course_password_notice").html("");
  188. $("#"+str+"_course_course_password_notice").hide();
  189. return true;
  190. }
  191. else
  192. {
  193. $("#"+str+"_course_course_password_notice").html("课程密码有非法字符");
  194. $("#"+str+"_course_course_password_notice").show();
  195. return false;
  196. }
  197. }
  198. //验证课程大纲
  199. function regex_syllabus_option(str) {
  200. if(str == "new" && document.getElementById(str + "_syllabus_id")) {
  201. var obj = document.getElementById(str + "_syllabus_id");
  202. var syllabus = obj.options[obj.selectedIndex];
  203. if(parseInt(syllabus.value) == 0) {
  204. $("#"+str+"_course_syllabus_notice").show();
  205. return false;
  206. } else{
  207. $("#"+str+"_course_syllabus_notice").hide();
  208. return true;
  209. }
  210. } else {
  211. $("#"+str+"_course_syllabus_notice").hide();
  212. return true;
  213. }
  214. }
  215. //提交新建课程
  216. function submit_new_course()
  217. {
  218. if(regex_syllabus_option('new')&&regex_course_name('new')&&regex_course_class_period('new')&&regex_time_term('new'))
  219. {
  220. $("#new_course").submit();
  221. }
  222. }
  223. function submit_edit_course(id)
  224. {
  225. if(regex_syllabus_option('edit')&&regex_course_name('edit')&&regex_course_class_period('edit')&&regex_time_term('edit'))
  226. {
  227. $("#edit_course_"+id).submit();
  228. }
  229. }
  230. //新建课程大纲
  231. function submit_new_syllabus()
  232. {
  233. if(regex_syllabus_name())
  234. {
  235. $("#new_syllabus").submit();
  236. }
  237. }
  238. //课程讨论区
  239. function regexTopicSubject() {
  240. var name = $("#message_subject").val();
  241. if(name.length ==0)
  242. {
  243. $("#subjectmsg").text("标题不能为空");
  244. $("#subjectmsg").css('color','#ff0000');
  245. $("#message_subject").focus();
  246. return false;
  247. }
  248. else if(name.length <= 255)
  249. {
  250. $("#subjectmsg").text("填写正确");
  251. $("#subjectmsg").css('color','#008000');
  252. return true;
  253. }
  254. else
  255. {
  256. $("#subjectmsg").text("标题超过255个字符");
  257. $("#subjectmsg").css('color','#ff0000');
  258. $("#message_subject").focus();
  259. return false;
  260. }
  261. }
  262. function regexTopicDescription()
  263. {
  264. var name = message_content_editor.html();
  265. if(message_content_editor.isEmpty())
  266. {
  267. $("#message_content_span").text("描述不能为空");
  268. $("#message_content_span").css('color','#ff0000');
  269. return false;
  270. }
  271. else if(name.length >=6000){
  272. $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)");
  273. $("#message_content_span").css('color','#ff0000');
  274. return false;
  275. }
  276. else
  277. {
  278. $("#message_content_span").text("填写正确");
  279. $("#message_content_span").css('color','#008000');
  280. return true;
  281. }
  282. }
  283. function submit_topic()
  284. {
  285. // if(regexTopicSubject() && regexTopicDescription())
  286. // {
  287. message_content_editor.sync();
  288. $("#message-form").submit();
  289. // }
  290. }
  291. function reset_topic(){
  292. }
  293. ///////////////////////////////////////////////////////////////
  294. //////////////////////////////////////////////////////////////课程讨论区
  295. function regexSubject(id) {
  296. var subjectid = "#message_subject" + id ;
  297. var content = $.trim($(subjectid).val());
  298. var message = "#subject_span" + id;
  299. if (content.length == 0) {
  300. $(message).text("主题不能为空");
  301. $(message).css('color', '#ff0000');
  302. return false;
  303. }
  304. else {
  305. $(message).text("填写正确");
  306. $(message).css('color', '#008000');
  307. return true;
  308. }
  309. return false;
  310. }
  311. function regexContent(id) {
  312. var contentid = "#message_content" + id;
  313. var message = "#message_content_span"+ id;
  314. var content = $.trim($(contentid).val());
  315. if (content.length == 0) {
  316. $(message).text("描述不能为空");
  317. $(message).css('color', '#ff0000');
  318. return false;
  319. }
  320. else {
  321. $(message).text("填写正确");
  322. $(message).css('color', '#008000');
  323. return true;
  324. }
  325. return false;
  326. }
  327. // 项目讨论区编辑和提交
  328. function submitProjectsBoard(id) {
  329. var formid = "#message-form" + id;
  330. if (regexSubject(id) && regexContent(id)) {
  331. $(formid).submit();
  332. }
  333. }
  334. ///////////////////////////////////////////////////////////////
  335. /////////////////////////////////////////////////////////////// 课程通知
  336. function regexTitle()
  337. {
  338. var name = $("#news_title").val();
  339. if(name.length ==0)
  340. {
  341. $("#title_notice_span").text("标题不能为空");
  342. $("#title_notice_span").css('color','#ff0000');
  343. $("#news_title").focus();
  344. return false;
  345. }
  346. else if(name.length <= 60)
  347. {
  348. $("#title_notice_span").text("填写正确");
  349. $("#title_notice_span").css('color','#008000');
  350. return true;
  351. }
  352. else
  353. {
  354. $("#title_notice_span").text("标题超过60个字符");
  355. $("#title_notice_span").css('color','#ff0000');
  356. $("#news_title").focus();
  357. return false;
  358. }
  359. }
  360. function regexDescription()
  361. {
  362. var name = news_description_editor.html();
  363. if(news_description_editor.isEmpty())
  364. {
  365. $("#description_notice_span").text("描述不能为空");
  366. $("#description_notice_span").css('color','#ff0000');
  367. $("#description_notice_span").focus();
  368. return false;
  369. }
  370. /*else if(name.length >=6000){
  371. $("#description_notice_span").text("描述最多3000个汉字(或6000个英文字符)");
  372. $("#description_notice_span").css('color','#ff0000');
  373. $("#description_notice_span").focus();
  374. return false;
  375. }*/
  376. else
  377. {
  378. $("#description_notice_span").text("填写正确");
  379. $("#description_notice_span").css('color','#008000');
  380. return true;
  381. }
  382. }
  383. function submitNews()
  384. {
  385. if(regexTitle() && regexDescription())
  386. {
  387. news_description_editor.sync();
  388. $("#news-form").submit();
  389. }
  390. }
  391. function submitFocus(obj)
  392. {
  393. $(obj).focus();
  394. }
  395. function submitComment()
  396. {
  397. if (newsReplyVerify()) {
  398. comment_editor.sync();
  399. $("#add_comment_form").submit();
  400. }
  401. }
  402. function newsReplyVerify() {
  403. var content = comment_editor.html();
  404. if(comment_editor.isEmpty()) {
  405. $("#add_reply_news").text("评论不能为空");
  406. $("#add_reply_news").css('color', '#ff0000');
  407. $("#news_submit_comment").one('click',function(){
  408. submitComment();
  409. });
  410. return false;
  411. } else {
  412. $("#add_reply_news").text("填写正确");
  413. $("#add_reply_news").css('color', '#008000');
  414. return true;
  415. }
  416. }
  417. /////////////////////////////////////////////////课程讨论区
  418. function course_board_submit_message_replay()
  419. {
  420. if(MessageReplayVevify())
  421. {
  422. message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
  423. $("#message_form").submit();
  424. }
  425. }
  426. function course_board_canel_message_replay()
  427. {
  428. $("#reply").hide(200);
  429. $("#message_quote").html("");
  430. }
  431. function MessageReplayVevify() {
  432. var content = message_content_editor.html();//$.trim($("#message_content").val());
  433. if (message_content_editor.isEmpty()) {
  434. $("#message_content_span").text("回复不能为空");
  435. $("#message_content_span").css('color', '#ff0000');
  436. return false;
  437. }
  438. else {
  439. $("#message_content_span").text("填写正确");
  440. $("#message_content_span").css('color', '#008000');
  441. return true;
  442. }
  443. }
  444. //////////////////////////////////////////////////
  445. ///////////////////////////////////////////////////////////////
  446. ///////////////////////////////////////////////////////////////
  447. //验证搜索时输入名字
  448. function regexName(content)
  449. {
  450. var name = $.trim($("#name").val());
  451. if(name.length == 0)
  452. {
  453. $("#project_name_span").text(content);
  454. $("#project_name_span").css('color','#ff0000');
  455. $("#project_name_span").focus();
  456. return false;
  457. }
  458. else
  459. {
  460. $("#project_name_span").text("");
  461. return true;
  462. }
  463. }
  464. //提交搜索
  465. function submitSerch(content)
  466. {
  467. if(regexName(content)){$("#course_search_form").submit();}
  468. }
  469. //验证搜索时输入名字
  470. function regexQ(content)
  471. {
  472. var name = $.trim($("#q").val());
  473. if(name.length == 0)
  474. {
  475. $("#course_member_name_span").text(content);
  476. $("#course_member_name_span").css('color','#ff0000');
  477. $("#course_member_name_span").focus();
  478. return false;
  479. }
  480. else
  481. {
  482. $("#course_member_name_span").text("");
  483. return true;
  484. }
  485. }
  486. //提交课程成员搜索
  487. function submitMemberSerch(content)
  488. {
  489. //if(regexQ(content)){$("#course_member_search_form").submit();}
  490. $("#course_member_search_form").submit();
  491. }
  492. //课程描述显示更多信息
  493. function show_more_msg()
  494. {
  495. $("#course_description").toggleClass("course_description_none");
  496. var information = $("#expend_more_information");
  497. var arrow = $("#arrow");
  498. var val = information.attr("value");
  499. if (val == "show_more") {
  500. $("#expend_more_information").text("收起描述信息");
  501. information.attr("value", "hide_more");
  502. arrow.attr("src", "/images/jiantouup.jpg")
  503. }
  504. else {
  505. $("#expend_more_information").text("展开更多信息");
  506. information.attr("value", "show_more");
  507. arrow.attr("src", "/images/jiantou.jpg")
  508. }
  509. }
  510. //作业描述显示更多信息
  511. function news_show_more_des(id)
  512. {
  513. $('#news_description_' + id).toggleClass("news_description_none");
  514. if($("#news_description_" + id).hasClass("news_description_none"))
  515. {
  516. $("#news_foot_" + id).html("[收起]");
  517. }
  518. else
  519. {
  520. $("#news_foot_" + id).html("[展开]");
  521. }
  522. }
  523. function bid_show_more_des(id)
  524. {
  525. $("#bid_description_" + id).toggleClass("news_description_none");
  526. if($("#bid_description_" + id).hasClass("news_description_none"))
  527. {
  528. $("#bid_show_more_des_button" + id).html("[收起]");
  529. }
  530. else
  531. {
  532. $("#bid_show_more_des_button" + id).html("[展开]");
  533. }
  534. }
  535. //课程作业结束时间倒计时
  536. function show_bid_dead_line(year,month,day,divname)
  537. {
  538. var now = new Date();
  539. var endDate = new Date(year, month-1, day);
  540. var leftTime=endDate.getTime()-now.getTime();
  541. var leftsecond = parseInt(leftTime/1000);
  542. var day1=Math.floor(leftsecond/(60*60*24));
  543. var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
  544. var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
  545. var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
  546. $("#"+divname).html("<form name='formnow' class='fr'>"
  547. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+day1+"' > 天"
  548. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+hour+"' > 小时"
  549. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+minute+"' > 分"
  550. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+second+"' > 秒"
  551. + "</form>"
  552. + "<p class='fr'>作品提交还剩:</p>");
  553. }
  554. //处理迟交、缺评扣分
  555. function check_late_penalty(id)
  556. {
  557. var obj = $("#" + id);
  558. var regex = /^\d+$/;
  559. if(regex.test(obj.val()))
  560. {
  561. if(obj.val() > 50)
  562. {
  563. obj.val("50");
  564. }
  565. }
  566. else
  567. {
  568. obj.val("");
  569. }
  570. }
  571. //验证匿评数量
  572. //function regex_evaluation_num()
  573. //{
  574. // if($("#evaluation_num").length == 0){ return true;}
  575. // var evaluation_num = $.trim($("#evaluation_num").val());
  576. // var regex = /^\d+$/;
  577. // if(evaluation_num=="")
  578. // {
  579. // $("#evaluation_num_notice").html("匿评分配数量不能为空");
  580. // $("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
  581. // return false;
  582. // }
  583. // else if(regex.test(evaluation_num))
  584. // {
  585. // if(evaluation_num > 0)
  586. // {
  587. // $("#evaluation_num_notice").html("每个学生将收到<span class='c_red'>&nbsp;"+ parseInt(evaluation_num) + "&nbsp;</span>份待匿评作品");
  588. // $("#evaluation_num_notice").removeClass("c_red");
  589. // return true;
  590. // }
  591. // else
  592. // {
  593. // $("#evaluation_num_notice").html("匿评分配数量必须为大于0");
  594. // $("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
  595. // return false;
  596. // }
  597. // }
  598. // else
  599. // {
  600. // $("#evaluation_num_notice").html("匿评分配数量只能为数字");
  601. // $("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
  602. // return false;
  603. // }
  604. //}
  605. //点击是否开启匿评单选框效果
  606. $(function(){
  607. $("#absence_penalty").change(function(){
  608. $("#absence_penalty_notice").html("&nbsp;"+ $("#absence_penalty").val() +"&nbsp;");
  609. });
  610. });
  611. //生成select
  612. function build_selector(max_num){
  613. var html = "<select class='w61 fl ml15' id='ta_proportion' name='ta_proportion'>";
  614. for(var i = 0; i <= max_num; i += 10){
  615. if( i == max_num){
  616. html += "<option value='" + parseFloat(i)/100 + "' selected='selected'>" + i + "%</option>";
  617. }else{
  618. html += "<option value='" + parseFloat(i)/100 + "'>" + i + "%</option>";
  619. }
  620. }
  621. html += "</select>";
  622. return html;
  623. }
  624. function build_selector_sy(max_num){
  625. var html = "<select class='w61 fl ml15' id='sy_proportion' name='sy_proportion'>";
  626. for(var i = 0; i <= 100; i += 10){
  627. if( i == max_num){
  628. html += "<option value='" + parseFloat(i)/100 + "' selected='selected'>" + i + "%</option>";
  629. }else{
  630. html += "<option value='" + parseFloat(i)/100 + "'>" + i + "%</option>";
  631. }
  632. }
  633. html += "</select>";
  634. return html;
  635. }
  636. //提交匿评参数设置
  637. function submit_set_evaluation_attr(end_time){
  638. if(!regex_evaluation_start(end_time)){
  639. $("#evaluation_start_time").focus();
  640. }
  641. else if(!regex_evaluation_end()){
  642. $("#evaluation_end_time").focus();
  643. }
  644. else if(!regex_evaluation_num()){
  645. $("#evaluation_num").focus();
  646. }
  647. else{
  648. $('#muban_popup_box form').submit();
  649. hideModal();
  650. }
  651. }
  652. //验证匿评开启时间:大于截止时间,或者为空
  653. function regex_evaluation_start(end_time){
  654. var evaluation_start = $.trim($("#evaluation_start_time").val());
  655. if(evaluation_start == ""){
  656. $("#homework_evaluation_start_time").text("开启匿评日期不能为空");
  657. return false;
  658. }
  659. var end_time = new Date(end_time);
  660. var evaluation_start_time = new Date(evaluation_start);
  661. if(evaluation_start_time > end_time){
  662. $("#homework_evaluation_start_time").text("");
  663. return true;
  664. }else{
  665. $("#homework_evaluation_start_time").text("开启匿评日期必须大于截止日期");
  666. return false;
  667. }
  668. }
  669. //验证匿评结束时间:大于匿评开启时间,或者为空。当匿评开启时间为空时,匿评结束时间必须为空
  670. function regex_evaluation_end(){
  671. var evaluation_start = $.trim($("#evaluation_start_time").val());
  672. var evaluation_end = $.trim($("#evaluation_end_time").val());
  673. if(evaluation_end == ""){
  674. $("#homework_evaluation_end_time").text("关闭匿评日期不能为空");
  675. return true;
  676. }
  677. var evaluation_start_time = new Date(evaluation_start);
  678. var evaluation_end_time = new Date(evaluation_end);
  679. if(evaluation_end_time >= evaluation_start_time){
  680. $("#homework_evaluation_end_time").text("");
  681. return true;
  682. }else{
  683. $("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期");
  684. return false;
  685. }
  686. }
  687. //验证匿评数量
  688. function regex_evaluation_num(){
  689. var evaluation_num = $.trim($("#evaluation_num").val());
  690. var regex = /^\d+$/;
  691. if(evaluation_num==""){
  692. $("#evaluation_num_notice").text("匿评人数不能为空");
  693. return false;
  694. }
  695. else if(regex.test(evaluation_num)){
  696. if(evaluation_num > 0){
  697. $("#evaluation_num_notice").html("");
  698. return true;
  699. }
  700. else{
  701. $("#evaluation_num_notice").text("匿评人数必须为大于0");
  702. return false;
  703. }
  704. }
  705. else{
  706. $("#evaluation_num_notice").text("匿评人数只能为数字");
  707. return false;
  708. }
  709. }
  710. //老师提交 新建/修改 作业
  711. function submit_homework(id){
  712. if(!regex_homework_name()){
  713. $("#homework_name").focus();
  714. }
  715. else if(!regex_homework_end_time()){
  716. $("#homework_end_time").focus();
  717. }
  718. else if(!regex_homework_end_publish_time()){
  719. $("#homework_end_time").focus();
  720. }
  721. else if(!regex_course_id()){
  722. $("#course_id").focus();
  723. }
  724. else{
  725. homework_description_editor.sync();
  726. $("#"+id).submit();
  727. }
  728. }
  729. //验证新建作业的名字
  730. function regex_homework_name()
  731. {
  732. var type = $("#homework_type_option").children('option:selected').val();
  733. if(type == "0"){
  734. $('#select_type_nitice').show();
  735. return false;
  736. }
  737. var name = $.trim($("#homework_name").val());
  738. if(name=="")
  739. {
  740. $("#homework_name_span").text("名称不能为空");
  741. return false;
  742. }
  743. else
  744. {
  745. $("#homework_name_span").text("");
  746. return true;
  747. }
  748. }
  749. //验证发布时间不能大于截止时间
  750. function regex_homework_end_publish_time()
  751. {
  752. var myDate = new Date();
  753. if($.trim($("#homework_publish_time").val()) == "")
  754. {
  755. $("#homework_publish_time").val(formate_date(myDate));
  756. }
  757. var publish_time = Date.parse($("#homework_publish_time").val());
  758. var end_time = Date.parse($("#homework_end_time").val());
  759. if(end_time < publish_time)
  760. {
  761. $("#homework_end_time_span").text("截止日期不能小于发布日期");
  762. return false;
  763. }
  764. else
  765. {
  766. $("#homework_end_time_span").text("");
  767. return true;
  768. }
  769. }
  770. //验证截止时间
  771. function regex_homework_end_time()
  772. {
  773. var name = $.trim($("#homework_end_time").val());
  774. if(name=="")
  775. {
  776. $("#homework_end_time_span").text("截止时间不能为空");
  777. return false;
  778. }
  779. else
  780. {
  781. $("#homework_end_time_span").text("");
  782. return true;
  783. }
  784. }
  785. function formate_date(date){
  786. var str = "";
  787. var year = date.getFullYear();
  788. var month = date.getMonth() + 1;
  789. var day = date.getDate();
  790. if(month < 10) {
  791. month = '0' + month;
  792. }
  793. if(day < 10) {
  794. day = '0' + day;
  795. }
  796. str = year + '-' + month + '-' + day;
  797. return str;
  798. }
  799. //验证发送到课程
  800. function regex_course_id(){
  801. var course_id = $("#course_id").val();
  802. if(course_id == -1)
  803. {
  804. $("#homework_course_id_span").text("发布课程不能为空");
  805. return false;
  806. }
  807. else
  808. {
  809. $("#homework_course_id_span").text("");
  810. return true;
  811. }
  812. }
  813. //验证分组作业的参数
  814. function regex_group_attr(){
  815. var min = $.trim($("#min_num").val());
  816. var max = $.trim($("#max_num").val());
  817. var regex = /^\d+$/;
  818. if(!regex.test(min) || parseInt(min) <= 0) {
  819. $("#min_max_num_notice").html("人数为正整数");
  820. $("#min_max_num_notice").show();
  821. $("#min_num").focus();
  822. return false;
  823. } else {
  824. $("#min_max_num_notice").html("");
  825. $("#min_max_num_notice").hide();
  826. }
  827. if(!regex.test(max) || parseInt(max) <= 0) {
  828. $("#min_max_num_notice").html("人数为正整数");
  829. $("#min_max_num_notice").show();
  830. $("#max_num").focus();
  831. return false;
  832. } else {
  833. $("#min_max_num_notice").html("");
  834. $("#min_max_num_notice").hide();
  835. }
  836. if(parseInt(min) > parseInt(max)) {
  837. $("#min_max_num_notice").html("最小人数不得大于最大人数");
  838. $("#min_max_num_notice").show();
  839. $("#max_num").focus();
  840. return false;
  841. } else {
  842. $("#min_max_num_notice").html("");
  843. $("#min_max_num_notice").hide();
  844. }
  845. if ($("#base_on_project").is(":checked")) {
  846. $("#base_on_project").val(1);
  847. } else {
  848. $("#base_on_project").val(0);
  849. }
  850. return true;
  851. }
  852. //验证编程作业的参数
  853. function regex_program_attr() {
  854. var result = true;
  855. $.each($('#programHomework textarea.InputBox'), function(i, val){
  856. if (result && $(val).val().length<=0) {
  857. $(val)[0].focus();
  858. result = false;
  859. }
  860. });
  861. return result;
  862. }
  863. function regexHomeworkCommonName()
  864. {
  865. var name = $.trim($("#homework_attach_name").val());
  866. if(name=="")
  867. {
  868. $("#homework_attach_name_span").text("作品名称不能为空");
  869. $("#homework_attach_name_span").css('color','#ff0000');
  870. return false;
  871. }
  872. else
  873. {
  874. $("#homework_attach_name_span").text("填写正确");
  875. $("#homework_attach_name_span").css('color','#008000');
  876. return true;
  877. }
  878. }
  879. function regexHomeworkCommonDescription()
  880. {
  881. var name = $.trim($("#homework_attach_description").val());
  882. if(name=="")
  883. {
  884. $("#homework_attach_description_span").text("作品描述不能为空");
  885. $("#homework_attach_description_span").css('color','#ff0000');
  886. return false;
  887. }
  888. else
  889. {
  890. $("#homework_attach_description_span").text("填写正确");
  891. $("#homework_attach_description_span").css('color','#008000');
  892. return true;
  893. }
  894. }
  895. function submit_homework_form(){if(regexHomeworkCommonName()&&regexHomeworkCommonDescription()){$('#new_homework_attach').submit();}}
  896. //增加测试结果
  897. function add_programing_test(obj) {
  898. var now = new Date().getTime();
  899. obj.after("<div><li><label class='label02'>&nbsp;测试输入:&nbsp;</label><input type='text' class='fl h26 w190 mb10' name='input[" + now +"]'' />" +
  900. "</li><li ><label class='fl f14 ml10'>&nbsp;输出:&nbsp;</label><input type='text' class='fl h26 w190 mb10' name='output[" + now +"]' />" +
  901. "</li><li><a class='icon_add ml10' href='javascript:void(0);' title='添加测试' onclick='add_programing_test($(this).parent().parent())'></a>" +
  902. "<a class='icon_remove' href='javascript:void(0);' title='删除测试' onclick='remove_programing_test($(this).parent().parent())'></a>" +
  903. "<a class='blue_btn fl ml5 mt1 programing_test' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
  904. "<input type='hidden' id='test_result_" + now +"' name='result[" + now +"]'/>" +
  905. "</li><div class='cl'></div></div>");
  906. }
  907. //删除测试结果
  908. function remove_programing_test(obj) {
  909. if(obj.siblings("div").length == 0){
  910. alert("至少需要一组测试");
  911. }
  912. else{
  913. obj.remove();
  914. }
  915. }
  916. function show_window (id1,id2,top,left) {
  917. $('#'+ id1).css('top',top);
  918. $('#'+ id1).css('left',left);
  919. $('#'+ id1).css('display','block');
  920. $('#' + id2).css('display','block');
  921. }
  922. function close_window(id1,id2){
  923. $('#' + id1).css('display','none');
  924. $('#' + id2).css('display','none');
  925. }
  926. //隐藏提示狂
  927. function hidden_atert_form(cur_page,cur_type)
  928. {
  929. hideModal($("#popbox"));
  930. }
  931. //当课程描述长度小于112px时,不显示更多按钮
  932. $(function(){
  933. if($("#course_description_content").height()>400)
  934. {
  935. $("#lg-foot").show();
  936. }
  937. });
  938. //将右侧的最小高度设置成左侧高度,美化界面
  939. // firefox pre标签换行
  940. $(document).ready(function () {
  941. $("#RSide").css("min-height",$("#LSide").height()-30);
  942. var userAgent = navigator.userAgent.toLowerCase();
  943. var browser = {
  944. version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1],
  945. safari: /webkit/.test(userAgent),
  946. opera: /opera/.test(userAgent),
  947. msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
  948. mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
  949. };
  950. if (browser.mozilla || browser.opera){
  951. $("pre").addClass("break_word_firefox");
  952. }
  953. else{
  954. $("pre").addClass("break_word");
  955. }
  956. });
  957. // 日历选择日期后关闭
  958. function regexDeadLine()
  959. {
  960. ('#ui-datepicker-div').hide();
  961. }
  962. //新建、修改课程明码显示
  963. $(function(){
  964. $("#psw_btn").click(function() {
  965. if($("#new_course_course_password").length > 0) {
  966. alert("密码: "+$("#new_course_course_password").val());
  967. } else if($("#edit_course_course_password").length > 0){
  968. alert("密码: "+$("#edit_course_course_password").val());
  969. }
  970. });
  971. });
  972. //查找TAG资源
  973. var clickFunction = null; //单击事件函数
  974. var isdb = false; //是否双击
  975. function search_tag_attachment(url,tag_name,q,course_id,sort)
  976. {
  977. //alert("111");
  978. //clearTimeout(clickFunction);
  979. clickFunction = setTimeout(function() {
  980. search_func()
  981. }, 500);
  982. function search_func(){
  983. if(isdb!= false ) return;
  984. $.get(
  985. url,
  986. {
  987. tag_name: tag_name,
  988. q: q,
  989. course_id:course_id
  990. },
  991. function (data) {
  992. }
  993. );
  994. }
  995. }
  996. // 课程讨论区
  997. function showhelpAndScrollToMessage(id, id1, count) {
  998. $('#' + id).toggle();
  999. if(cookieget("repositories_visiable") == "true")
  1000. {
  1001. cookiesave("repositories_visiable", false,'','','');
  1002. }
  1003. else
  1004. {
  1005. cookiesave("repositories_visiable", true,'','','');
  1006. }
  1007. var information = $(id1);
  1008. var val = information.attr("value");
  1009. if(val=="show_help")
  1010. {
  1011. $(id1).text("收起回复(" + count + ")" );
  1012. information.attr("value", "hide_help");
  1013. }
  1014. else
  1015. {
  1016. $(id1).text("展开回复(" + count + ")");
  1017. information.attr("value", "show_help");
  1018. }
  1019. }
  1020. function show_more_reply(contentid, id2, id3) {
  1021. $(contentid).toggleClass("course_description_none");
  1022. var information = $(id2);
  1023. var arrow = $(id3);
  1024. var val = information.attr("value");
  1025. if (val == "show_more") {
  1026. $(id2).text("[收起]");
  1027. information.attr("value", "hide_more");
  1028. arrow.attr("src", "/images/jiantouup.jpg")
  1029. }
  1030. else {
  1031. $(id2).text("[展开]");
  1032. information.attr("value", "show_more");
  1033. arrow.attr("src", "/images/jiantou.jpg")
  1034. }
  1035. }
  1036. ///////////////////////////////////////////////
  1037. //学生作品
  1038. function show_project()
  1039. {
  1040. $("#about_project").slideToggle();
  1041. }
  1042. //验证作品名称
  1043. function regexStudentWorkName()
  1044. {
  1045. var name = $.trim($("#student_work_name").val());
  1046. if(name=="")
  1047. {
  1048. $("#student_work_name_span").text("作品名称不能为空");
  1049. return false;
  1050. }
  1051. else
  1052. {
  1053. $("#student_work_name_span").text("");
  1054. return true;
  1055. }
  1056. }
  1057. function regexStudentWorkDescription()
  1058. {
  1059. var name = $.trim($("#student_work_description").val());
  1060. if(name=="")
  1061. {
  1062. $("#student_work_description_textarea").text("作品描述不能为空");
  1063. return false;
  1064. }
  1065. else
  1066. {
  1067. $("#student_work_description_textarea").text("");
  1068. return true;
  1069. }
  1070. }
  1071. function regexStudentWorkMember(min, max) {
  1072. var members = $.trim($("#group_member_ids").val()).split(',');
  1073. if ( min <= members.length && members.length <= max ){
  1074. $("#student_work_group_textarea").text("");
  1075. return true;
  1076. } else {
  1077. $("#student_work_group_textarea").text("合作成员人数应为:"+min+"-"+max+"人");
  1078. return false;
  1079. }
  1080. }
  1081. //提交新建作品
  1082. function new_student_work()
  1083. {
  1084. if(regexStudentWorkName()&&regexStudentWorkDescription())
  1085. {
  1086. if($("#group_member_ids").length > 0) {
  1087. if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
  1088. $("#new_student_work").submit();
  1089. $("#ajax-indicator").hide();
  1090. }
  1091. } else {
  1092. $("#new_student_work").submit();
  1093. $("#ajax-indicator").hide();
  1094. }
  1095. }
  1096. }
  1097. function edit_student_work(id)
  1098. {
  1099. if(regexStudentWorkName()&&regexStudentWorkDescription())
  1100. {
  1101. $("#edit_student_work_" + id).submit();
  1102. $("#ajax-indicator").hide();
  1103. }
  1104. }
  1105. //
  1106. //滑动打分
  1107. $.fn.peSlider = function(settings){
  1108. //configurable options (none so far)
  1109. var o = $.extend({},settings);
  1110. if( !$('body').is('[role]') ){ $('body').attr('role','application'); }
  1111. return $(this).each(function(){
  1112. var thisLabel = $('label[for=' + $(this).attr('id') + ']').attr('id', $(this).attr('id') + '-label').attr('id');
  1113. var thisUnits = $(this).attr('data-units') || '';
  1114. var slider = $('<div></div>');
  1115. if( $(this).is('input') ){
  1116. var input = $(this);
  1117. var thisUnits = input.attr('data-units');
  1118. var friendlyVal = input.val() + ' ' + thisUnits;
  1119. var sliderOptions = $.extend(o,{
  1120. min: parseFloat(input.attr('min')),
  1121. max: parseFloat(input.attr('max')),
  1122. value: parseFloat(input.val())
  1123. });
  1124. if(parseFloat(input.val()) == -1){
  1125. input.css("color", "#fff");
  1126. input.next().next().html("未评分");
  1127. input.next().next().show();
  1128. } else{
  1129. input.css("color", "#000");
  1130. input.next().next().hide();
  1131. }
  1132. slider
  1133. .insertBefore(input)
  1134. .slider(sliderOptions)
  1135. .bind('slide', function(e, ui){
  1136. if(ui.value == -1){
  1137. input.css("color", "#fff");
  1138. input.next().next().html("未评分");
  1139. input.next().next().show();
  1140. } else {
  1141. input.css("color", "#000");
  1142. input.next().next().hide();
  1143. }
  1144. input.val(ui.value);
  1145. friendlyVal = input.val() + ' ' + thisUnits;
  1146. slider.find('a').attr({
  1147. 'aria-valuenow': ui.value,
  1148. 'aria-valuetext': friendlyVal
  1149. });
  1150. })
  1151. .find('a')
  1152. .attr({
  1153. 'role': 'slider',
  1154. 'aria-valuemin': input.attr('min'),
  1155. 'aria-valuemax': input.attr('max'),
  1156. 'aria-valuenow': input.val(),
  1157. 'aria-valuetext': friendlyVal,
  1158. 'aria-labelledby': thisLabel
  1159. });
  1160. input
  1161. .keyup(function(){
  1162. var inVal = parseFloat(input.val());
  1163. if( !isNaN(inVal) ){
  1164. if(inVal == -1){
  1165. input.css("color", "#fff");
  1166. input.next().next().html("未评分");
  1167. input.next().next().show();
  1168. } else {
  1169. input.css("color", "#000");
  1170. input.next().next().hide();
  1171. }
  1172. slider.slider('value', inVal);
  1173. input.val(slider.slider('value'));
  1174. }
  1175. })
  1176. .change(function(){
  1177. var inVal = parseFloat(input.val());
  1178. if( !isNaN(inVal) ){
  1179. if(inVal == -1){
  1180. input.css("color", "#fff");
  1181. input.next().next().html("未评分");
  1182. input.next().next().show();
  1183. } else {
  1184. input.css("color", "#000");
  1185. input.next().next().hide();
  1186. }
  1187. slider.slider('value', inVal);
  1188. input.val(slider.slider('value'));
  1189. }
  1190. })
  1191. .blur(function(){
  1192. var inVal = parseFloat(input.val());
  1193. if( isNaN(inVal) ){
  1194. input.val(-1);
  1195. }
  1196. if(input.val() == -1){
  1197. input.css("color", "#fff");
  1198. input.next().next().html("未评分");
  1199. input.next().next().show();
  1200. } else {
  1201. input.css("color", "#000");
  1202. input.next().next().hide();
  1203. }
  1204. });
  1205. if( !settings.step ){
  1206. var step = Math.round( parseFloat(input.attr('max')) / slider.width());
  1207. if(step > 1){ slider.slider('option','step',step); }
  1208. }
  1209. }
  1210. });
  1211. };
  1212. //返回顶部
  1213. $(function(){goTopEx();});
  1214. var Sys = {};
  1215. var ua = navigator.userAgent.toLowerCase();
  1216. var s;
  1217. (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
  1218. (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
  1219. (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
  1220. (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
  1221. (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
  1222. function goTopEx() {
  1223. var obj = document.getElementById("goTopBtn");
  1224. if(obj != null)
  1225. {
  1226. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  1227. function getScrollTop() {
  1228. var xsun = document.documentElement.scrollTop;
  1229. if (Sys.chrome) {
  1230. xsun=document.body.scrollTop;
  1231. }
  1232. return xsun;
  1233. }
  1234. function setScrollTop(value) {
  1235. if (Sys.chrome) {
  1236. document.body.scrollTop = value;
  1237. }
  1238. else {
  1239. document.documentElement.scrollTop = value;
  1240. }
  1241. }
  1242. window.onscroll = function () { getScrollTop() > 0 ? obj.style.display = "" : obj.style.display = "none"; };
  1243. obj.onclick = function () {
  1244. var goTop = setInterval(scrollMove, 10);
  1245. function scrollMove() {
  1246. setScrollTop(getScrollTop() / 1.1);
  1247. if (getScrollTop() < 1) clearInterval(goTop);
  1248. }
  1249. }
  1250. }
  1251. }
  1252. $(function(){
  1253. //匿评评分提示
  1254. $(".student_score_info").live("mouseover",function(){
  1255. $(this).find("div").show();
  1256. });
  1257. $(".student_score_info").live("mouseout",function(){
  1258. $(this).find("div").hide();
  1259. });
  1260. //最终成绩提示
  1261. $(".student_final_scor_info").live("mouseover",function(){
  1262. $(this).find("div").show();
  1263. });
  1264. $(".student_final_scor_info").live("mouseout",function(){
  1265. $(this).find("div").hide();
  1266. });
  1267. $("#about_project label").eq(1).remove();
  1268. ////附件下载提示
  1269. //$(".zip_download_alert").bind("mouseover",function(){
  1270. // $(this).next("div").show();
  1271. //});
  1272. //$(".zip_download_alert").bind("mouseout",function(){
  1273. // $(this).next("div").hide();
  1274. //});
  1275. });
  1276. //匿评弹框取消按钮
  1277. function clickCanel(){hideModal("#popbox02");}
  1278. //匿评弹框确定按钮
  1279. function clickOK(path)
  1280. {
  1281. clickCanel();
  1282. $.ajax({
  1283. type: "GET",
  1284. url: path,
  1285. data: 'text',
  1286. success: function (data) {
  1287. }
  1288. });
  1289. }
  1290. //关闭引入资源弹框
  1291. function hideResource(){
  1292. $('#ajax-modal').parent().removeClass("popbox").removeClass("referenceResourcesPopup");
  1293. hideModal();
  1294. }
  1295. //查询
  1296. function SearchByName(url,event)
  1297. {
  1298. var keycode = (event.keyCode ? event.keyCode : event.which);
  1299. if(keycode == '13'){
  1300. $.get(
  1301. url,
  1302. {
  1303. name : $("#course_student_name").val(),
  1304. group : $("#student_work_in_group").val()
  1305. },
  1306. function (data) {
  1307. }
  1308. );
  1309. }
  1310. }
  1311. function SearchByName_1(url)
  1312. {
  1313. //alert($("#student_work_in_group").val());
  1314. $.get(
  1315. url,
  1316. {
  1317. name : $("#course_student_name").val(),
  1318. group : $("#student_work_in_group").val()
  1319. },
  1320. function (data) {
  1321. }
  1322. );
  1323. }
  1324. $(function(){
  1325. $("#student_work_in_group").live("change",function(){
  1326. $("#search_in_student_work").click();
  1327. });
  1328. });
  1329. //新建作业临时弹框
  1330. function new_homework_alert(){
  1331. alert("您好!课程内直接发布作业的功能正在改进中,请直接点击\n顶部导航栏的“作业”向本课程发送作业。谢谢!如有问\n题,可参见帮助中心。");
  1332. }
  1333. function show_student_work(url){
  1334. $.get(
  1335. url,
  1336. {
  1337. },
  1338. function (data) {
  1339. }
  1340. );
  1341. }
  1342. /////////////////////////////////////////////////////////////////////////////////////////
  1343. var autoTextarea2 = function (elem,elem2, extra, maxHeight) {
  1344. extra = extra || 0;
  1345. var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
  1346. isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
  1347. addEvent = function (element, type, callback) {
  1348. element.addEventListener ?
  1349. element.addEventListener(type, callback, false) :
  1350. element.attachEvent('on' + type, callback);
  1351. },
  1352. getFirstStyle = elem.currentStyle ? function (name) {
  1353. var val = elem.currentStyle[name];
  1354. if (name === 'height' && val.search(/px/i) !== 1) {
  1355. var rect = elem.getBoundingClientRect();
  1356. return rect.bottom - rect.top -
  1357. parseFloat(getFirstStyle('paddingTop')) -
  1358. parseFloat(getFirstStyle('paddingBottom')) + 'px';
  1359. };
  1360. return val;
  1361. } : function (name) {
  1362. return getComputedStyle(elem, null)[name];
  1363. },
  1364. minHeight = parseFloat(getFirstStyle('height'));
  1365. elem.style.resize = 'none';
  1366. elem2.style.resize = 'none';
  1367. var change = function () {
  1368. var scrollTop, height,
  1369. padding = 0,
  1370. style = elem.style,
  1371. style2 = elem2.style;
  1372. if (elem._length === elem.value.length) return;
  1373. elem._length = elem.value.length;
  1374. elem2._length = elem._length;
  1375. if (!isFirefox && !isOpera) {
  1376. padding = parseInt(getFirstStyle('paddingTop')) + parseInt(getFirstStyle('paddingBottom'));
  1377. };
  1378. scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
  1379. elem.style.height = minHeight + 'px';
  1380. elem2.style.height = minHeight + 'px';
  1381. if (elem.scrollHeight > minHeight) {
  1382. if (maxHeight && elem.scrollHeight > maxHeight) {
  1383. height = maxHeight - padding;
  1384. style.overflowY = 'auto';
  1385. style2.overflowY = 'auto';
  1386. } else {
  1387. height = elem.scrollHeight - padding;
  1388. };
  1389. style.height = height + extra + 'px';
  1390. style2.height = height + extra + 'px';
  1391. scrollTop += parseInt(style.height) - elem.currHeight;
  1392. document.body.scrollTop = scrollTop;
  1393. document.documentElement.scrollTop = scrollTop;
  1394. elem.currHeight = parseInt(style.height);
  1395. };
  1396. if (elem2.scrollHeight > minHeight) {
  1397. if (maxHeight && elem2.scrollHeight > maxHeight) {
  1398. height = maxHeight - padding;
  1399. style.overflowY = 'auto';
  1400. style2.overflowY = 'auto';
  1401. } else {
  1402. height = elem2.scrollHeight - padding;
  1403. };
  1404. style.height = height + extra + 'px';
  1405. style2.height = height + extra + 'px';
  1406. scrollTop += parseInt(style2.height) - elem2.currHeight;
  1407. document.body.scrollTop = scrollTop;
  1408. document.documentElement.scrollTop = scrollTop;
  1409. elem2.currHeight = parseInt(style2.height);
  1410. };
  1411. };
  1412. addEvent(elem, 'propertychange', change);
  1413. addEvent(elem, 'input', change);
  1414. addEvent(elem, 'focus', change);
  1415. addEvent(elem2, 'propertychange', change);
  1416. addEvent(elem2, 'input', change);
  1417. addEvent(elem2, 'focus', change);
  1418. change();
  1419. };
  1420. //课程大纲选择请求,第二个参数是可选的,判断当前页面是大纲显示页面还是 课程首页
  1421. function course_outline(id){
  1422. $.get(
  1423. ' /courses/'+id+'/course_outline'+"?is_in_show_outline_page="+(arguments[1] ? arguments[1] : 'N')
  1424. )
  1425. }
  1426. //取消课程组织关联
  1427. function cancel_org_course_relation(id, courseId){
  1428. if(confirm("确定取消关联吗?") == false) return;
  1429. $.ajax({
  1430. url:"/org_courses/" + id + "?course_id=" + courseId,
  1431. type: "delete",
  1432. success:function(data){
  1433. $.ajax({
  1434. url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true",
  1435. type:'get'
  1436. });
  1437. }
  1438. });
  1439. }
  1440. //$(function(){
  1441. // $('#course_outline_search').on('input',function(){
  1442. // alert('<%= @course.id%>')
  1443. // })
  1444. //})
  1445. //项目点击展开
  1446. function expand_tools_expand(content) {
  1447. if (content == "invit") {
  1448. $("#expand_tools_expand_invit").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
  1449. $("#expand_tools_expand_invit").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
  1450. $("#expand_tools_expand_invit").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
  1451. }
  1452. else {
  1453. // $("#expand_tools_expand").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
  1454. // $("#expand_tools_expand").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
  1455. // $("#expand_tools_expand").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
  1456. $("#navContent").toggle(500);
  1457. }
  1458. // 修改数字控制速度, slideUp(500)控制卷起速度
  1459. }
  1460. //通过cookie存储伸开形式
  1461. $(function(){
  1462. var personalized_expand_key = "personalized_expand";
  1463. function personalized_init(){
  1464. var personalized_map = cookieget(personalized_expand_key);
  1465. if(personalized_map!=false){
  1466. personalized_map = JSON.parse(personalized_map);
  1467. $("*[nhtype='toggle4cookiecourse']").each(function(){
  1468. var personalized_id=$(this).data('id');
  1469. var val = personalized_map[personalized_id];
  1470. if(val!=undefined && val!=$(this).data('val')){
  1471. personalized_click($(this),0);
  1472. }
  1473. });
  1474. }
  1475. }
  1476. function personalized_click(obj,timeout){
  1477. var target = $(obj.data('target'));
  1478. var oldval = obj.data('val');
  1479. var val='';
  1480. if(oldval=='expand'){val='retract';}else{val='expand';}
  1481. obj.data('val',val);
  1482. var personalized_map = cookieget(personalized_expand_key);
  1483. if(personalized_map == false){
  1484. personalized_map={};
  1485. }else{
  1486. personalized_map = JSON.parse(personalized_map);
  1487. }
  1488. var personalized_id=obj.data('id');
  1489. personalized_map[personalized_id]=val;
  1490. cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
  1491. target.toggle(timeout);
  1492. }
  1493. $("*[nhtype='toggle4cookiecourse']").on('click',function(){
  1494. personalized_click($(this),500);
  1495. });
  1496. personalized_init();
  1497. });
  1498. function submit_course_feedback() {
  1499. var flag = false;
  1500. if(flag == false){
  1501. $("#course_feedback_new").submit();
  1502. var flag = true
  1503. }
  1504. }
  1505. function show_more_tool(){
  1506. $('#navContentCourse').css('display', 'block');
  1507. }

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...