From 0c5988d7d2ea0ca126bd17d9e12a5cb69c7231d0 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 3 Jun 2007 16:17:39 +0000 Subject: [PATCH] MDL-10011 cleanup xhtml and code in report.php - forum, glossary and data mod --- mod/data/report.php | 36 ++++++++++++++---------- mod/forum/report.php | 61 +++++++++++++++++++++++------------------ mod/glossary/report.php | 37 +++++++++++++++---------- 3 files changed, 78 insertions(+), 56 deletions(-) diff --git a/mod/data/report.php b/mod/data/report.php index ebb7668b3b..fafbc549e2 100755 --- a/mod/data/report.php +++ b/mod/data/report.php @@ -5,26 +5,32 @@ require_once("../../config.php"); require_once("lib.php"); - $id = required_param('id',PARAM_INT); + $id = required_param('id', PARAM_INT); $sort = optional_param('sort', '', PARAM_ALPHA); if (!$record = get_record('data_records', 'id', $id)) { error("Record ID is incorrect"); } + if (!$data = get_record('data', 'id', $record->dataid)) { error("Data ID is incorrect"); } + if (!$course = get_record('course', 'id', $data->course)) { error("Course is misconfigured"); } + if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { error("Course Module ID was incorrect"); } require_login($course->id, false, $cm); - $context = get_context_instance(CONTEXT_MODULE, $cm->id); + if (!$data->assessed) { + error("This activity does not use ratings"); + } + if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) { error("You can not view ratings"); } @@ -37,9 +43,9 @@ $scalemenu = make_grades_menu($data->scale); - $strratings = get_string("ratings", "data"); - $strrating = get_string("rating", "data"); - $strname = get_string("name"); + $strratings = get_string('ratings', 'data'); + $strrating = get_string('rating', 'data'); + $strname = get_string('name'); print_header($strratings); @@ -47,21 +53,23 @@ error("No ratings for this record!"); } else { - echo ""; + echo "
"; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; foreach ($ratings as $rating) { if (has_capability('mod/data:manageentries', $context)) { echo ''; } else { echo ''; } - echo "'; + echo ''; + echo ''; echo "\n"; } echo "
 $strname"; - echo "$strrating"; + echo " id&sort=firstname\">$strname$strrating
"; - print_user_picture($rating->id, $data->course, $rating->picture); - echo '

'.fullname($rating).'

'; - echo '

'.$scalemenu[$rating->rating]."

"; + echo '
'; + print_user_picture($rating->id, $data->course, $rating->picture, false, false, true); + echo ''.fullname($rating).''.$scalemenu[$rating->rating].'
"; @@ -69,5 +77,5 @@ } close_window_button(); - + print_footer('none'); ?> diff --git a/mod/forum/report.php b/mod/forum/report.php index 9af670134f..ede8b138f8 100644 --- a/mod/forum/report.php +++ b/mod/forum/report.php @@ -5,67 +5,76 @@ require_once("../../config.php"); require_once("lib.php"); - $id = required_param('id',PARAM_INT); + $id = required_param('id', PARAM_INT); + $sort = optional_param('sort', '', PARAM_ALPHA); - if (! $post = get_record("forum_posts", "id", $id)) { + if (! $post = get_record('forum_posts', 'id', $id)) { error("Post ID was incorrect"); } - if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) { + if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) { error("Discussion ID was incorrect"); } - if (! $forum = get_record("forum", "id", $discussion->forum)) { + if (! $forum = get_record('forum', 'id', $discussion->forum)) { error("Forum ID was incorrect"); } - if (! $course = get_record("course", "id", $forum->course)) { + if (! $course = get_record('course', 'id', $forum->course)) { error("Course ID was incorrect"); } - + if (! $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error('Course Module ID was incorrect'); + error("Course Module ID was incorrect"); } - + + require_login($course, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); - + + if (!$forum->assessed) { + error("This activity does not use ratings"); + } + if (!has_capability('mod/forum:viewrating', $context)) { - error('You do not have the capability to view post ratings'); + error("You do not have the capability to view post ratings"); } if (!has_capability('mod/forum:viewanyrating', $context) and $USER->id != $post->userid) { error("You can only look at results for posts that you made"); } - if (!isset($sort)) { - $sort = "r.time"; + switch ($sort) { + case 'firstname': $sqlsort = "u.firstname ASC"; break; + case 'rating': $sqlsort = "r.rating ASC"; break; + default: $sqlsort = "r.time ASC"; } $scalemenu = make_grades_menu($forum->scale); - $strratings = get_string("ratings", "forum"); - $strrating = get_string("rating", "forum"); - $strname = get_string("name"); - $strtime = get_string("time"); + $strratings = get_string('ratings', 'forum'); + $strrating = get_string('rating', 'forum'); + $strname = get_string('name'); + $strtime = get_string('time'); print_header("$strratings: ".format_string($post->subject)); - if (!$ratings = forum_get_ratings($post->id, $sort)) { + if (!$ratings = forum_get_ratings($post->id, $sqlsort)) { error("No ratings for this post: \"".format_string($post->subject)."\""); } else { - echo ""; + echo "
"; echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; foreach ($ratings as $rating) { echo ''; echo "'; - echo '"; - echo '"; + echo ''; + echo '"; + echo '"; echo "\n"; } echo "
 id&sort=u.firstname\">$strnameid&sort=r.rating\">$strratingid&sort=r.time\">$strtime
 id&sort=firstname\">$strnameid&sort=rating\">$strratingid&sort=time\">$strtime
"; print_user_picture($rating->id, $forum->course, $rating->picture); - echo '

'.fullname($rating).'

'.$scalemenu[$rating->rating]."

'.userdate($rating->time)."

'.fullname($rating).''.$scalemenu[$rating->rating]."'.userdate($rating->time)."
"; @@ -73,7 +82,5 @@ } close_window_button(); - print_footer('none'); - ?> diff --git a/mod/glossary/report.php b/mod/glossary/report.php index bc9d4e70ab..93496ca637 100644 --- a/mod/glossary/report.php +++ b/mod/glossary/report.php @@ -1,34 +1,41 @@ glossaryid)) { + if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) { error("Glossary ID was incorrect"); } - if (! $course = get_record("course", "id", $glossary->course)) { + if (! $course = get_record('course', 'id', $glossary->course)) { error("Course ID was incorrect"); } - - $module = get_record("modules","name","glossary"); - $cm = get_record("course_modules","module",$module->id,"instance",$entry->glossaryid); + + if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) { + error("Course Module ID was incorrect"); + } + + require_login($course, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); - + + if (!$glossary->assessed) { + error("This activity does not use ratings"); + } + if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) { error("You can only look at results for your own entries"); } switch ($sort) { - case 'time': $sqlsort = "r.time ASC"; break; case 'firstname': $sqlsort = "u.firstname ASC"; break; case 'rating': $sqlsort = "r.rating ASC"; break; default: $sqlsort = "r.time ASC"; @@ -36,10 +43,10 @@ $scalemenu = make_grades_menu($glossary->scale); - $strratings = get_string("ratings", "glossary"); - $strrating = get_string("rating", "glossary"); - $strname = get_string("name"); - $strtime = get_string("time"); + $strratings = get_string('ratings', 'glossary'); + $strrating = get_string('rating', 'glossary'); + $strname = get_string('name'); + $strtime = get_string('time'); print_header("$strratings: $entry->concept"); @@ -47,7 +54,7 @@ error("No ratings for this entry: \"$entry->concept\""); } else { - echo ""; + echo "
"; echo ""; echo ""; echo ""; @@ -73,5 +80,5 @@ } close_window_button(); - print_footer(); + print_footer('none'); ?> -- 2.39.5
 id&sort=firstname\">$strname