Example #1
0
}
if (isset($_SESSION['update'])) {
    $update = $_SESSION['update'];
}
$_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);
Example #2
0
function autoattend_close_session($courseid, $sess, $ntime = '')
{
    global $DB;
    if ($sess->state == 'C') {
        //
        $context = jbxl_get_course_context($courseid);
        $users = jbxl_get_course_students($context);
        //		$users = autoattend_get_users_bystatus($sess->id, 'Y');
        if ($users) {
            if (empty($ntime)) {
                $ntime = time();
            }
            //
            $rec = new stdClass();
            $rec->attsid = $sess->id;
            $rec->status = 'X';
            $rec->called = $sess->method;
            $rec->calledby = 0;
            $rec->calledtime = $ntime;
            $rec->remarks = '';
            $rec->ipaddress = '';
            foreach ($users as $user) {
                $rec->studentid = $user->id;
                //
                $student = $DB->get_record('autoattend_students', array('attsid' => $sess->id, 'studentid' => $user->id));
                if (empty($student)) {
                    $DB->insert_record('autoattend_students', $rec);
                } else {
                    if ($student->status == 'Y') {
                        $rec->id = $student->id;
                        $DB->update_record('autoattend_students', $rec);
                    }
                }
            }
            //
            unset($rec);
        }
    }
}
Example #3
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;
 }
 function jbxl_get_course_assistants($cntxt, $sort = '')
 {
     global $DB;
     if (!$cntxt) {
         return '';
     }
     $roles = $DB->get_records('role', array('archetype' => 'teacher'), 'id', 'id');
     if (empty($roles)) {
         return '';
     }
     $roleid = '';
     foreach ($roles as $role) {
         if (!empty($roleid)) {
             $roleid .= ' OR ';
         }
         $roleid .= 'r.roleid = ' . $role->id;
     }
     if ($sort) {
         $sort = ' ORDER BY u.' . $sort;
     }
     $sql = 'SELECT u.* FROM {role_assignments} r, {user} u ' . ' WHERE r.contextid = ? AND (' . $roleid . ') AND r.userid = u.id ' . $sort;
     //
     if (!is_object($cntxt)) {
         $cntxt = jbxl_get_course_context($cntxt);
     }
     $users = $DB->get_records_sql($sql, array($cntxt->id));
     return $users;
 }