id)) {
error("Only teachers can look at this page");
}
/// Check to see if groups are being used in this course
if ($groupmode = groupmode($course)) { // Groups are being used
if (empty($currentgroup)) {
$currentgroup = setup_and_print_groups($course, $groupmode,
"marking.php?id=$id&muser=$muser");
} else {
setup_and_print_groups($course, $groupmode,
"marking.php?id=$id&muser=$muser");
}
} else {
$currentgroup = false;
}
/// Get all teachers and students
$teachers = get_course_teachers($course->id);
/// Show any specific group of users requested.
if ($currentgroup) {
$users = get_group_students($currentgroup);
} else {
$users = get_course_students($course->id);
}
if (!$users) {
print_heading(get_string("nostudentsyet"));
exit;
}
/// Load unsubmitted data into the $users structure:
foreach ($mod_uusers_array as $mod => $modfunc) {
$modfunc($mod);
}
echo '
';
if (isset($users[$muser]) && is_array($users[$muser]->unsubmitted)) {
echo "\n";
echo "\n";
print_user_picture($users[$muser]->id, $course->id, $users[$muser]->picture);
echo ' '.fullname($users[$muser], true);
echo " | ";
echo '';
foreach ($users[$muser]->unsubmitted as $assignment) {
echo ''.
$assignment->name.' ';
}
echo ' | ';
echo "
\n";
}
if (is_array($users)) {
$timenow = time();
foreach ($users as $userid => $user) {
if (($userid != $muser) && isset($user->unsubmitted) && is_array($user->unsubmitted)) {
echo "\n";
echo "\n";
print_user_picture($user->id, $course->id, $user->picture);
echo ' '.fullname($user, true);
echo " | ";
echo '';
foreach ($user->unsubmitted as $assignment) {
echo ''.
$assignment->name.'';
$lateby = sprintf('%.1f', (float)($timenow - $assignment->timedue) / (float)(60*60*24));
echo ' ('.get_string('lateby', 'block_marking', $lateby).')';
echo ' ';
}
echo ' | ';
echo "
\n";
}
}
}
echo "
\n";
function get_unsubmitted_assignment_data($assign_type='assignment') {
global $course, $users;
$timenow = time();
if (($assignments = get_all_instances_in_course($assign_type, $course)) !== false) {
foreach ($assignments as $assignment) {
if ($assignment->grade > 0) {
$ass_func = $assign_type.'_get_all_submissions';
if ($submissions = $ass_func($assignment)) {
foreach ($submissions as $submission) {
/// If this submission is by a user we are concerned about (group related...)
if (isset($users[$submission->userid])) {
if (($submission->timemodified <= 0) && ($assignment->timedue <= $timenow) &&
(empty($assignment->assignmenttype) || $assignment->assignmenttype != 'offline')) {
$assignment->modname = $assign_type;
$users[$submission->userid]->unsubmitted[] = $assignment;
}
}
}
}
}
}
} else {
return false;
}
}
function get_unsubmitted_forum_data() {
global $course, $users, $CFG;
require_once($CFG->dirroot.'/mod/forum/lib.php');
$timenow = time();
if (($forums = get_all_instances_in_course('forum', $course)) !== false) {
foreach ($forums as $forum) {
if ($submissions = forum_get_discussions($forum->id)) {
foreach ($submissions as $submission) {
/// If this submission is by a user we are concerned about (group related...)
if (isset($users[$submission->userid])) {
$submitted[$submission->userid] = true;
}
}
/// Calculate the unsubmitted posts.
foreach ($users as $userid => $user) {
if (!isset($submitted[$userid]) || ($submitted[$userid] !== true)) {
if (($forum->assesstimefinish != 0) && ($forum->assesstimefinish <= $timenow)) {
$forum->modname = 'forum';
$users[$userid]->unsubmitted[] = $forum;
}
}
}
}
}
} else {
return false;
}
}
function get_unsubmitted_journal_data() {
global $course, $users;
$timenow = time();
if (($journals = get_all_instances_in_course('journal', $course)) !== false) {
foreach ($journals as $journal) {
if ($submissions = get_records('journal_entries', 'journal', $journal->id)) {
foreach ($submissions as $submission) {
/// If this submission is by a user we are concerned about (group related...)
if (isset($users[$submission->userid])) {
$submitted[$submission->userid] = true;
}
}
/// Calculate the unsubmitted posts.
foreach ($users as $userid => $user) {
if ($submitted[$userid] !== true) {
if (($journal->days != 0) && ($course->startdate+($journal->days*(24*60*60)) <= $timenow)) {
$forum->modname = 'journal';
$users[$userid]->unsubmitted[] = $journal;
}
}
}
}
}
} else {
return false;
}
}
function get_unsubmitted_lesson_data() {
global $course, $users, $CFG;
require_once($CFG->dirroot.'/mod/lesson/locallib.php');
$timenow = time();
if (($lessons = get_all_instances_in_course('lesson', $course)) !== false) {
foreach ($lessons as $lesson) {
// get lesson pages that are essay
if ($pages = get_records_select("lesson_pages", "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) {
$submissionbyuser = array();
$submissionbypage = array();
$pageids = implode(",", array_keys($pages)); // all the pageids in comma seperated list
$userids = implode(',', array_keys($users));
$select = 'lessonid = '.$lesson->id.' AND pageid IN ('.$pageids.') AND '.'userid IN ('.$userids.')';
if ($submissions = get_records_select("lesson_attempts", $select)) {
foreach ($submissions as $submission) {
/// If this submission is by a user we are concerned about (group related...)
if (isset($users[$submission->userid])) {
$submitted[$submission->userid] = true;
}
}
/// Calculate the unsubmitted posts.
foreach ($users as $userid => $user) {
if ((empty($submitted[$userid]) || ($submitted[$userid] !== true)) &&
($lesson->deadline > 0) && ($lesson->deadline <= $timenow)) {
$lesson->timedue = $lesson->deadline;
$users[$userid]->unsubmitted[] = $lesson;
}
}
}
}
}
} else {
return false;
}
}
?>