@@ -7,10 +7,27 @@ class Lms extends BaseController
77 public function index ()
88 {
99 $ moduleModel = new \App \Models \LmsModuleModel ();
10+ $ masjidModel = new \App \Models \MasjidModel ();
1011
12+ $ modules = $ moduleModel ->where ('status ' , 'published ' )->orderBy ('created_at ' , 'DESC ' )->findAll ();
13+
14+ $ masjids = $ masjidModel ->findAll ();
15+ $ masjidMap = [];
16+ foreach ($ masjids as $ m ) {
17+ $ masjidMap [$ m ['id ' ]] = $ m ['name ' ];
18+ }
19+
20+ foreach ($ modules as &$ mod ) {
21+ if (is_numeric ($ mod ['lembaga_pemateri ' ]) && isset ($ masjidMap [$ mod ['lembaga_pemateri ' ]])) {
22+ $ mod ['lembaga_nama ' ] = $ masjidMap [$ mod ['lembaga_pemateri ' ]];
23+ } else {
24+ $ mod ['lembaga_nama ' ] = $ mod ['lembaga_pemateri ' ];
25+ }
26+ }
27+
1128 $ data = [
1229 'title ' => 'E-Learning (LMS) - Masj.id ' ,
13- 'modules ' => $ moduleModel -> where ( ' status ' , ' published ' )-> orderBy ( ' created_at ' , ' DESC ' )-> findAll () ,
30+ 'modules ' => $ modules ,
1431 ];
1532
1633 return view ('dashboard/lms/index ' , $ data );
@@ -27,6 +44,14 @@ public function module($slug)
2744 $ module = $ moduleModel ->where ('slug ' , $ slug )->first ();
2845 if (!$ module ) return redirect ()->to ('dashboard/lms ' )->with ('error ' , 'Modul tidak ditemukan. ' );
2946
47+ $ masjidModel = new \App \Models \MasjidModel ();
48+ if (is_numeric ($ module ['lembaga_pemateri ' ])) {
49+ $ masjid = $ masjidModel ->find ($ module ['lembaga_pemateri ' ]);
50+ $ module ['lembaga_nama ' ] = $ masjid ? $ masjid ['name ' ] : $ module ['lembaga_pemateri ' ];
51+ } else {
52+ $ module ['lembaga_nama ' ] = $ module ['lembaga_pemateri ' ];
53+ }
54+
3055 $ materials = $ materialModel ->where ('module_id ' , $ module ['id ' ])->orderBy ('order_number ' , 'ASC ' )->findAll ();
3156
3257 // Calculate progress
@@ -67,6 +92,13 @@ public function material($id)
6792
6893 $ module = $ moduleModel ->find ($ material ['module_id ' ]);
6994
95+ $ masjidModel = new \App \Models \MasjidModel ();
96+ if (is_numeric ($ module ['lembaga_pemateri ' ])) {
97+ $ masjid = $ masjidModel ->find ($ module ['lembaga_pemateri ' ]);
98+ $ module ['lembaga_nama ' ] = $ masjid ? $ masjid ['name ' ] : $ module ['lembaga_pemateri ' ];
99+ } else {
100+ $ module ['lembaga_nama ' ] = $ module ['lembaga_pemateri ' ];
101+ }
70102 // Check if completed
71103 $ isCompleted = $ progressModel ->where (['user_id ' => $ userId , 'material_id ' => $ id ])->first () ? true : false ;
72104
0 commit comments