コード例 #1
0
function updateAttendance_show_table($course, $students, $sessdata, $settings, $attsid, $attend, $classid, $name_pattern, $order, $isteacher)
{
    global $CFG, $DB, $OUTPUT, $wwwBlock, $TIME_OFFSET;
    $url_options = '?course=' . $course->id . '&class=' . $classid . '&attend=' . $attend . '&attsid=' . $attsid;
    $sessndate = strftime(get_string('strftimedmshort', 'block_autoattend'), $sessdata->sessdate + $TIME_OFFSET);
    $table = new html_table();
    $i = 0;
    foreach ($students as $student) {
        $classinfo = autoattend_get_user_class($student->id, $course->id, true);
        // ID Only
        if ($classinfo->classid == $classid or $classid == 0 or $classid == NON_CLASSID and $classinfo->classid == 0) {
            //
            $att = $DB->get_record('autoattend_students', array('attsid' => $attsid, 'studentid' => $student->id));
            if ($att) {
                $status = $att->status;
                $called = $att->called;
            } else {
                $status = 'Y';
                $called = 'D';
            }
            if ($attend == 'A' or $attend == 'Z' and ($status == 'X' or $status == 'Y') or $attend == $status) {
                $i++;
                $table->data[$student->id][] = $i;
                $pic_options = array('size' => 20, 'link' => true, 'alttext' => true, 'courseid' => $course->id, 'popup' => true);
                $username = jbxl_get_user_name($student->id, $name_pattern);
                $table->data[$student->id][] = $OUTPUT->user_picture($student->user, $pic_options);
                $table->data[$student->id][] = '<a href="' . $wwwBlock . '/index.php?course=' . $course->id . '&amp;student=' . $student->id . '" target="_blank">' . $username . '</a>';
                if ($CFG->output_idnumber) {
                    if (empty($student->idnumber)) {
                        $table->data[$student->id][] = '-';
                    } else {
                        $table->data[$student->id][] = $student->idnumber;
                    }
                }
                $table->data[$student->id][] = $student->classname;
                foreach ($settings as $set) {
                    $checked = $set->status == $status ? 'checked' : '';
                    $table->data[$student->id][] = '<input name="statusid' . $student->id . '" ' . 'type="radio"  value="' . $set->status . '" ' . $checked . ' />';
                }
                $table->data[$student->id][] = get_string($called . 'methodfull', 'block_autoattend');
                //
                if (!$att or $att->status === 'X' or $att->status === 'Y') {
                    $table->data[$student->id][] = get_string('novalue', 'block_autoattend');
                } else {
                    $calleddate = strftime(get_string('strftimedmshort', 'block_autoattend'), $att->calledtime + $TIME_OFFSET);
                    $calledtime = strftime(get_string('strftimehmshort', 'block_autoattend'), $att->calledtime + $TIME_OFFSET);
                    if ($sessndate === $calleddate) {
                        $table->data[$student->id][] = $calledtime;
                    } else {
                        $table->data[$student->id][] = $calledtime . '&nbsp;(' . $calleddate . ')';
                    }
                }
                //
                if ($att) {
                    $ipaddr = $att->ipaddress ? $att->ipaddress : get_string('novalue', 'block_autoattend');
                    $ipurl = autoattend_get_ipresolv_url($ipaddr);
                    if ($ipurl) {
                        $table->data[$student->id][] = "<a href={$ipurl} target=_blank>{$ipaddr}</a>";
                    } else {
                        $table->data[$student->id][] = $ipaddr;
                    }
                } else {
                    $table->data[$student->id][] = get_string('novalue', 'block_autoattend');
                }
                //
                $remarks = $att ? $att->remarks : '';
                $input = '<input type="text"   name="remarks' . $student->id . '" size="20" maxlength="40" value="' . $remarks . '" />';
                $prvvl1 = '<input type="hidden" name="prvstatusid' . $student->id . '" value="' . $status . '" />';
                $prvvl2 = '<input type="hidden" name="prvremarks' . $student->id . '" value="' . $remarks . '" />';
                $table->data[$student->id][] = $input . $prvvl1 . $prvvl2;
                //
                if ($i % PAGE_ROW_SIZE == 0) {
                    updateAttendance_make_header($table, $settings, $url_options, $i - PAGE_ROW_SIZE, $i, $name_pattern, $order);
                    echo '<div align="center" style="overflow-x: auto;">';
                    // スクロールしません
                    echo html_writer::table($table);
                    echo '<div align="center">';
                    updateAttendance_show_button($isteacher);
                    echo '</div>';
                    echo '</div><br />';
                    unset($table->data);
                }
            }
        }
    }
    //
    if ($i % PAGE_ROW_SIZE != 0 or $i == 0) {
        updateAttendance_make_header($table, $settings, $url_options, $i - $i % PAGE_ROW_SIZE, $i, $name_pattern, $order);
        echo '<div align="center" style="overflow-x: auto;">';
        echo html_writer::table($table);
        echo '<div align="center">';
        updateAttendance_show_button($isteacher);
        echo '</div>';
        echo '</div>';
    }
    return;
}
コード例 #2
0
ファイル: locallib.php プロジェクト: educakanchay/campus
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;
}