Added new type of assignment - offline.
This type of assignment doesn't require anything of the student online, it just tells them about an assignment and the teacher can provide feedback and grades. Useful for offline activities, and also for the teacher to add manual columns to the grades page
This commit is contained in:
@@ -82,6 +82,9 @@ function assignment_upgrade($oldversion) {
|
||||
if ($oldversion < 2002101600) {
|
||||
execute_sql(" ALTER TABLE `assignment` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `description` ");
|
||||
}
|
||||
if ($oldversion < 2002110302) {
|
||||
execute_sql(" UPDATE `assignment` SET `type` = '1'");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+48
-26
@@ -2,6 +2,11 @@
|
||||
|
||||
include_once("$CFG->dirroot/files/mimetypes.php");
|
||||
|
||||
define("OFFLINE", "0");
|
||||
define("UPLOADSINGLE", "1");
|
||||
|
||||
$ASSIGNMENT_TYPE = array (OFFLINE => get_string("typeoffline", "assignment"),
|
||||
UPLOADSINGLE => get_string("typeuploadsingle", "assignment") );
|
||||
|
||||
|
||||
function assignment_add_instance($assignment) {
|
||||
@@ -267,14 +272,25 @@ function assignment_print_difference($time) {
|
||||
function assignment_print_submission($assignment, $user, $submission, $teachers, $grades) {
|
||||
global $THEME;
|
||||
|
||||
echo "\n<TABLE BORDER=1 CELLSPACING=0 valign=top cellpadding=10>";
|
||||
switch ($assignment->type) {
|
||||
case OFFLINE:
|
||||
break;
|
||||
case UPLOADSINGLE:
|
||||
break;
|
||||
}
|
||||
|
||||
echo "\n<TABLE BORDER=1 CELLSPACING=0 valign=top cellpadding=10 align=center>";
|
||||
|
||||
echo "\n<TR>";
|
||||
echo "\n<TD ROWSPAN=2 BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
|
||||
if ($assignment->type == OFFLINE) {
|
||||
echo "\n<TD BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
|
||||
} else {
|
||||
echo "\n<TD ROWSPAN=2 BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
|
||||
}
|
||||
print_user_picture($user->id, $assignment->course, $user->picture);
|
||||
echo "</TD>";
|
||||
echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$THEME->cellheading\">$user->firstname $user->lastname";
|
||||
if ($submission) {
|
||||
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\">$user->firstname $user->lastname";
|
||||
if ($submission->timemodified) {
|
||||
echo " <FONT SIZE=1>".get_string("lastmodified").": ";
|
||||
echo userdate($submission->timemodified);
|
||||
echo assignment_print_difference($assignment->timedue - $submission->timemodified);
|
||||
@@ -282,31 +298,37 @@ function assignment_print_submission($assignment, $user, $submission, $teachers,
|
||||
}
|
||||
echo "</TR>";
|
||||
|
||||
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
|
||||
if ($submission) {
|
||||
assignment_print_user_files($assignment, $user);
|
||||
} else {
|
||||
print_string("notsubmittedyet", "assignment");
|
||||
}
|
||||
echo "</TD></TR>";
|
||||
|
||||
if ($submission) {
|
||||
echo "\n<TR>";
|
||||
echo "<TD WIDTH=35 VALIGN=TOP>";
|
||||
if (!$submission->teacher) {
|
||||
$submission->teacher = $USER->id;
|
||||
if ($assignment->type != OFFLINE) {
|
||||
echo "\n<TR><TD BGCOLOR=\"$THEME->cellcontent\">";
|
||||
if ($submission->numfiles) {
|
||||
assignment_print_user_files($assignment, $user);
|
||||
} else {
|
||||
print_string("notsubmittedyet", "assignment");
|
||||
}
|
||||
print_user_picture($submission->teacher, $assignment->course, $teachers[$submission->teacher]->picture);
|
||||
echo "<TD BGCOLOR=\"$THEME->cellheading\">Teacher Feedback:";
|
||||
choose_from_menu($grades, "g$submission->id", $submission->grade, get_string("grade")."...");
|
||||
if ($submission->timemarked) {
|
||||
echo " <FONT SIZE=1>".userdate($submission->timemarked)."</FONT>";
|
||||
}
|
||||
echo "<BR><TEXTAREA NAME=\"c$submission->id\" ROWS=6 COLS=60 WRAP=virtual>";
|
||||
p($submission->comment);
|
||||
echo "</TEXTAREA><BR>";
|
||||
echo "</TD></TR>";
|
||||
}
|
||||
|
||||
echo "\n<TR>";
|
||||
echo "<TD WIDTH=35 VALIGN=TOP>";
|
||||
if (!$submission->teacher) {
|
||||
$submission->teacher = $USER->id;
|
||||
}
|
||||
print_user_picture($submission->teacher, $assignment->course, $teachers[$submission->teacher]->picture);
|
||||
if ($submission->timemodified > $submission->timemarked) {
|
||||
echo "<TD BGCOLOR=\"$THEME->cellheading2\">";
|
||||
} else {
|
||||
echo "<TD BGCOLOR=\"$THEME->cellheading\">";
|
||||
}
|
||||
echo "Teacher Feedback:";
|
||||
choose_from_menu($grades, "g$submission->id", $submission->grade, get_string("grade")."...");
|
||||
if ($submission->timemarked) {
|
||||
echo " <FONT SIZE=1>".userdate($submission->timemarked)."</FONT>";
|
||||
}
|
||||
echo "<BR><TEXTAREA NAME=\"c$submission->id\" ROWS=6 COLS=60 WRAP=virtual>";
|
||||
p($submission->comment);
|
||||
echo "</TEXTAREA><BR>";
|
||||
echo "</TD></TR>";
|
||||
|
||||
echo "</TABLE><BR CLEAR=ALL>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
} else {
|
||||
helpbutton("text", get_string("helptext"));
|
||||
}
|
||||
echo "<P>";
|
||||
echo "<P align=right>";
|
||||
print_string("formattexttype");
|
||||
echo ": ";
|
||||
if (!$form->format) {
|
||||
@@ -42,8 +42,12 @@
|
||||
<tr valign=top>
|
||||
<td align=right><P><B><? print_string("assignmenttype", "assignment") ?>:</B></P></TD>
|
||||
<td>
|
||||
<input type="hidden" name=type value="<? p($form->type) ?>">
|
||||
<? print_string("typeuploadsingle", "assignment") ?>
|
||||
<?PHP
|
||||
require("$CFG->dirroot/mod/assignment/lib.php");
|
||||
asort($ASSIGNMENT_TYPE);
|
||||
choose_from_menu($ASSIGNMENT_TYPE, "type", $form->type, "");
|
||||
helpbutton("assignmenttype", get_string("assignmenttype", "assignment"), "assignment");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
@@ -53,7 +57,7 @@
|
||||
for ($i=100; $i>=0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
choose_from_menu($grades, "grade", "$form->grade");
|
||||
choose_from_menu($grades, "grade", "$form->grade", "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -35,7 +35,16 @@
|
||||
<A HREF=\"view.php?a=$assignment->id\">$assignment->name</A> -> $strsubmissions",
|
||||
"", "", true);
|
||||
|
||||
// Some easy ways to reference submissions
|
||||
/// Get all teachers and students
|
||||
$teachers = get_course_teachers($course->id);
|
||||
|
||||
if (!$users = get_course_students($course->id)) {
|
||||
print_heading(get_string("nostudentsyet"));
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Make some easy ways to reference submissions
|
||||
if ($submissions = assignment_get_all_submissions($assignment)) {
|
||||
foreach ($submissions as $submission) {
|
||||
$submissionbyuser[$submission->user] = $submission;
|
||||
@@ -43,7 +52,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) { // Feedback submitted
|
||||
/// Get all existing submissions and check for missing ones
|
||||
foreach($users as $user) {
|
||||
if (!isset($submissionbyuser[$user->id])) { // Need to create empty entry
|
||||
$newsubmission->assignment = $assignment->id;
|
||||
$newsubmission->user = $user->id;
|
||||
$newsubmission->timecreated = time();
|
||||
if (!insert_record("assignment_submissions", $newsubmission)) {
|
||||
error("Could not insert a new empty submission");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($newsubmission)) { // Get them all out again to be sure
|
||||
if ($submissions = assignment_get_all_submissions($assignment)) {
|
||||
foreach ($submissions as $submission) {
|
||||
$submissionbyuser[$submission->user] = $submission;
|
||||
$submissionbyid[$submission->id] = $submission;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// If data is being submitted, then process it
|
||||
if (match_referer() && isset($HTTP_POST_VARS)) {
|
||||
|
||||
$feedback = array();
|
||||
|
||||
@@ -89,32 +121,18 @@
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
|
||||
$teachers = get_course_teachers($course->id);
|
||||
if (! $users = get_course_students($course->id)) {
|
||||
print_heading(get_string("nostudentsyet"));
|
||||
echo "<FORM ACTION=submissions.php METHOD=post>\n";
|
||||
|
||||
} else {
|
||||
echo "<FORM ACTION=submissions.php METHOD=post>\n";
|
||||
|
||||
if ($usersdone = assignment_get_users_done($assignment)) {
|
||||
foreach ($usersdone as $user) {
|
||||
$submission = $submissionbyuser[$user->id];
|
||||
assignment_print_submission($assignment, $user, $submission, $teachers, $grades);
|
||||
}
|
||||
}
|
||||
|
||||
$submission = NULL;
|
||||
foreach ($users as $user) {
|
||||
if (! $usersdone[$user->id]) {
|
||||
assignment_print_submission($assignment, $user, $submission, $teachers, $grades);
|
||||
}
|
||||
}
|
||||
echo "<CENTER>";
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$assignment->id\">";
|
||||
echo "<INPUT TYPE=submit VALUE=\"Save all my feedback\">";
|
||||
echo "</CENTER>";
|
||||
echo "</FORM>";
|
||||
foreach ($users as $user) {
|
||||
$submission = $submissionbyuser[$user->id];
|
||||
assignment_print_submission($assignment, $user, $submission, $teachers, $grades);
|
||||
}
|
||||
|
||||
echo "<CENTER>";
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$assignment->id\">";
|
||||
echo "<INPUT TYPE=submit VALUE=\"Save all my feedback\">";
|
||||
echo "</CENTER>";
|
||||
echo "</FORM>";
|
||||
|
||||
print_footer($course);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2002101606;
|
||||
$module->version = 2002110602;
|
||||
$module->cron = 60;
|
||||
|
||||
?>
|
||||
|
||||
+36
-25
@@ -47,13 +47,16 @@
|
||||
"", "", true, update_module_button($cm->id, $course->id, $strassignment));
|
||||
|
||||
if (isteacher($course->id)) {
|
||||
if ($submissions = assignment_get_all_submissions($assignment)) {
|
||||
$count = count($submissions);
|
||||
if ($assignment->type == OFFLINE) {
|
||||
echo "<P align=right><A HREF=\"submissions.php?id=$assignment->id\">".
|
||||
get_string("viewfeedback", "assignment")."</A></P>";
|
||||
} else {
|
||||
$count = 0;
|
||||
$count = count_records_sql("SELECT * FROM assignment_submissions
|
||||
WHERE assignment = '$assignment->id'
|
||||
AND timemodified > 0");
|
||||
echo "<P align=right><A HREF=\"submissions.php?id=$assignment->id\">".
|
||||
get_string("viewsubmissions", "assignment", $count)."</A></P>";
|
||||
}
|
||||
echo "<P align=right><A HREF=\"submissions.php?id=$assignment->id\">".
|
||||
get_string("viewsubmissions", "assignment", $count)."</A></P>";
|
||||
}
|
||||
|
||||
$strdifference = format_time($assignment->timedue - time());
|
||||
@@ -74,28 +77,36 @@
|
||||
echo "<BR>";
|
||||
|
||||
if (!isteacher($course->id) and !isguest()) {
|
||||
if ($submission = assignment_get_submission($assignment, $USER)) {
|
||||
print_simple_box_start("center");
|
||||
echo "<CENTER>";
|
||||
print_heading(get_string("yoursubmission","assignment").":", "CENTER");
|
||||
echo "<P><FONT SIZE=-1><B>".get_string("lastmodified")."</B>: ".userdate($submission->timemodified)."</FONT></P>";
|
||||
assignment_print_user_files($assignment, $USER);
|
||||
print_simple_box_end();
|
||||
$submission = assignment_get_submission($assignment, $USER);
|
||||
|
||||
if ($assignment->type == OFFLINE) {
|
||||
if ($submission->timemarked) {
|
||||
assignment_print_feedback($course, $submission);
|
||||
}
|
||||
} else {
|
||||
print_heading(get_string("notsubmittedyet","assignment"));
|
||||
}
|
||||
|
||||
echo "<HR SIZE=1 NOSHADE>";
|
||||
|
||||
if ($submission->grade) {
|
||||
print_heading(get_string("submissionfeedback", "assignment").":", "CENTER");
|
||||
assignment_print_feedback($course, $submission);
|
||||
} else {
|
||||
if ($submission) {
|
||||
echo "<P ALIGN=CENTER>".get_string("overwritewarning", "assignment")."</P>";
|
||||
if ($submission and $submission->timemodified) {
|
||||
print_simple_box_start("center");
|
||||
echo "<CENTER>";
|
||||
print_heading(get_string("yoursubmission","assignment").":", "CENTER");
|
||||
echo "<P><FONT SIZE=-1><B>".get_string("lastmodified")."</B>: ".userdate($submission->timemodified)."</FONT></P>";
|
||||
assignment_print_user_files($assignment, $USER);
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
print_heading(get_string("notsubmittedyet","assignment"));
|
||||
}
|
||||
|
||||
echo "<HR SIZE=1 NOSHADE>";
|
||||
|
||||
if ($submission and $submission->timemarked) {
|
||||
print_heading(get_string("submissionfeedback", "assignment").":", "CENTER");
|
||||
assignment_print_feedback($course, $submission);
|
||||
} else {
|
||||
if ($submission and $submission->timemodified) {
|
||||
echo "<P ALIGN=CENTER>".get_string("overwritewarning", "assignment")."</P>";
|
||||
}
|
||||
print_heading(get_string("submitassignment", "assignment").":", "CENTER");
|
||||
assignment_print_upload_form($assignment);
|
||||
}
|
||||
print_heading(get_string("submitassignment", "assignment").":", "CENTER");
|
||||
assignment_print_upload_form($assignment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user