<h2>Thông tin thống kê bài giảng</h2>
<div class="content">
  <div class="span-4"><label>Tổng số lượt học:</label></div>
  <b><?php echo $totalHit ?></b> lượt học<br>
  <div class="span-4"><label>Số lượt trung bình:</label></div>
  <b><?php echo round($totalHit/count($tblcustom), 1) ?></b> lượt / người học<br>
  <div class="span-4"><label>Tổng gian học:</label></div>
  <b><?php echo (gmdate('H', $totalTime)>0? gmdate('H', $totalTime).'</b> giờ <b>': ''). gmdate('i', $totalTime) ?></b> phút<br>
  <div class="span-4"><label>Thời gian trung bình:</label></div>
  <b><?php echo round($totalTime/$totalHit/60, 1) ?></b> phút / lượt học<br>

  <h4>Danh sách người học: (<?php echo count($learners) ?> người)</h4>
  <table class="table-content" style="width:100%">
    <tr>
      <th colspan="2">Tên người học</th>
      <th style="width:25%; text-align:center">Thời gian học<br>(phút)</th>
      <th style="width:25%; text-align:center">Điểm số<br>(/10)</th>
    </tr>
    <?php $index = 0 ?>
    <?php foreach ($learners as $key => $learner): ?>
      <tr id="line.user<?php echo $key?>" class="row<?php echo (++$index)%2 ?>" onclick="showScormDetail(<?php echo $index.', \'user'.$key.'\', '.count($learner['detail']) ?>);" style="cursor:pointer">
        <td colspan="2"><?php echo $learner['name'] ?></td>
        <td style="text-align:center"><?php echo round($learner['time']/60, 1) ?></td>
        <td style="text-align:center"><?php echo round($learner['score']*20)/2 ?></td>
      </tr>
      <?php $subIndex = 0 ?>
      <?php foreach ($learner['detail'] as $cpnode => $detail): ?>
        <?php $subIndex++ ?>
        <tr class="row<?php echo ($index)%2 ?>" id="detail.user<?php echo $key.'.'.$subIndex ?>" style="display:none">
          <td></td>
          <td><?php echo $detail[0] ?></td>
          <td style="text-align:center"><?php echo round($detail[1]/60, 1) ?></td>
          <td style="text-align:center"><?php echo round($detail[2]*20)/2 ?></td>
        </tr>
      <?php endforeach ?>
    <?php endforeach ?>
  </table>

  <br>
  <h4>Chi tiết bài giảng: (<?php echo count($nodes) ?> nội dung)</h4>
  <table class="table-content" style="width:100%">
    <tr>
      <th colspan="2">Tên mục</th>
      <th style="width:20%; text-align:center">Số người học</th>
      <th style="width:20%; text-align:center">Thời gian học<br>(phút)</th>
      <th style="width:20%; text-align:center">Điểm trung bình<br>(/10)</th>
    </tr>
    <?php $index = 0 ?>
    <?php foreach ($nodes as $key => $node): ?>
      <tr id="line.node<?php echo $key?>" class="row<?php echo (++$index)%2 ?>" onclick="showScormDetail(<?php echo $index.', \'node'.$key.'\', '.count($node['detail']) ?>);" style="cursor:pointer">
        <td colspan="2"><?php echo $node['name'] ?></td>
        <td style="text-align:center"><?php echo $node['hit'] ?></td>
        <td style="text-align:center"><?php echo round($node['time']/60, 1) ?></td>
        <td style="text-align:center"><?php echo round($node['score']/$node['scorehit']*20)/2 ?></td>
      </tr>
      <?php $subIndex = 0 ?>
      <?php foreach ($node['detail'] as $user => $detail): ?>
        <?php $subIndex++ ?>
        <tr class="row<?php echo ($index)%2 ?>" id="detail.node<?php echo $key.'.'.$subIndex ?>" style="display:none">
          <td></td>
          <td><?php echo $detail[0] ?></td>
          <td></td>
          <td style="text-align:center"><?php echo round($detail[1]/60, 1) ?></td>
          <td style="text-align:center"><?php echo round($detail[2]*20)/2 ?></td>
        </tr>
      <?php endforeach ?>
    <?php endforeach ?>
  </table>
</div>

<script>
showScormDetail = function(id, key, count) {
  var show = ($('detail.'+key+'.1').style.display=='')? 'none': '';
  $('line.'+key).className = (show == '')? 'selected': 'row'+id%2;

  for (var i = 1; i <= count; i++) {
    $('detail.'+key+'.'+i).style.display = show;
  }
}
</script>
