From f9a59efa64b567b398604dc627c75cd671475ec2 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Tue, 29 Aug 2006 08:43:59 +0000 Subject: [PATCH] adding some capabilities --- mod/chat/gui_header_js/index.php | 2 +- mod/chat/gui_sockets/index.php | 2 +- mod/choice/lib.php | 15 +++------------ mod/choice/report.php | 9 +++------ 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index 632940a7e7..dcbc97ef2f 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -24,7 +24,7 @@ require_capability('mod/chat:chat',$context); - if (!$cm->visible and !isteacher($course->id)) { + if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) { print_header(); notice(get_string("activityiscurrentlyhidden")); } diff --git a/mod/chat/gui_sockets/index.php b/mod/chat/gui_sockets/index.php index 073f773a91..74504f5281 100644 --- a/mod/chat/gui_sockets/index.php +++ b/mod/chat/gui_sockets/index.php @@ -24,7 +24,7 @@ error('Guest does not have access to chat rooms'); } - if (!$cm->visible and !isteacher($course->id)) { + if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) { print_header(); notice(get_string("activityiscurrentlyhidden")); } diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 2164e63038..fd9b01de14 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -159,7 +159,6 @@ $cdisplay = array(); if (!empty($countanswers)) { foreach ($countanswers as $ca) { //only return enrolled users. if (has_capability('mod/choice:choose', $context)) { - //if (isstudent($cm->course, $ca->userid) or isteacher($cm->course, $ca->userid)) { $countans = $countans+1; } } @@ -262,7 +261,6 @@ $current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user $countans = 0; foreach ($countanswers as $ca) { //only return enrolled users. if (has_capability('mod/choice:choose', $context)) { - //if (isstudent($courseid, $ca->userid) or isteacher($courseid, $ca->userid)) { $countans = $countans+1; } } @@ -308,7 +306,6 @@ function choice_show_reportlink($choice, $courseid, $cmid) { $responsecount = 0; foreach ($allanswers as $aa) { if (has_capability('mod/choice:readresponses', $context)) { - //if (isstudent($courseid, $aa->userid) or isteacher($courseid, $aa->userid)) { //check to make sure user is enrolled in course. $responsecount++; } } @@ -380,11 +377,8 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { switch ($forcepublish) { case CHOICE_PUBLISH_NAMES: - //$isteacher = isteacher($course->id); - $tablewidth = (int) (100.0 / count($useranswer)); if (has_capability('mod/choice:readresponses', $context)) { - //if (isteacher($course->id, $USER->id)) { echo '
'; echo '
'; echo ''; @@ -421,7 +415,7 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { echo ""; foreach ($userlist as $user) { // this needs to be fixed - if (!($optionid==0 && isadmin($user->id)) && !($optionid==0 && isteacher($course->id, $user->id) && !(isteacheredit($course->id, $user->id)) ) ) { //make sure admins and hidden teachers are not shown in not answered yet column. + if (!($optionid==0 && isadmin($user->id)) && !($optionid==0 && isteacher($course->id, $user->id) && !(isteacheredit($course->id, $user->id)) ) ) { // make sure admins and hidden teachers are not shown in not answered yet column. echo ""; if (isteacher($course->id, $USER->id) && !($optionid==0)) { echo ''; @@ -450,9 +444,8 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { $countanswers = get_records("choice_answers", "optionid", $optionid); $countans = 0; if (!empty($countanswers)) { - foreach ($countanswers as $ca) { //only return enrolled users. - // needs fixing too - if (isstudent($course->id, $ca->userid) or isteacher($course->id, $ca->userid)) { + foreach ($countanswers as $ca) { //only return enrolled users. + if (has_capability('mod/choice:choose', get_context_instance(CONTEXT_MODULE, $cm->id))) { $countans = $countans+1; } } @@ -471,7 +464,6 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { /// Print "Select all" etc. if (has_capability('mod/choice:readresponses', $context)) { - //if (isteacher($course->id, $USER->id)) { echo '

'; echo '

'; echo ''.get_string('selectall', 'quiz').' / '; @@ -488,7 +480,6 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { echo "
"; - //if (isteacher($course->id, $USER->id)) { if (has_capability('mod/choice:readresponses', $context)) { echo "
"; } diff --git a/mod/choice/report.php b/mod/choice/report.php index 547825e5f9..0da20cd43b 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -22,10 +22,6 @@ require_capability('mod/choice:readresponses', $context); - //if (!isteacher($course->id)) { - // error("Only teachers can look at this page"); - //} - if (!$choice = choice_get_choice($cm->instance)) { error("Course module is incorrect"); } @@ -109,10 +105,11 @@ $i=0; $row=1; if ($users) { - foreach ($users as $user) { + foreach ($users as $user) { + // this needs fixing if (!empty($answers[$user->id]) && !($answers[$user->id]->optionid==0 && isadmin($user->id)) && (!($answers[$user->id]->optionid==0 && isteacher($course->id, $user->id) && !(isteacheredit($course->id, $user->id)) ) ) && - !($choice->showunanswered==0 && $answers[$user->id]->optionid==0) ) { //make sure admins and hidden teachers are not shown in not answered yet column, and not answered only shown if set in config page. + !($choice->showunanswered==0 && $answers[$user->id]->optionid==0) ) { // make sure admins and hidden teachers are not shown in not answered yet column, and not answered only shown if set in config page. $myxls->write_string($row,0,$user->lastname); $myxls->write_string($row,1,$user->firstname); -- 2.39.5