Browse files

Indexes added to submissions, assessments and grades tables.

Administration page cleaned up slightly.
  • Loading branch information...
1 parent ab809cc commit e539802dc51ed29585851a61638b7f6c3fc9aae7 rkingdon committed Nov 14, 2003
Showing with 78 additions and 80 deletions.
  1. +7 −0 mod/exercise/db/mysql.php
  2. +6 −3 mod/exercise/db/mysql.sql
  3. +60 −66 mod/exercise/lib.php
  4. +4 −10 mod/exercise/submissions.php
  5. +1 −1 mod/exercise/version.php
View
7 mod/exercise/db/mysql.php
@@ -6,6 +6,13 @@ function exercise_upgrade($oldversion) {
global $CFG;
+ if ($oldversion < 2003111400) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD INDEX (`userid`)");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` DROP INDEX `title`");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_assessments` ADD INDEX (`submissionid`)");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_submissions` ADD INDEX (`userid`)");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}exercise_grades` ADD INDEX (`assessmentid`)");
+ }
return true;
}
View
9 mod/exercise/db/mysql.sql
@@ -36,7 +36,7 @@ CREATE TABLE `prefix_exercise_submissions` (
`mailed` tinyint(3) unsigned NOT NULL default '0',
`isexercise` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
- INDEX `title` (`title`)
+ INDEX `userid` (`userid`)
) COMMENT='Info about submitted work from teacher and students';
# --------------------------------------------------------
@@ -56,7 +56,9 @@ CREATE TABLE `prefix_exercise_assessments` (
`mailed` tinyint(2) unsigned NOT NULL default '0',
`generalcomment` text NOT NULL,
`teachercomment` text NOT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ INDEX (`submissionid`),
+ INDEX (`userid`)
) COMMENT='Info about assessments by teacher and students';
# --------------------------------------------------------
@@ -102,7 +104,8 @@ CREATE TABLE `prefix_exercise_grades` (
`elementno` int(10) unsigned NOT NULL default '0',
`feedback` text NOT NULL default '',
`grade` tinyint(3) NOT NULL default '0',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ INDEX (`assessmentid`)
) COMMENT='Info about individual grades given to each element';
# --------------------------------------------------------
View
126 mod/exercise/lib.php
@@ -626,7 +626,7 @@ function exercise_get_user_assessments($exercise, $user) {
function exercise_get_user_submissions($exercise, $user) {
function exercise_list_all_ungraded_assessments($exercise) {
-function exercise_list_submissions_for_admin($exercise, $order) {
+function exercise_list_submissions_for_admin($exercise) {
function exercise_list_teacher_assessments($exercise, $user) {
function exercise_list_teacher_submissions($exercise, $user, $reassess) {
function exercise_list_unassessed_student_submissions($exercise, $user) {
@@ -1330,7 +1330,7 @@ function exercise_list_all_ungraded_assessments($exercise) {
///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_list_submissions_for_admin($exercise, $order) {
+function exercise_list_submissions_for_admin($exercise) {
// list the teacher sublmissions first
global $CFG, $EXERCISE_FWEIGHTS, $THEME, $USER;
@@ -1482,73 +1482,67 @@ function exercise_list_submissions_for_admin($exercise, $order) {
print_table($table);
echo "<p align=\"center\">".get_string("noteonstudentassessments", "exercise")."</p>\n";
}
- }
+ $elapsed = time() - $timenow;
+ echo "<p>Elapsed time: $elapsed\n";
+ }
// now the sudent submissions
unset($table);
- switch ($order) {
- case "title" :
- $table->head = array("<a href=\"submissions.php?action=adminlist&id=$cm->id&order=name\">".
- get_string("submittedby", "exercise")."</a>", get_string("title", "exercise"),
- get_string("submitted", "exercise"), get_string("action", "exercise"));
- break;
- case "name" :
- $table->head = array (get_string("submittedby", "exercise"),
- "<a href=\"submissions.php?action=adminlist&id=$cm->id&order=title\">".
- get_string("title", "exercise")."</a>", get_string("submitted", "exercise"),
- get_string("action", "exercise"));
- break;
- }
- $table->align = array ("left", "left", "left", "left");
- $table->size = array ("*", "*", "*", "*");
- $table->cellpadding = 2;
- $table->cellspacing = 0;
-
- if ($submissions = exercise_get_student_submissions($exercise, $order)) {
- foreach ($submissions as $submission) {
- if (!$user = get_record("user", "id", $submission->userid)) {
- error("exercise_list_submissions_for_admin: failure to get user record");
- }
- $action = "<a href=\"submissions.php?action=adminamendtitle&id=$cm->id&sid=$submission->id\">".
- get_string("amendtitle", "exercise")."</a>";
- // has teacher already assessed this submission
- if ($assessment = get_record_select("exercise_assessments", "submissionid = $submission->id
- AND userid = $USER->id")) {
- $curtime = time();
- if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
- $action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
- get_string("reassess", "exercise")."</a>";
- }
- else { // there's still time left to edit...
- $action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
- get_string("edit", "exercise")."</a>";
- }
- }
- else { // user has not assessed this submission
- $action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
- get_string("assess", "exercise")."</a>";
- }
- if ($nassessments = exercise_count_assessments($submission)) {
- $action .= " | <a href=\"assessments.php?action=adminlist&id=$cm->id&sid=$submission->id\">".
- get_string("view", "exercise")." ($nassessments)</a>";
- }
- $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
- get_string("delete", "exercise")."</a>";
- $title = $submission->title;
- if ($submission->resubmit) {
- $title .= "*";
- }
- $table->data[] = array("$user->firstname $user->lastname", $title.
- " ".exercise_print_submission_assessments($exercise, $submission),
- userdate($submission->timecreated), $action);
- }
- print_heading(get_string("studentsubmissions", "exercise", $course->student)." [".
- count($submissions)."]", "center");
- print_table($table);
- echo "<center><p>".get_string("resubmitnote", "exercise", $course->student)."</p>\n";
- echo "<p>".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade)."</p></center>\n";
- }
- }
+ if ($users) {
+ $table->head = array (get_string("submittedby", "exercise"), get_string("title", "exercise"),
+ get_string("submitted", "exercise"), get_string("action", "exercise"));
+ $table->align = array ("left", "left", "left", "left");
+ $table->size = array ("*", "*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ foreach ($users as $user) {
+ if ($submissions = exercise_get_user_submissions($exercise, $user)) {
+ foreach ($submissions as $submission) {
+ $action = "<a href=\"submissions.php?action=adminamendtitle&id=$cm->id&sid=$submission->id\">".
+ get_string("amendtitle", "exercise")."</a>";
+ // has teacher already assessed this submission
+ if ($assessment = get_record_select("exercise_assessments",
+ "submissionid = $submission->id AND userid = $USER->id")) {
+ $curtime = time();
+ if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
+ get_string("reassess", "exercise")."</a>";
+ }
+ else { // there's still time left to edit...
+ $action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
+ get_string("edit", "exercise")."</a>";
+ }
+ }
+ else { // user has not assessed this submission
+ $action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
+ get_string("assess", "exercise")."</a>";
+ }
+ if ($nassessments = exercise_count_assessments($submission)) {
+ $action .= " | <a href=\"assessments.php?action=adminlist&id=$cm->id&sid=$submission->id\">".
+ get_string("view", "exercise")." ($nassessments)</a>";
+ }
+ $action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
+ get_string("delete", "exercise")."</a>";
+ $title = $submission->title;
+ if ($submission->resubmit) {
+ $title .= "*";
+ }
+ $table->data[] = array("$user->firstname $user->lastname", $title.
+ " ".exercise_print_submission_assessments($exercise, $submission),
+ userdate($submission->timecreated), $action);
+ }
+ }
+ }
+ print_heading(get_string("studentsubmissions", "exercise", $course->student)." [".
+ count($submissions)."]", "center");
+ print_table($table);
+ echo "<center><p>".get_string("resubmitnote", "exercise", $course->student)."</p>\n";
+ echo "<p>".get_string("allgradeshaveamaximumof", "exercise", $exercise->grade)."</p></center>\n";
+ }
+ $elapsed = time() - $timenow;
+ echo "<p>Elapsed time: $elapsed\n";
+}
///////////////////////////////////////////////////////////////////////////////////////////////
View
14 mod/exercise/submissions.php
@@ -143,19 +143,13 @@
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
- }
- if (empty($_GET['order'])) {
- $order = "name";
- }
- else {
- $order = $_GET['order'];
- }
-
+ }
+
echo "<p><small>Exercise Version-> $module->version</small></p>";
- exercise_list_submissions_for_admin($exercise, $order);
+ exercise_list_submissions_for_admin($exercise);
print_continue("view.php?id=$cm->id");
- }
+ }
/******************* admin update title ************************************/
View
2 mod/exercise/version.php
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003100400;
+$module->version = 2003111400;
$module->cron = 60;
?>

0 comments on commit e539802

Please sign in to comment.