Journal grading is now also all converted over to use scales as
well as numerical grades
This commit is contained in:
@@ -4,20 +4,44 @@ function journal_upgrade($oldversion) {
|
||||
// This function does anything necessary to upgrade
|
||||
// older versions to match current functionality
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 20020810) {
|
||||
if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
|
||||
$result = false;
|
||||
}
|
||||
if ($oldversion < 2002081000) {
|
||||
if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
if ($oldversion < 2002101200) {
|
||||
execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
|
||||
execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
|
||||
}
|
||||
if ($oldversion < 2002122300) {
|
||||
execute_sql("ALTER TABLE `journal_entries` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003081701) {
|
||||
table_column("journal", "assessed", "assessed", "integer", "10", "", "0");
|
||||
table_column("journal_entries", "rating", "rating", "integer", "10", "", "0");
|
||||
}
|
||||
|
||||
if ($oldversion < 2003081705) {
|
||||
$defaultscale = NULL;
|
||||
$defaultscale->courseid = 0;
|
||||
$defaultscale->userid = 0;
|
||||
$defaultscale->timemodified = time();
|
||||
$defaultscale->name = get_string("journalrating2", "journal");
|
||||
$defaultscale->scale = get_string("journalrating1", "journal").",".
|
||||
get_string("journalrating2", "journal").",".
|
||||
get_string("journalrating3", "journal");
|
||||
|
||||
if ($defaultscale->id = insert_record("scale", $defaultscale)) {
|
||||
execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
|
||||
} else {
|
||||
notify("An error occurred while inserting the default journal scale");
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ CREATE TABLE prefix_journal (
|
||||
name varchar(255) default NULL,
|
||||
intro text,
|
||||
days smallint(5) unsigned NOT NULL default '7',
|
||||
assessed tinyint(1) NOT NULL default '1',
|
||||
assessed int(10) NOT NULL default '0',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id)
|
||||
) TYPE=MyISAM;
|
||||
@@ -37,7 +37,7 @@ CREATE TABLE prefix_journal_entries (
|
||||
modified int(10) unsigned NOT NULL default '0',
|
||||
text text NOT NULL,
|
||||
format tinyint(2) NOT NULL default '0',
|
||||
rating tinyint(4) default '0',
|
||||
rating int(10) default '0',
|
||||
comment text,
|
||||
teacher int(10) unsigned NOT NULL default '0',
|
||||
timemarked int(10) unsigned NOT NULL default '0',
|
||||
|
||||
@@ -4,7 +4,27 @@ function journal_upgrade($oldversion) {
|
||||
// This function does anything necessary to upgrade
|
||||
// older versions to match current functionality
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2003081705) {
|
||||
$defaultscale = NULL;
|
||||
$defaultscale->courseid = 0;
|
||||
$defaultscale->userid = 0;
|
||||
$defaultscale->timemodified = time();
|
||||
$defaultscale->name = get_string("journalrating2", "journal");
|
||||
$defaultscale->scale = get_string("journalrating1", "journal").",".
|
||||
get_string("journalrating2", "journal").",".
|
||||
get_string("journalrating3", "journal");
|
||||
|
||||
if ($defaultscale->id = insert_record("scale", $defaultscale)) {
|
||||
execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
|
||||
} else {
|
||||
notify("An error occurred while inserting the default journal scale");
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ CREATE TABLE prefix_journal (
|
||||
name varchar(255) default NULL,
|
||||
intro text,
|
||||
days integer NOT NULL default '7',
|
||||
assessed integer NOT NULL default '1',
|
||||
assessed integer NOT NULL default '0',
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
# --------------------------------------------------------
|
||||
|
||||
+30
-20
@@ -1,10 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$JOURNAL_RATING = array ("3" => get_string("journalrating3", "journal"),
|
||||
"2" => get_string("journalrating2", "journal"),
|
||||
"1" => get_string("journalrating1", "journal") );
|
||||
|
||||
|
||||
|
||||
// STANDARD MODULE FUNCTIONS /////////////////////////////////////////////////////////
|
||||
|
||||
@@ -170,18 +165,33 @@ function journal_print_recent_activity($course, $isteacher, $timestart) {
|
||||
|
||||
function journal_grades($journalid) {
|
||||
/// Must return an array of grades, indexed by user, and a max grade.
|
||||
global $JOURNAL_RATING;
|
||||
|
||||
if ($return->grades = get_records_menu("journal_entries", "journal", $journalid, "", "userid,rating")) {
|
||||
foreach ($return->grades as $key => $value) {
|
||||
if ($value) {
|
||||
$return->grades[$key] = $JOURNAL_RATING[$value];
|
||||
} else {
|
||||
$return->grades[$key] = "-";
|
||||
if (!$journal = get_record("journal", "id", $journalid)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$grades = get_records_menu("journal_entries", "journal",
|
||||
$journal->id, "", "userid,rating");
|
||||
|
||||
if ($journal->assessed > 0) {
|
||||
$return->grades = $grades;
|
||||
$return->maxgrade = $journal->assessed;
|
||||
|
||||
} else if ($journal->assessed == 0) {
|
||||
$return->grades = NULL;
|
||||
$return->maxgrade = 0;
|
||||
|
||||
} else {
|
||||
if ($scale = get_record("scale", "id", - $journal->assessed)) {
|
||||
$scalegrades = make_menu_from_list($scale->scale);
|
||||
foreach ($grades as $key => $grade) {
|
||||
$grades[$key] = $scalegrades[$grade];
|
||||
}
|
||||
}
|
||||
$return->grades = $grades;
|
||||
$return->maxgrade = "";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -228,7 +238,7 @@ function journal_log_info($log) {
|
||||
|
||||
|
||||
|
||||
function journal_print_user_entry($course, $user, $entry, $teachers, $ratings) {
|
||||
function journal_print_user_entry($course, $user, $entry, $teachers, $grades) {
|
||||
global $THEME, $USER;
|
||||
|
||||
if ($entry->timemarked < $entry->modified) {
|
||||
@@ -265,7 +275,7 @@ function journal_print_user_entry($course, $user, $entry, $teachers, $ratings) {
|
||||
}
|
||||
print_user_picture($entry->teacher, $course->id, $teachers[$entry->teacher]->picture);
|
||||
echo "<TD BGCOLOR=\"$colour\">".get_string("feedback").":";
|
||||
choose_from_menu($ratings, "r$entry->id", $entry->rating, get_string("rate", "journal")."...");
|
||||
choose_from_menu($grades, "r$entry->id", $entry->rating, get_string("nograde")."...");
|
||||
if ($entry->timemarked) {
|
||||
echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
|
||||
}
|
||||
@@ -326,8 +336,8 @@ function journal_delete_instance($id) {
|
||||
}
|
||||
|
||||
|
||||
function journal_print_feedback($course, $entry) {
|
||||
global $CFG, $THEME, $JOURNAL_RATING;
|
||||
function journal_print_feedback($course, $entry, $grades) {
|
||||
global $CFG, $THEME;
|
||||
|
||||
if (! $teacher = get_record("user", "id", $entry->teacher)) {
|
||||
error("Weird journal error");
|
||||
@@ -347,11 +357,11 @@ function journal_print_feedback($course, $entry) {
|
||||
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
|
||||
|
||||
echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
|
||||
if ($JOURNAL_RATING[$entry->rating]) {
|
||||
echo get_string("overallrating", "journal").": ";
|
||||
echo $JOURNAL_RATING[$entry->rating];
|
||||
if ($grades[$entry->rating]) {
|
||||
echo get_string("grade").": ";
|
||||
echo $grades[$entry->rating];
|
||||
} else {
|
||||
print_string("noratinggiven", "journal");
|
||||
print_string("nograde");
|
||||
}
|
||||
echo "</I></FONT></P>";
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
if (!isset($form->intro)) {
|
||||
$form->intro = "";
|
||||
}
|
||||
if (!isset($form->assessed)) {
|
||||
$form->assessed = "0";
|
||||
}
|
||||
if (!isset($form->days)) {
|
||||
$form->days = "14";
|
||||
}
|
||||
@@ -36,6 +39,14 @@
|
||||
<textarea name="intro" rows=15 cols=30 wrap="virtual"><?php p($form->intro) ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><b><?php print_string("grade") ?>:</b></p></td>
|
||||
<td>
|
||||
<?php
|
||||
print_grade_menu($course->id, "assessed", "$form->assessed");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><b><?php print_string("daysavailable", "journal") ?>:</b></p></td>
|
||||
<td>
|
||||
|
||||
@@ -84,25 +84,29 @@
|
||||
add_to_log($course->id, "journal", "view responses", "report.php?id=$cm->id", "$journal->id");
|
||||
}
|
||||
|
||||
/// Print out the journal entries
|
||||
|
||||
$teachers = get_course_teachers($course->id);
|
||||
if (! $users = get_course_users($course->id)) {
|
||||
print_heading(get_string("nousersyet"));
|
||||
|
||||
} else {
|
||||
|
||||
$grades = make_grades_menu($journal->assessed);
|
||||
$teachers = get_course_teachers($course->id);
|
||||
|
||||
echo "<FORM ACTION=report.php METHOD=post>\n";
|
||||
|
||||
if ($usersdone = journal_get_users_done($journal)) {
|
||||
foreach ($usersdone as $user) {
|
||||
$entry = $entrybyuser[$user->id];
|
||||
journal_print_user_entry($course, $user, $entry, $teachers, $JOURNAL_RATING);
|
||||
journal_print_user_entry($course, $user, $entry, $teachers, $grades);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
if (empty($usersdone[$user->id])) {
|
||||
$entry = NULL;
|
||||
journal_print_user_entry($course, $user, $entry, $teachers, $JOURNAL_RATING);
|
||||
journal_print_user_entry($course, $user, $entry, $teachers, $grades);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2002122300;
|
||||
$module->version = 2003081705;
|
||||
$module->cron = 60;
|
||||
|
||||
?>
|
||||
|
||||
@@ -113,9 +113,10 @@
|
||||
echo userdate($timefinish)."</P>";
|
||||
}
|
||||
|
||||
if ($entry->comment || $entry->rating) {
|
||||
if ($entry->comment or $entry->rating) {
|
||||
$grades = make_grades_menu($journal->assessed);
|
||||
print_heading(get_string("feedback"));
|
||||
journal_print_feedback($course, $entry);
|
||||
journal_print_feedback($course, $entry, $grades);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user