Exemplo n.º 1
0
function autoattend_print_user($user, $course, $printing = null)
{
    global $DB, $CFG, $USER, $OUTPUT, $TIME_OFFSET;
    $wwwBlock = $CFG->wwwroot . '/blocks/autoattend';
    $wwwGrade = $CFG->wwwroot . '/grade/report/user';
    $wwwReport = $CFG->wwwroot . '/report/log';
    $wwwMesg = $CFG->wwwroot . '/message';
    $wwwUser = $CFG->wwwroot . '/user';
    if (!is_object($course)) {
        $course = $DB->get_record('course', array('id' => $course));
    }
    $courseid = $course->id;
    $userid = $user->id;
    $context = jbxl_get_course_context($courseid);
    $isteacher = jbxl_is_teacher($USER->id, $context);
    $summary = autoattend_get_user_summary($user->id, $courseid);
    if (!$summary) {
        notice(get_string('attendnotstarted', 'block_autoattend'), $CFG->wwwroot . '/course/view.php?id=' . $courseid);
    } else {
        $complete = $summary['complete'];
        $percent = $summary['percent'] . ' %';
        $grade = $summary['grade'];
        $maxgrade = $summary['maxgrade'];
        $settings = $summary['settings'];
        $classid = $summary['classid'];
        $classname = $summary['classname'];
        //
        if ($CFG->output_idnumber) {
            if (empty($user->idnumber)) {
                $user_idnum = ' - ';
            } else {
                $user_idnum = $user->idnumber;
            }
            $disp_idnum = '[' . $user_idnum . ']';
        } else {
            $user_idnum = '';
            $disp_idnum = '';
        }
        //
        $name_pattern = autoattend_get_namepattern($courseid);
        $username = jbxl_get_user_name($user->id, $name_pattern);
        include 'html/print_user_header.html';
        //
        if ($classid >= 0) {
            // !出欠から除外
            //
            $table = new html_table();
            // Header
            $table->head[] = '#';
            $table->align[] = 'right';
            $table->size[] = '20px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('date');
            $table->align[] = 'center';
            $table->size[] = '40px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('starttime', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '60px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('endtime', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '60px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('classname', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '40px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('description', 'block_autoattend');
            $table->align[] = 'left';
            $table->size[] = '40px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('status', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '40px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('callmethod', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '60px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('calledtime', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '60px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('ip', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '80px';
            $table->wrap[] = 'nowrap';
            $table->head[] = get_string('remarks', 'block_autoattend');
            $table->align[] = 'center';
            $table->size[] = '120px';
            $table->wrap[] = 'nowrap';
            $i = 0;
            foreach ($summary['attitems'] as $att) {
                if ($att->classid == $classid or $att->classid == 0) {
                    $table->data[$i][] = $i + 1;
                    $table->data[$i][] = strftime(get_string('strftimedmyw', 'block_autoattend'), $att->sessdate + $TIME_OFFSET);
                    $table->data[$i][] = strftime(get_string('strftimehourmin', 'block_autoattend'), $att->starttime + $TIME_OFFSET);
                    $table->data[$i][] = strftime(get_string('strftimehourmin', 'block_autoattend'), $att->endtime + $TIME_OFFSET);
                    $table->data[$i][] = autoattend_get_user_classname($att->classid);
                    $table->data[$i][] = $att->description ? $att->description : get_string('nodescription', 'block_autoattend');
                    if ($att->studentid) {
                        if ($att->status == 'Y') {
                            if (time() > $att->endtime) {
                                $table->data[$i][] = $settings['X']->acronym;
                            } else {
                                $table->data[$i][] = get_string('novalue', 'block_autoattend');
                            }
                        } else {
                            $table->data[$i][] = $settings[$att->status]->acronym;
                        }
                        $table->data[$i][] = get_string($att->called . 'methodfull', 'block_autoattend');
                    } else {
                        $table->data[$i][] = get_string('novalue', 'block_autoattend');
                        $table->data[$i][] = get_string('novalue', 'block_autoattend');
                    }
                    //
                    if (!$att->studentid or $att->status === 'X' or $att->status === 'Y') {
                        $table->data[$i][] = get_string('novalue', 'block_autoattend');
                    } else {
                        $sessndate = strftime(get_string('strftimedmshort', 'block_autoattend'), $att->sessdate + $TIME_OFFSET);
                        $calleddate = strftime(get_string('strftimedmshort', 'block_autoattend'), $att->calledtime + $TIME_OFFSET);
                        $calledtime = strftime(get_string('strftimehmshort', 'block_autoattend'), $att->calledtime + $TIME_OFFSET);
                        //$table->data[$i][] = strftime(get_string('strftimecalled', 'block_autoattend'), $att->calledtime + $TIME_OFFSET);
                        if ($sessndate === $calleddate) {
                            //$table->data[$i][] = '<div align="left">'.$calledtime.'</div>';
                            $table->data[$i][] = $calledtime;
                        } else {
                            //$table->data[$i][] = '<div align="left">'.$calledtime.'&nbsp;('.$calleddate.')</div>';
                            $table->data[$i][] = $calledtime . '&nbsp;(' . $calleddate . ')';
                        }
                    }
                    //
                    $ipaddr = $att->ipaddress ? $att->ipaddress : get_string('novalue', 'block_autoattend');
                    if ($ipaddr) {
                        //$ipurl  = jbxl_get_ipresolv_url($ipaddr);
                        $ipurl = autoattend_get_ipresolv_url($ipaddr);
                        if ($ipurl) {
                            $table->data[$i][] = "<a href={$ipurl} target=_blank>{$ipaddr}</a>";
                        } else {
                            $table->data[$i][] = $ipaddr;
                        }
                    } else {
                        $table->data[$i][] = get_string('novalue', 'block_autoattend');
                    }
                    $table->data[$i][] = $att->remarks;
                    $i++;
                }
            }
            echo '<div align="left">';
            echo html_writer::table($table);
            echo '</div>';
        }
        //
        echo '</td>';
        echo '</tr>';
        echo '</table>';
        echo '</div>';
    }
    return;
}
Exemplo n.º 2
0
function updateUser_show_table($attitems, $settings, $classid)
{
    global $TIME_OFFSET;
    $table = new html_table();
    $i = 0;
    foreach ($attitems as $att) {
        if ($att->classid == $classid or $att->classid == 0) {
            $i++;
            $table->data[$att->id][] = $i;
            $table->data[$att->id][] = strftime(get_string('strftimedmyw', 'block_autoattend'), $att->sessdate + $TIME_OFFSET);
            $table->data[$att->id][] = strftime(get_string('strftimehourmin', 'block_autoattend'), $att->starttime + $TIME_OFFSET);
            $table->data[$att->id][] = strftime(get_string('strftimehourmin', 'block_autoattend'), $att->endtime + $TIME_OFFSET);
            $table->data[$att->id][] = autoattend_get_user_classname($att->classid);
            $table->data[$att->id][] = $att->description ? $att->description : get_string('nodescription', 'block_autoattend');
            foreach ($settings as $set) {
                $checked = $set->status == $att->status ? 'checked' : '';
                $table->data[$att->id][] = '<input name="statusid' . $att->id . '" type="radio" value="' . $set->status . '" ' . $checked . ' />';
            }
            if ($att->studentid) {
                $table->data[$att->id][] = get_string($att->called . 'methodfull', 'block_autoattend');
                $table->data[$att->id][] = $att->ipaddress ? $att->ipaddress : get_string('novalue', 'block_autoattend');
            } else {
                $table->data[$att->id][] = ' - ';
                $table->data[$att->id][] = ' - ';
            }
            $input = '<input type="text"   name="remarks' . $att->id . '" size="20" maxlength="40" value="' . $att->remarks . '" />';
            $prvvl1 = '<input type="hidden" name="prvstatusid' . $att->id . '" value="' . $att->status . '" />';
            $prvvl2 = '<input type="hidden" name="prvremarks' . $att->id . '" value="' . $att->remarks . '" />';
            $table->data[$att->id][] = $input . $prvvl1 . $prvvl2;
            if ($i % PAGE_ROW_SIZE == 0) {
                updateUser_make_header($table, $settings, $i - PAGE_ROW_SIZE, $i);
                echo html_writer::table($table);
                unset($table->data);
            }
        }
    }
    if ($i % PAGE_ROW_SIZE != 0 or $i == 0) {
        updateUser_make_header($table, $settings, $i - $i % PAGE_ROW_SIZE, $i);
        echo html_writer::table($table);
    }
    return;
}