I am receiving the following error:
Notice (8): Undefined offset: 47 [APP/Template\\CoursesEnrolled\\view.ctp, line 75]
I have tried debugging the line but I'm stuck with what to do.
My view.ctp looks like this:
$modulesEnrolled = Cake\Utility\Hash::combine($coursesEnrolled->courses_enrolled_modules,
'{n}.course_module_id','{n}');
// debug($modulesEnrolled);
$allModulesCompleted = true;
if (!empty($coursesEnrolled->course->course_modules)): ?>
<div class="">
<table class="table table-bordered table-hover" id="toggletable">
<thead>
<tr>
<th><?= __('Title') ?></th>
<th><?= __('Type') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($coursesEnrolled->course->course_modules as $courseModules): ?>
<tr>
<td><?= h($courseModules->title) ?></td>
<td><?= h($courseModules->type) ?></td>
<td class="actions">
<?php
if($allModulesCompleted && $modulesEnrolled[$courseModules->id]['status'] == 'Pending') { //this is line 75
$allModulesCompleted = false;
}
Any help would be greatly appreciated.
My guess is, one of your arrays doesn't start at 0.
The $courseModules->id
doesn't match the any key in the $modulesEnrolled
array.
I would try either incrementing or decrementing by 1, maybe try the following:
$IDHere = (int)$courseModules->id - 1;
if($allModulesCompleted && $modulesEnrolled[$IDHere]['status'] == 'Pending') { //this is line 75
$allModulesCompleted = false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.