exercise.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  5. if(ret.code==1){
  6. Backend.api.addtabs( ret.url,'正在练习');
  7. }
  8. });
  9. },
  10. examing: function () {
  11. $(document).ready(function() {
  12. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  13. var display = $('#timer');
  14. var timer = setInterval(function() {
  15. var minutes = parseInt(countdownTime / 60, 10);
  16. var seconds = parseInt(countdownTime % 60, 10);
  17. minutes = minutes < 10 ? "0" + minutes : minutes;
  18. seconds = seconds < 10 ? "0" + seconds : seconds;
  19. display.text(minutes + "分" + seconds+'秒');
  20. if (--countdownTime < 0) {
  21. clearInterval(timer);
  22. display.text("时间到!");
  23. }
  24. }, 1000);
  25. });
  26. $(document).on('click', '.btn-replace', function () {
  27. console.log($(".other_replace").val());
  28. $.ajax({
  29. url: "student/collection/replace/ids/"+Config.ids,
  30. type: 'post',
  31. data: {
  32. other_replace: $(".other_replace").val(),
  33. other_report: $(".other_report").val(),
  34. },
  35. success: function (data) {
  36. if(data.code==1){
  37. window.location.reload();
  38. }
  39. if(data.code==0){
  40. Layer.alert(data.msg);
  41. }
  42. }
  43. });
  44. });
  45. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  46. //绑定动态下拉组件
  47. Form.events.selectpage(obj);
  48. });
  49. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  50. if(ret.code==1){
  51. Backend.api.addtabs( ret.url,'得分分析');
  52. }
  53. });
  54. },
  55. analysis: function () {
  56. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  57. if(ret.code==1){
  58. Backend.api.addtabs( ret.url);
  59. }
  60. });
  61. },
  62. edit: function () {
  63. Controller.api.bindevent();
  64. },
  65. api: {
  66. bindevent: function () {
  67. Form.api.bindevent($("form[role=form]"));
  68. }
  69. }
  70. };
  71. return Controller;
  72. });