예제 #1
0
    return;
}
//////////////////////////////////////////////////////////////////////////////////////////////
//
if ($isteacher or $isassist) {
    //
    if ($classid == 0) {
        $where_classid = '';
    } else {
        if ($classid == NON_CLASSID) {
            $where_classid = " AND classid=0";
        } else {
            $where_classid = " AND (classid={$classid} OR classid=0)";
        }
    }
    $name_pattern = autoattend_get_namepattern($course->id);
    $students = autoattend_get_attend_students($course->id, $classid, $context, $sort, $order);
    $rec = $DB->get_record_sql("SELECT MIN(sessdate) AS min, MAX(sessdate) AS max " . " FROM {$CFG->prefix}autoattend_sessions WHERE courseid={$course->id}" . $where_classid);
    $firstdate = $rec->min + $TIME_OFFSET;
    $lastdate = $rec->max + $TIME_OFFSET;
    if ($current == 0) {
        $current = time();
    }
    list(, , , $sday, $wday, $smonth, $syear) = array_values(getdate($firstdate));
    if ($wday == 0) {
        $wday = 7;
    }
    $startdate = mktime(0, 0, 0, $smonth, $sday - $wday + 1, $syear);
    //
    $options['all'] = get_string('alltaken', 'block_autoattend');
    $options['weeks'] = get_string('everyweeks', 'block_autoattend');
예제 #2
0
function autoattend_make_download_data($courseid, $classes = null, $classid = 0, $viewmode = 'all', $starttm = 0, $attsid = 'all', $students = null, $sort = '', $order = '')
{
    global $CFG, $DB, $TIME_OFFSET;
    $settings = autoattend_get_grade_settings($courseid);
    //
    $indclass = '';
    $indsess = '';
    $indperiod = '';
    if ($classid != 0) {
        $indclass = ' AND (classid=' . $classid . ' OR classid=0)';
    }
    if ($viewmode != 'all') {
        if ($starttm == 0) {
            $starttm = time();
        }
        if ($viewmode === 'weeks') {
            $indperiod = " AND sessdate >= {$starttm} AND sessdate < " . ($starttm + ONE_WEEK_TIME);
        } elseif ($viewmode === 'months') {
            $nxtmon = mktime(0, 0, 0, date('m', $starttm + $TIME_OFFSET) + 1, 1, date('Y', $starttm + $TIME_OFFSET)) - $TIME_OFFSET;
            $indperiod = " AND sessdate >= {$starttm} AND sessdate < " . $nxtmon;
        }
    }
    if ($attsid != 'all' and $attsid != 0) {
        $indsess = ' AND id=' . $attsid;
        $viewmode = 'session';
    }
    // Only Closed Session
    $qry = "SELECT * FROM {$CFG->prefix}autoattend_sessions where courseid=" . $courseid . $indsess . $indclass . $indperiod . " AND state='C' ORDER BY sessdate, starttime ASC";
    $name_pattern = autoattend_get_namepattern($courseid);
    //
    $datas = new stdClass();
    $datas->attr = array();
    // 属性 'string', 'number'. デフォルトは 'string'
    $datas->data = array();
    $j = 0;
    $k = 0;
    $datas->attr[0] = array();
    $datas->data[0] = array();
    if ($CFG->fullnamedisplay == 'lastname firstname') {
        if ($name_pattern == 'fullname' or $name_pattern == 'lastname') {
            $datas->attr[0][$k++] = '';
            $datas->data[0][$j++] = get_string('lastname');
        }
        if ($name_pattern == 'fullname' or $name_pattern == 'firstname') {
            $datas->attr[0][$k++] = '';
            $datas->data[0][$j++] = get_string('firstname');
        }
        if ($sort == '') {
            $sort = 'lastname';
        }
    } else {
        if ($name_pattern == 'fullname' or $name_pattern == 'firstname') {
            $datas->attr[0][$k++] = '';
            $datas->data[0][$j++] = get_string('firstname');
        }
        if ($name_pattern == 'fullname' or $name_pattern == 'lastname') {
            $datas->attr[0][$k++] = '';
            $datas->data[0][$j++] = get_string('lastname');
        }
        if ($sort == '') {
            $sort = 'firstname';
        }
    }
    //
    if ($CFG->output_idnumber) {
        $datas->attr[0][$k++] = '';
        $datas->data[0][$j++] = 'ID';
    }
    if ($classes) {
        $datas->attr[0][$k++] = '';
        $datas->data[0][$j++] = get_string('classname', 'block_autoattend');
    }
    if ($viewmode == 'session') {
        $courseses = array();
        if ($sess = $DB->get_records_sql($qry)) {
            foreach ($sess as $id => $dsess) {
                $date = strftime(get_string('strftimedmshort', 'block_autoattend'), $dsess->sessdate + $TIME_OFFSET);
                $datas->attr[0][$k++] = '';
                $datas->data[0][$j++] = $date;
                $courseses[] = $dsess->id;
            }
        }
    }
    //
    $datas->attr[0][$k++] = '';
    $datas->attr[0][$k++] = '';
    $datas->attr[0][$k++] = '';
    $datas->attr[0][$k++] = '';
    $datas->attr[0][$k++] = '';
    $datas->attr[0][$k++] = '';
    $datas->attr[0][$k++] = '';
    //
    $datas->data[0][$j++] = get_string('Cstatefull', 'block_autoattend');
    $datas->data[0][$j++] = $settings['P']->title;
    $datas->data[0][$j++] = $settings['X']->title;
    $datas->data[0][$j++] = $settings['L']->title;
    $datas->data[0][$j++] = $settings['E']->title;
    $datas->data[0][$j++] = get_string('attendpercent', 'block_autoattend');
    $datas->data[0][$j++] = get_string('attendgrade', 'block_autoattend');
    if ($viewmode != 'session') {
        $courseses = array();
        if ($sess = $DB->get_records_sql($qry)) {
            foreach ($sess as $id => $dsess) {
                $date = strftime(get_string('strftimedmshort', 'block_autoattend'), $dsess->sessdate + $TIME_OFFSET);
                $datas->attr[0][$k++] = '';
                $datas->data[0][$j++] = $date;
                $courseses[] = $dsess->id;
            }
        }
    }
    //
    if (!$students) {
        $context = jbxl_get_course_context($courseid);
        $students = autoattend_get_attend_students($courseid, $classid, $context, $sort, $order);
    }
    $i = 1;
    foreach ($students as $student) {
        $j = 0;
        $k = 0;
        $summary = autoattend_get_user_summary($student->id, $courseid);
        $datas->data[$i] = array();
        $datas->attr[$i] = array();
        //
        if ($CFG->fullnamedisplay == 'lastname firstname') {
            if ($name_pattern == 'fullname' or $name_pattern == 'lastname') {
                $datas->attr[$i][$k++] = '';
                $datas->data[$i][$j++] = $student->lastname;
            }
            if ($name_pattern == 'fullname' or $name_pattern == 'firstname') {
                $datas->attr[$i][$k++] = '';
                $datas->data[$i][$j++] = $student->firstname;
            }
        } else {
            if ($name_pattern == 'fullname' or $name_pattern == 'firstname') {
                $datas->attr[$i][$k++] = '';
                $datas->data[$i][$j++] = $student->firstname;
            }
            if ($name_pattern == 'fullname' or $name_pattern == 'lastname') {
                $datas->attr[$i][$k++] = '';
                $datas->data[$i][$j++] = $student->lastname;
            }
        }
        if ($CFG->output_idnumber) {
            if (empty($student->idnumber)) {
                $idnumber = '-';
            } else {
                $idnumber = $student->idnumber;
            }
            $datas->attr[$i][$k++] = '';
            $datas->data[$i][$j++] = $idnumber;
        }
        if ($classes) {
            $datas->attr[$i][$k++] = '';
            $datas->data[$i][$j++] = $summary['classname'];
        }
        if ($viewmode == 'session') {
            foreach ($courseses as $sid) {
                if ($rec = $DB->get_record('autoattend_students', array('attsid' => $sid, 'studentid' => $student->id))) {
                    $datas->attr[$i][$k++] = '';
                    $datas->data[$i][$j++] = $settings[$rec->status]->acronym;
                } else {
                    $datas->attr[$i][$k++] = '';
                    $datas->data[$i][$j++] = '-';
                }
            }
        }
        //
        $datas->attr[$i][$k++] = 'number';
        $datas->attr[$i][$k++] = 'number';
        $datas->attr[$i][$k++] = 'number';
        $datas->attr[$i][$k++] = 'number';
        $datas->attr[$i][$k++] = 'number';
        $datas->attr[$i][$k++] = 'number';
        $datas->attr[$i][$k++] = 'number';
        //
        $datas->data[$i][$j++] = $summary['complete'];
        $datas->data[$i][$j++] = $summary['P'];
        $datas->data[$i][$j++] = $summary['X'];
        $datas->data[$i][$j++] = $summary['L'];
        $datas->data[$i][$j++] = $summary['E'];
        $datas->data[$i][$j++] = $summary['percent'];
        $datas->data[$i][$j++] = $summary['grade'];
        if ($viewmode != 'session') {
            foreach ($courseses as $sid) {
                if ($rec = $DB->get_record('autoattend_students', array('attsid' => $sid, 'studentid' => $student->id))) {
                    $datas->attr[$i][$k++] = '';
                    $datas->data[$i][$j++] = $settings[$rec->status]->acronym;
                } else {
                    $datas->attr[$i][$k++] = '';
                    $datas->data[$i][$j++] = '-';
                }
            }
        }
        $i++;
    }
    return $datas;
}