作者 何书鹏
1 个管道 的构建 通过 耗费 3 秒

后台查看用户考试进度

@@ -64,6 +64,17 @@ class ThirdStudy extends Backend @@ -64,6 +64,17 @@ class ThirdStudy extends Backend
64 ->select(); 64 ->select();
65 65
66 foreach ($list as $row) { 66 foreach ($list as $row) {
  67 + // 学习进度
  68 + $finish_hour = Db::name('study_class')
  69 + ->alias('a')
  70 + ->join('classes b','a.class_id = b.id')
  71 + ->where('a.third_id',$row['third_id'])
  72 + ->where('a.study_id',$row['study_id'])
  73 + ->where('a.status',2)
  74 + ->sum('b.class_hour');
  75 + $proportion = round($finish_hour/$row['study']['class_hour']*100,0);
  76 + $row->proportion = ($proportion > 100 ? 100 : $proportion).'%';
  77 + $row->append(['proportion']);
67 78
68 $row->getRelation('user')->visible(['username']); 79 $row->getRelation('user')->visible(['username']);
69 $row->getRelation('study')->visible(['examname']); 80 $row->getRelation('study')->visible(['examname']);
@@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
28 {field: 'user.username', title: __('Third.username')}, 28 {field: 'user.username', title: __('Third.username')},
29 {field: 'study.examname', title: __('Study.examname')}, 29 {field: 'study.examname', title: __('Study.examname')},
30 {field: 'periodtime', title: __('Periodtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 30 {field: 'periodtime', title: __('Periodtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  31 + {field: 'proportion', title: __('考试进度')},
31 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 32 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
32 ] 33 ]
33 ] 34 ]