Skip to content

Commit

Permalink
Version 2003100200: improved handling of resubmissions (new field add…
Browse files Browse the repository at this point in the history
…ed to workshop_assessments)
  • Loading branch information
rkingdon committed Oct 5, 2003
1 parent d8152d0 commit 12fbf69
Show file tree
Hide file tree
Showing 9 changed files with 611 additions and 317 deletions.
133 changes: 70 additions & 63 deletions mod/workshop/assessments.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -694,12 +694,12 @@
} }




/*********************** list teacher submissions ***********************/ /****************** list teacher submissions ***********************/
elseif ($action == 'listteachersubmissions') { elseif ($action == 'listteachersubmissions') {


workshop_list_teacher_submissions($workshop, $USER); workshop_list_teacher_submissions($workshop, $USER);
print_continue("view.php?a=$workshop->id"); print_continue("view.php?a=$workshop->id");
} }




/*************** update assessment (by teacher or student) ***************************/ /*************** update assessment (by teacher or student) ***************************/
Expand All @@ -708,17 +708,17 @@
require_variable($aid); require_variable($aid);
if (! $assessment = get_record("workshop_assessments", "id", $aid)) { if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
error("workshop assessment is misconfigured"); error("workshop assessment is misconfigured");
} }


// first get the assignment elements for maxscores and weights... // first get the assignment elements for maxscores and weights...
if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) { if (!$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC")) {
print_string("noteonassignmentelements", "workshop"); print_string("noteonassignmentelements", "workshop");
} }
else { else {
foreach ($elementsraw as $element) { foreach ($elementsraw as $element) {
$elements[] = $element; // to renumber index 0,1,2... $elements[] = $element; // to renumber index 0,1,2...
}
} }
}


$timenow = time(); $timenow = time();
// don't fiddle about, delete all the old and add the new! // don't fiddle about, delete all the old and add the new!
Expand All @@ -738,8 +738,8 @@
$element->feedback = $thefeedback; $element->feedback = $thefeedback;
if (!$element->id = insert_record("workshop_grades", $element)) { if (!$element->id = insert_record("workshop_grades", $element)) {
error("Could not insert workshop element!"); error("Could not insert workshop element!");
}
} }
}
$grade = 0; // set to satisfy save to db $grade = 0; // set to satisfy save to db
break; break;


Expand All @@ -764,10 +764,10 @@
$weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
if ($weight > 0) { if ($weight > 0) {
$totalweight += $weight; $totalweight += $weight;
} }
$rawgrade += ($grade / $maxscore) * $weight; $rawgrade += ($grade / $maxscore) * $weight;
// echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<BR>"; // echo "\$key, \$maxscore, \$weight, \$totalweight, \$grade, \$rawgrade : $key, $maxscore, $weight, $totalweight, $grade, $rawgrade<BR>";
} }
$grade = $workshop->grade * ($rawgrade / $totalweight); $grade = $workshop->grade * ($rawgrade / $totalweight);
break; break;


Expand All @@ -783,11 +783,11 @@
$element->grade = $form->grade[$i]; $element->grade = $form->grade[$i];
if (!$element->id = insert_record("workshop_grades", $element)) { if (!$element->id = insert_record("workshop_grades", $element)) {
error("Could not insert workshop element!"); error("Could not insert workshop element!");
} }
if (empty($form->grade[$i])){ if (empty($form->grade[$i])){
$error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight]; $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
}
} }
}
// now save the adjustment // now save the adjustment
unset($element); unset($element);
$i = $workshop->nelements; $i = $workshop->nelements;
Expand All @@ -797,8 +797,9 @@
$element->grade = $form->grade[$i]; $element->grade = $form->grade[$i];
if (!$element->id = insert_record("workshop_grades", $element)) { if (!$element->id = insert_record("workshop_grades", $element)) {
error("Could not insert workshop element!"); error("Could not insert workshop element!");
} }
$grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * $workshop->grade / 100; $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) *
$workshop->grade / 100;
echo "<P><B>".get_string("weightederrorcount", "workshop", intval($error + 0.5))."</B>\n"; echo "<P><B>".get_string("weightederrorcount", "workshop", intval($error + 0.5))."</B>\n";
break; break;


Expand All @@ -811,7 +812,7 @@
$element->grade = $form->grade[0]; $element->grade = $form->grade[0];
if (!$element->id = insert_record("workshop_grades", $element)) { if (!$element->id = insert_record("workshop_grades", $element)) {
error("Could not insert workshop element!"); error("Could not insert workshop element!");
} }
// now save the adjustment in element one // now save the adjustment in element one
unset($element); unset($element);
$element->workshopid = $workshop->id; $element->workshopid = $workshop->id;
Expand All @@ -820,7 +821,7 @@
$element->grade = $form->grade[1]; $element->grade = $form->grade[1];
if (!$element->id = insert_record("workshop_grades", $element)) { if (!$element->id = insert_record("workshop_grades", $element)) {
error("Could not insert workshop element!"); error("Could not insert workshop element!");
} }
$grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * $workshop->grade / 100; $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * $workshop->grade / 100;
break; break;


Expand All @@ -835,8 +836,8 @@
$element->grade = $thegrade; $element->grade = $thegrade;
if (!$element->id = insert_record("workshop_grades", $element)) { if (!$element->id = insert_record("workshop_grades", $element)) {
error("Could not insert workshop element!"); error("Could not insert workshop element!");
}
} }
}
// now work out the grade... // now work out the grade...
$rawgrade=0; $rawgrade=0;
$totalweight=0; $totalweight=0;
Expand All @@ -845,55 +846,58 @@
$weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight]; $weight = $WORKSHOP_EWEIGHTS[$elements[$key]->weight];
if ($weight > 0) { if ($weight > 0) {
$totalweight += $weight; $totalweight += $weight;
}
$rawgrade += ($grade / $maxscore) * $weight;
} }
$rawgrade += ($grade / $maxscore) * $weight;
}
$grade = $workshop->grade * ($rawgrade / $totalweight); $grade = $workshop->grade * ($rawgrade / $totalweight);
break; break;


} // end of switch } // end of switch


// update the time of the assessment record (may be re-edited)... // update the time of the assessment record (may be re-edited)...
set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id); set_field("workshop_assessments", "timecreated", $timenow, "id", $assessment->id);


if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
error ("Updateassessment: submission record not found"); error ("Updateassessment: submission record not found");
} }


// if the workshop does need peer agreement AND it's self assessment then set timeagreed // if the workshop does need peer agreement AND it's self assessment then set timeagreed
if ($workshop->agreeassessments and ($submission->userid == $assessment->userid)) { if ($workshop->agreeassessments and ($submission->userid == $assessment->userid)) {
set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id);
} }


set_field("workshop_assessments", "grade", $grade, "id", $assessment->id); set_field("workshop_assessments", "grade", $grade, "id", $assessment->id);
// ...and clear any grading of this assessment // ...and clear any grading of this assessment...
set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id); set_field("workshop_assessments", "timegraded", 0, "id", $assessment->id);
set_field("workshop_assessments", "gradinggrade", 0, "id", $assessment->id); set_field("workshop_assessments", "gradinggrade", 0, "id", $assessment->id);
// ...and the resubmission flag
set_field("workshop_assessments", "resubmission", 0, "id", $assessment->id);


// any comment? // any comment?
if (!empty($form->generalcomment)) { if (!empty($form->generalcomment)) {
set_field("workshop_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id); set_field("workshop_assessments", "generalcomment", $form->generalcomment, "id", $assessment->id);
} }


add_to_log($course->id, "workshop", "assess", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id"); add_to_log($course->id, "workshop", "assess",
"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id");


// set up return address // set up return address
if (!$returnto = $form->returnto) { if (!$returnto = $form->returnto) {
$returnto = "view.php?id=$cm->id"; $returnto = "view.php?id=$cm->id";
} }


// show grade if grading strategy is not zero // show grade if grading strategy is not zero
if ($workshop->gradingstrategy) { if ($workshop->gradingstrategy) {
redirect($returnto, get_string("thegradeis", "workshop").": ".number_format($grade, 2)."% (".get_string("maximumgrade"). redirect($returnto, get_string("thegradeis", "workshop").": ".number_format($grade, 2).
" ".number_format($workshop->grade)."%)"); "% (".get_string("maximumgrade")." ".number_format($workshop->grade)."%)");
} }
else { else {
redirect($returnto); redirect($returnto);
}
} }
}




/*************** update comment (by author, assessor or teacher) ***************************/ /****************** update comment (by author, assessor or teacher) ********************/
elseif ($action == 'updatecomment') { elseif ($action == 'updatecomment') {
$timenow = time(); $timenow = time();


Expand All @@ -902,10 +906,10 @@
// get the comment record... // get the comment record...
if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) { if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) {
error("Update to Comment failed"); error("Update to Comment failed");
} }
if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) {
error("Update Comment: Assessment not found"); error("Update Comment: Assessment not found");
} }
//save the comment for the assessment... //save the comment for the assessment...
if (isset($form->comments)) { if (isset($form->comments)) {
set_field("workshop_comments", "comments", $form->comments, "id", $comment->id); set_field("workshop_comments", "comments", $form->comments, "id", $comment->id);
Expand All @@ -914,26 +918,27 @@
set_field("workshop_comments", "mailed", 0, "id", $comment->id); set_field("workshop_comments", "mailed", 0, "id", $comment->id);
echo "<CENTRE><B>".get_string("savedok", "workshop")."</B></CENTER><BR>\n"; echo "<CENTRE><B>".get_string("savedok", "workshop")."</B></CENTER><BR>\n";


add_to_log($course->id, "workshop", "comment", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$comment->id"); add_to_log($course->id, "workshop", "comment",
} "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$comment->id");
}


print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id"); print_continue("assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id");
} }




/*************** update grading (by teacher) ***************************/ /****************** update grading (by teacher) ***************************/
elseif ($action == 'updategrading') { elseif ($action == 'updategrading') {
$timenow = time(); $timenow = time();


if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }


$form = (object)$_POST; $form = (object)$_POST;


if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) {
error("Update Grading failed"); error("Update Grading failed");
} }
//save the comment and grade for the assessment //save the comment and grade for the assessment
if (isset($form->teachercomment)) { if (isset($form->teachercomment)) {
set_field("workshop_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id); set_field("workshop_assessments", "teachercomment", $form->teachercomment, "id", $assessment->id);
Expand All @@ -942,37 +947,39 @@
set_field("workshop_assessments", "mailed", 0, "id", $assessment->id); set_field("workshop_assessments", "mailed", 0, "id", $assessment->id);
echo "<CENTRE><B>".get_string("savedok", "workshop")."</B></CENTRE><BR>\n"; echo "<CENTRE><B>".get_string("savedok", "workshop")."</B></CENTRE><BR>\n";


add_to_log($course->id, "workshop", "grade", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id"); add_to_log($course->id, "workshop", "grade",
} "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id");
}
switch ($form->stype) { switch ($form->stype) {
case "student" : case "student" :
redirect("assessments.php?action=listungradedstudentsubmissions&id=$cm->id"); redirect("assessments.php?action=listungradedstudentsubmissions&id=$cm->id");
break; break;
case "teacher" : case "teacher" :
redirect("assessments.php?action=listungradedteachersubmissions&id=$cm->id"); redirect("assessments.php?action=listungradedteachersubmissions&id=$cm->id");
break; break;
} }
} }




/******************* user confirm delete ************************************/ /****************** user confirm delete ************************************/
elseif ($action == 'userconfirmdelete' ) { elseif ($action == 'userconfirmdelete' ) {


if (empty($_GET['aid'])) { if (empty($_GET['aid'])) {
error("User confirm delete: assessment id missing"); error("User confirm delete: assessment id missing");
}

notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")),
"assessments.php?action=userdelete&id=$cm->id&aid=$_GET[aid]", "view.php?id=$cm->id");
} }

notice_yesno(get_string("confirmdeletionofthisitem","workshop",
get_string("assessment", "workshop")),
"assessments.php?action=userdelete&id=$cm->id&aid=$_GET[aid]", "view.php?id=$cm->id");
}




/******************* user delete ************************************/ /****************** user delete ************************************/
elseif ($action == 'userdelete' ) { elseif ($action == 'userdelete' ) {


if (empty($_GET['aid'])) { if (empty($_GET['aid'])) {
error("User delete: assessment id missing"); error("User delete: assessment id missing");
} }


print_string("deleting", "workshop"); print_string("deleting", "workshop");
// first delete all the associated records... // first delete all the associated records...
Expand All @@ -982,50 +989,50 @@
delete_records("workshop_assessments", "id", $_GET['aid']); delete_records("workshop_assessments", "id", $_GET['aid']);


print_continue("view.php?id=$cm->id"); print_continue("view.php?id=$cm->id");
} }




/*********************** view all assessments ***********************/ /****************** view all assessments ***********************/
elseif ($action == 'viewallassessments') { elseif ($action == 'viewallassessments') {


if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) {
error("View All Assessments: submission record not found"); error("View All Assessments: submission record not found");
} }


if ($assessments = workshop_get_assessments($submission)) { if ($assessments = workshop_get_assessments($submission)) {
foreach ($assessments as $assessment) { foreach ($assessments as $assessment) {
workshop_print_assessment($workshop, $assessment); workshop_print_assessment($workshop, $assessment);
}
} }
}
// only called from list all submissions // only called from list all submissions
print_continue("submissions.php?action=listallsubmissions&id=$cm->id"); print_continue("submissions.php?action=listallsubmissions&id=$cm->id");
} }




/*********************** view assessment ***********************/ /****************** view assessment *****************************/
elseif ($action == 'viewassessment') { elseif ($action == 'viewassessment') {


optional_variable($allowcomments); optional_variable($allowcomments);
if (!isset($allowcomments)) { if (!isset($allowcomments)) {
$allowcomments = false; $allowcomments = false;
} }


// get the assessment record // get the assessment record
if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) { if (!$assessment = get_record("workshop_assessments", "id", $_GET['aid'])) {
error("Assessment record not found"); error("Assessment record not found");
} }


// show assessment but don't allow changes // show assessment but don't allow changes
workshop_print_assessment($workshop, $assessment, false, $allowcomments); workshop_print_assessment($workshop, $assessment, false, $allowcomments);


print_continue("view.php?a=$workshop->id"); print_continue("view.php?a=$workshop->id");
} }




/*************** no man's land **************************************/ /*************** no man's land **************************************/
else { else {
error("Fatal Error: Unknown Action: ".$action."\n"); error("Fatal Error: Unknown Action: ".$action."\n");
} }


print_footer($course); print_footer($course);


Expand Down
5 changes: 5 additions & 0 deletions mod/workshop/db/mysql.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ function workshop_upgrade($oldversion) {
execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `overallocation` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `nsassessments`"); execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `overallocation` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `nsassessments`");


} }
if ($oldversion < 2003100200) {

execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `resubmission` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `mailed`");

}


return true; return true;
} }
Expand Down
3 changes: 2 additions & 1 deletion mod/workshop/db/mysql.sql
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ CREATE TABLE `prefix_workshop_assessments` (
`timeagreed` int(10) unsigned NOT NULL default '0', `timeagreed` int(10) unsigned NOT NULL default '0',
`grade` float NOT NULL default '0', `grade` float NOT NULL default '0',
`gradinggrade` int(3) NOT NULL default '0', `gradinggrade` int(3) NOT NULL default '0',
`mailed` tinyint(2) unsigned NOT NULL default '0', `mailed` tinyint(3) unsigned NOT NULL default '0',
`resubmission` tinyint(3) unsigned NOT NULL default '0',
`generalcomment` text NOT NULL, `generalcomment` text NOT NULL,
`teachercomment` text NOT NULL, `teachercomment` text NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
Expand Down
1 change: 1 addition & 0 deletions mod/workshop/db/oci8po.sql
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ CREATE TABLE prefix_workshop_assessments (
grade float default '0' not null, grade float default '0' not null,
gradinggrade number(3) default '0' not null, gradinggrade number(3) default '0' not null,
mailed number(2) default '0' not null, mailed number(2) default '0' not null,
resubmission number(2) default '0' not null,
generalcomment varchar2(255) NOT NULL, generalcomment varchar2(255) NOT NULL,
teachercomment varchar2(255) NOT NULL teachercomment varchar2(255) NOT NULL
); );
Expand Down
1 change: 1 addition & 0 deletions mod/workshop/db/postgres7.sql
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ CREATE TABLE prefix_workshop_assessments (
grade float NOT NULL default '0', grade float NOT NULL default '0',
gradinggrade INT NOT NULL default '0', gradinggrade INT NOT NULL default '0',
mailed INT2 NOT NULL default '0', mailed INT2 NOT NULL default '0',
resubmission INT2 NOT NULL default '0',
generalcomment text NOT NULL, generalcomment text NOT NULL,
teachercomment text NOT NULL teachercomment text NOT NULL
); );
Expand Down
Loading

0 comments on commit 12fbf69

Please sign in to comment.