Course role code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does anyone have any code they can share to create a course role with the following permissions.
- can view content
- can view gradebook
- cannot edit grade
- can view quizzes questions, but cannot view exam questions (midterm and final exams)
Basically, the user cannot grade, but can view the grades and comments from a teacher, and they can view quiz questions, but they cannot view exam questions.
The Javascript I have isn't quite working the way I need it to, and it's not possible to do this when I enable or disable some of the permissions. Here's the code (i removed the link to our server and noted it):
//alert(window.location.pathname);
var url = window.location.pathname;
url = url.split("/");
if((url[1]=="courses")&&(url[3]=="quizzes")){//check if on a quiz page
//alert("we are on a quiz page");
var courseID = url[2];
var quizID = url[4];
var quizReadOnlyPage = url[5];
//alert(courseID);
//alert(quizID);
//find out if quiz has access code
$.getJSON("/api/v1/courses/" + courseID + "/quizzes/" + quizID, function(dataQuiz){
if(dataQuiz.has_access_code==true){
alert("This quiz has an access code");
//var quizAccessCode = true;
//get self ID
$.getJSON("/api/v1/users/self", function(dataID){
selfID = dataID.id;
alert("My id is: " + selfID);
alert("here we have a link to our server" + courseID + "/enrollments?include[]=role&user_id="+selfID);
});//end json get self ID
//course and id are hard coded; change to variable once it is owrking.
$.getJSON("ourtestinstance/api/v1/courses/870/enrollments?include[]=role&user_id=" + selfID, function(enrollData) {
alert("Enroll Data: " + enrollData.role);
alert("getting users....");
var blockExams = false;
//loop through enrollments, find if "self" is in here.
$.each(data,function(i, value){
alert(value.role);
});//end for each enrollment
/*alert("checking role...");
if((enrollData.role=="BR_Coordinator")||(enrollData.role=="BR_Teacher")){
//alert(selfID + " " + value.role + ". You are a br teacher or coord");
blockExams = true;
alert("i am blocking you..." + blockExams);
$("ul.page-action-list").hide();//block exams
if(quizReadOnlyPage == "read_only"){
alert("you cannot be here!");
$("body").hide();
}else{
alert("you are fine to view the page.");
}//end if quiz read_only page
}else{//if not a BR Corrd and Teacher
alert("You are allowed to view this page.");
$("ul.page-action-list").css("visibility","visible");//unblock
}//end if self is enrolled AND a BR teach or coord
*/
}); //end get jSON enrollments
}else{//if this is not an exam -- does not have an access code
$("ul.page-action-list").css("visibility","visible");//unblock
//alert("this is not an exam");
}//end if has access code
});//end json get access code information
}//end IF on a quiz page
/***********END BLOCK EXAM*************/
Any help is greatly appreciated!