コード例 #1
0
 function get_content()
 {
     global $CFG, $USER, $DB;
     if ($this->content != NULL) {
         return $this->content;
     }
     $courseid = optional_param('course', 0, PARAM_INTEGER);
     $classid = optional_param('class', 0, PARAM_INTEGER);
     if ($courseid == 0) {
         $courseid = $this->page->course->id;
     }
     if ($courseid != 0) {
         $course = $DB->get_record('course', array('id' => $courseid));
         if (!$course) {
             print_error('courseidwrong', 'block_autoattend');
         }
     } else {
         return '';
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     $this->content->text = '';
     //
     $context = jbxl_get_course_context($course->id);
     $isstudent = false;
     $isassist = false;
     $isteacher = jbxl_is_teacher($USER->id, $context);
     if (!$isteacher) {
         $isassist = jbxl_is_assistant($USER->id, $context);
         if (!$isassist) {
             $isstudent = jbxl_is_student($USER->id, $context);
         }
     }
     if ($isteacher or $isassist) {
         // Teacher
         //
         $this->content->text = '<a href="' . $CFG->wwwroot . '/blocks/autoattend/index.php?course=' . $course->id . '&amp;class=' . $classid . '&amp;from=home">' . get_string('takemanualattend', 'block_autoattend') . '</a><br />';
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/class_division.php?course=' . $course->id . '&amp;class=' . $classid . '&amp;from=home">' . get_string('students_list', 'block_autoattend') . '</a><br />';
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/report.php?course=' . $course->id . '&amp;class=' . $classid . '&amp;from=home&amp;view=months&amp;refresh=1">' . get_string('report', 'block_autoattend') . '</a><br />';
         if ($isteacher) {
             //$this->content->text.= '<a href="'.$CFG->wwwroot.'/blocks/autoattend/class_division.php?course='.$course->id.'">'.
             //								get_string('class_division','block_autoattend').'</a><br />';
             //
             if ($this->version < 2014051100) {
                 $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/repairDB.php?course=' . $course->id . '">' . get_string('repairdb', 'block_autoattend') . '</a><br />';
             }
         }
     } elseif ($isstudent) {
         //
         $user_summary = autoattend_get_user_summary($USER->id, $course->id);
         if (!$user_summary) {
             //autoattend not generated yet
             $this->content->text .= get_string('attendnotstarted', 'block_autoattend');
         } else {
             //autoattend taken
             $classinfo = autoattend_get_user_class($USER->id, $course->id);
             $this->content->text .= get_string('classname', 'block_autoattend') . ': ' . $classinfo->name . '<br />';
             //
             if ($classinfo->classid >= 0) {
                 // !出欠から除外
                 $absence = 0;
                 $settings = autoattend_get_grade_settings($course->id);
                 foreach ($settings as $set) {
                     //if ($set->status=='X' or $set->status=='Y') {
                     if ($set->status == 'X') {
                         $absence += $user_summary[$set->status];
                     } else {
                         if ($set->status != 'Y') {
                             $this->content->text .= $settings[$set->status]->description . ': ' . $user_summary[$set->status] . '<br />';
                         }
                     }
                 }
                 $this->content->text .= $settings['X']->description . ': ' . $absence . '<br />';
                 $percent = $user_summary['percent'];
                 $grade = $user_summary['grade'];
                 $mxgrade = $user_summary['maxgrade'];
                 $this->content->text .= get_string('attendpercent', 'block_autoattend') . ': ' . $percent . ' %<br />';
                 $this->content->text .= get_string('attendgrade', 'block_autoattend') . ": {$grade} / {$mxgrade}<br />";
                 $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/index.php?course=' . $course->id . '&amp;class=' . $classid . '">';
                 $this->content->text .= get_string('indetail', 'block_autoattend') . '</a>';
             }
         }
     } else {
         $this->content->text = '';
         // Guest
     }
     $this->content->footer = '<hr />';
     if (autoattend_disp_feedback($course->id)) {
         if ($isteacher or $isassist) {
             $this->content->footer .= '<a href="https://el.mml.tuis.ac.jp/moodle/mod/feedback/view.php?id=528" target="_blank">';
         } elseif ($isstudent) {
             $this->content->footer .= '<a href="https://el.mml.tuis.ac.jp/moodle/mod/feedback/view.php?id=529" target="_blank">';
         }
         $this->content->footer .= get_string('feedback', 'block_autoattend') . '</a><br />';
     }
     $this->content->footer .= '<a href="' . get_string('wiki_url', 'block_autoattend') . '" target="_blank"><i>Autoattend ' . $this->release . '</i></a>';
     return $this->content;
 }
コード例 #2
0
ファイル: index.php プロジェクト: educakanchay/campus
}
$_SESSION['update'] = true;
$course = $DB->get_record('course', array('id' => $courseid));
if (!$course) {
    print_error('courseidwrong', 'block_autoattend');
}
require_login($course->id);
$user = $DB->get_record('user', array('id' => $USER->id));
if (!$user) {
    print_error('nosuchuser', 'block_autoattend');
}
//
$context = jbxl_get_course_context($course->id);
$isstudent = false;
$isassist = false;
$isteacher = jbxl_is_teacher($USER->id, $context);
if (!$isteacher) {
    $isassist = jbxl_is_assistant($USER->id, $context);
    if (!$isassist) {
        $isstudent = jbxl_is_student($USER->id, $context);
    }
}
// DownLoad (Excel or Text Format)
if ($isteacher or $isassist) {
    $classes = autoattend_get_session_classes($course->id);
    $datas = autoattend_make_download_data($course->id, $classes, $classid);
    if ($action == 'excel') {
        jbxl_download_data('xls', $datas);
        die;
    } else {
        if ($action == 'text') {
コード例 #3
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;
}