]> git.mjollnir.org Git - moodle.git/commitdiff
adding some capabilities
authortoyomoyo <toyomoyo>
Tue, 29 Aug 2006 08:43:59 +0000 (08:43 +0000)
committertoyomoyo <toyomoyo>
Tue, 29 Aug 2006 08:43:59 +0000 (08:43 +0000)
mod/chat/gui_header_js/index.php
mod/chat/gui_sockets/index.php
mod/choice/lib.php
mod/choice/report.php

index 632940a7e72552ea31ef442998ec8a53af0bf1fd..dcbc97ef2f4f77b837baefa186e7d4fc82541083 100644 (file)
@@ -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"));
     }
index 073f773a91ef98d869629f6b3e36a0d8cd0b1d07..74504f52810699e25ec6ffc16c4078e3fc4feb5f 100644 (file)
@@ -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"));
     }
index 2164e630386b564f7debc729bcf52a2abe3cde16..fd9b01de1429316c43697bcbf29b5f247d7128dc 100644 (file)
@@ -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 '<div id="tablecontainer">';
                 echo '<form id="attemptsform" method="post" action="'.$_SERVER['PHP_SELF'].'" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \''.addslashes(get_string('deleteattemptcheck','quiz')).'\' : true);">';
                 echo '<input type="hidden" name="id" value="'.$cm->id.'" />';
@@ -421,7 +415,7 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
                 echo "<table width=\"100%\">";
                 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 "<tr>";
                         if (isteacher($course->id, $USER->id) && !($optionid==0)) {
                             echo '<td width=\"5\" nowrap=\"nowrap\"><input type="checkbox" name="attemptid[]" value="'. $answers[$user->id]->id. '" /></td>';
@@ -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 '<tr><td><p>';
                     echo '<tr><td>';
                     echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
@@ -488,7 +480,6 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
             
             
             echo "</tr></table>";
-            //if (isteacher($course->id, $USER->id)) {
             if (has_capability('mod/choice:readresponses', $context)) {
                 echo "</form></div>";
             }
index 547825e5f904238b15cc4b76feac51ef4bae6b47..0da20cd43b320d8fc128c0683ff6fed07b96f362 100644 (file)
     
     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");
     }
         $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);