Missing close bracket leads to syntax error in acces control rules
The following module has a missing close } for define page answer. This is correctly indicated in this version before the access control rules section following the section with the error. However, when inserting parameters for the showGrade template rule, i.e. ‘answer:Answer, inline : String’, then the entire access control rules section is containing the error.
module course/submissionsimports course/course-data
access control rules
rule template assignmentsOf(user : User) {
principal() == user || isFaculty()
}
rule template submissionsFor(assignment : Assignment) {
assignment.course.isOrganizer() || (principal() in assignment.course.students)
rule action startSubmission() { assignment.mayCreateSubmission() }
}section submission indices
define activateSubmission(submission : Submission) {
if(submission.mayDeactivate()) { actionLink(“[join other project]”, action { submission.deactivate(); return submission(submission); }) }
if(submission.mayActivate()) { actionLink(“[resume this project]”, action { submission.activate(); return submission(submission); }) }
}define submissionStatus(submission : Submission) {
if(submission.submitted) {
"submitted " output(submission.submittedOn)
} else { if(submission.active) {
“in progress”
} else {
“inactive”
} }
}define assignmentsOf(user : User) {
section{
header{“Assignments”}
table{
row{ “Due” “Course” “Assignment” “Status” “Grade” "" }
for(submission : Submission in user.assignments where submission.mayView() && submission.show() order by submission.assignment.due asc) {
row[class:=“active_assignment_”+submission.active]{
column{ output(submission.assignment.due) }
column{ outputCode(submission.assignment.course) }
column{ output(submission) }
column{ submissionStatus(submission) }
column{ if(submission.graded && submission.mayViewGrade()) { output(submission.grade) } }
column{ activateSubmission(submission) }
}
}
}
}
}define submissionsFor(assignment : Assignment) {
action startSubmission() { return submission(assignment.createSubmission()); }
section{
header{“Submissions”}
table{
row{ “Students” “Status” "" }
for(submission : Submission in assignment.submissions where submission.mayView() && submission.show() order by submission.students.list()[0].fullname) {
row[class:=“active_assignment_”+submission.active]{
column{ navigate(submission(submission)){ for(user : User in submission.students){ output(user.name) } separated-by { “, " } } }
column{ submissionStatus(submission) }
column{ if(submission.graded && submission.mayViewGrade()) { output(submission.grade) } }
column{ activateSubmission(submission) }
}
}
}
form{ actionLink(”[Start Submission]", startSubmission()) }
}
}access control rules
rule page submission(submission : Submission) { submission.mayView() }
section submission page
define page submission(submission : Submission) {
init{ submission.update(); }
main{
submissionWrap(submission, ""){
assignmentBody(submission.assignment)
for(answer : Answer in submission.answers.set() order by answer.question.number asc) {
answerInline(answer)
}
}
submitSubmission(submission)
}
}define submissionWrap(submission : Submission, crumb : String) {
section{
header{ output(submission.assignment.name) }
block[class:=submissionAdmin]{
block[class:=submitters]{
"Submission by " partners(submission)
}
block[class:=submissionDue]{
"Due: " output(submission.assignment.due)
}
block[class:=submissionStatus]{
if(submission.submitted) {
" Submitted: " output(submission.submittedOn)
} else {
" Last modified on " output(submission.modified)
}
}
if(submission.graded && submission.mayViewGrade()) {
block[class:=submissionStatus]{
“Grade: " output(submission.grade)
}
}
block[class:=submissionActive]{
addPartnerLink(submission)
if(!submission.active) { " (deactivated)” }
" " activateSubmission(submission)
}
}
block[class:=breadcrumb]{
"Course " outputCode(submission.assignment.course)
" > Assignment " outputCode(submission.assignment)
" > " navigate(submission(submission)){ “Submission” }
output(crumb)
}
elements()
}
}access control rules
rule template submitSubmission(submission: Submission) {
true
rule action submitIt() { submission.maySubmit() }
rule action reopen() { submission.mayReopen() }
}section submitting
define submitSubmission(submission: Submission) {
action submitIt() { submission.submit(); refresh(); }
action reopen() { submission.reopen(); refresh(); }
if(submission.maySubmit()) {
par{
"When your assignment is ready you can submit it. "
"By submitting the assignment you indicate that it is ready for grading. "
"Note that you cannot edit your work when it is submitted. "
“Until the deadline, and as long your work has not been graded, "
“you can reopen your submission to make corrections. "
form{ actionLink(”[Submit]”, submitIt())[ajax] }
}
}
if(submission.submitted) {
par{
“This assignment has been submitted. "
if(submission.mayReopen()) {
“You can reopen your assignment to make corrections. "
form{ actionLink(”[Reopen]”, reopen())[ajax] }
}
}
}
}access control rules
rule template partners(submission : Submission) {
submission.mayView()
rule action removePartner(u : User) { submission.mayRemovePartner() }}
rule page addPartner(submission : Submission) {
submission.mayAddPartner()
}section partners
define partners(submission : Submission) {
action removePartner(u : User) {
submission.students.remove(u);
return assignment(submission.assignment);
}
for(u:User in submission.students){
output(u) " " actionLink(“[X]”, removePartner(u))
} separated-by { ", " }
}define addPartnerLink(submission : Submission) {
navigate(addPartner(submission)){“[add partner]”}
}define page addPartner(submission : Submission) {
var user : User
action add(){
log(“add partner”);
submission.students.add(user);
return submission(submission);
}
main{
submissionWrap(submission, "") {
par{ “Select a partner for this submission” }
form{
select(user from submission.assignment.studentsWithoutActiveSubmission())[notnull:=true]
action(“Add”, add())
}
}
}
}access control rules
rule page answer(answer : Answer, op : String) {
op == "" && answer.mayView() || op == “edit” && answer.mayEdit()
}rule template answerInline(answer : Answer) { answer.mayView() }
rule ajaxtemplate answerDisplay(answer : Answer) { answer.mayView() }
rule template editAnswerLink(answer : Answer) { answer.mayEdit() }
rule ajaxtemplate editAnswer(answer : Answer, op : String) { answer.mayEdit() }rule template submitAnswer(answer : Answer) {
answer.question.submitable
rule action submit() { answer.maySubmit() }
rule action reopen() { answer.mayReopen() }
}section answers
define submitAnswer(answer : Answer) {
action submit() { answer.submit(); refresh(); }
action reopen() { answer.reopen(); refresh(); }
actionLink(“[Submit]”, submit())[ajax]
actionLink(“[Reopen]”, reopen())[ajax]
}define answerInline(answer : Answer) {
question(answer.question)
block[class:=answerText]{
output(answer.text)
block[class:=answerActions]{
navigate(answer(answer,“edit”)){“[Edit Answer]”} " "
navigate(answer(answer, ““)){”[Comments ("output(answer.comments.length) ")]”} " "
submitAnswer(answer)
}
}
//showGradeDialog(answer)
showGrade(answer, “inline”)
}define page answer(answer : Answer, op : String) {
main{
submissionWrap(answer.submission, " > Question " + answer.question.number){
question(answer.question)
placeholder answerBody {
case(op) {
“edit” { editAnswer(answer, op) }
default { answerDisplay(answer) }
}
showGradeDialog(answer, op)
for(comment : AnswerComment in answer.comments order by comment.submitted asc) { comment(comment) }
showGrade(answer, "")
newComment(answer)
navigateAnswers(answer)
}
}
}define navigateAnswers(answer : Answer) {
var prev : Answer := answer.previous()
var next : Answer := answer.next()
if(prev != null) {
navigate(answer(prev,““)){”[Previous]”}
}
if(next != null) {
navigate(answer(next,““)){”[Next]”}
}
}define ajax answerDisplay(answer : Answer) {
block[class:=answerText]{
output(answer.text)
block[class:=answerActions]{
editAnswerLink(answer)
submitAnswer(answer)
}
}
}define editAnswerLink(answer : Answer) {
form{ actionLink(“[Edit Answer]”, action{ replace(answerBody, editAnswer(answer,"")); })[ajax] }
}define ajax editAnswer(answer : Answer, op : String) {
action doit() {
// if(op == “edit”) { return submission(answer.submission); } else
replace(answerBody, answerDisplay(answer));
}
form{
block[class:=answerText]{ input(answer.text) }
action(“Save”, doit())[ajax]
}
action(“Cancel”, doit())[ajax]
}access control rules
rule template showGrade() { //}answer:Answer, inline : String) {
answer.mayGrade() || answer.mayViewGrade()
}
rule ajaxtemplate gradeDisplay(answer : Answer, inline : String) {
answer.mayViewGrade()
}
rule template editGradeLink(answer : Answer, inline : String) {
answer.mayGrade()
}
rule ajaxtemplate editGrade(answer : Answer) {
answer.mayGrade()
}section grading
define showGradeDialog(answer : Answer, op : String) {
placeholder gradedialog {
if(!answer.isGraded() && answer.mayGrade()) {
editGrade(answer)
}
}
}define showGrade(answer : Answer, inline : String) {
placeholder answerGrade {
gradeDisplay(answer, inline)
}
}define ajax gradeDisplay(answer : Answer, inline : String) {
if(answer.graded != null && answer.graded) {
block[class:=grade]{
"Grade: " output(answer.grade)
}
if(!isEmptyString(answer.gradeComments)) {
block[class:=gradeComments] { output(answer.gradeComments) }
}
block[class:=gradedBy]{ "By " output(answer.grader) " at " output(answer.gradedAt) }
}
editGradeLink(answer, inline)
}/*
define editGradeLink(answer : Answer) {
if(answer.isGraded()) {
form{ actionLink(“[Change Grade]”, action{ replace(answerGrade, editGrade(answer)); })[ajax] }
} else {
form{ actionLink(“[Grade]”, action{ replace(answerGrade, editGrade(answer)); })[ajax] }
}
}
*/define editGradeLink(answer : Answer, inline : String) {
action showEditDialog() {
if(inline == “inline”) {
return answer(answer,“grade”);
} else {
replace(gradedialog, editGrade(answer));
}
}
if(answer.isGraded()) {
form{ actionLink(“[Change Grade]”, showEditDialog())[ajax] }
} else {
form{ actionLink(“[Grade]”, showEditDialog())[ajax] }
}
}define ajax editGrade(answer: Answer) {
form{
block[class:=grade]{
"Grade: " input(answer.grade)
" " output(answer.question.title)
}
block[class:=gradeComments] {
input(answer.gradeComments)
}
block[class:=gradeComments] {
input(answer.question.gradeComments)
}
submit action{
answer.grader := principal();
answer.graded := true;
answer.gradedAt := now();
replace(answerGrade, gradeDisplay(answer));
} { “Save Grade” }
}
submit action{
replace(answerGrade, gradeDisplay(answer));
replace(gradedialog, empty());
} { “Cancel” }
}access control rules
rule template newComment(answer : Answer) { answer.mayView() }
section comments
// todo: edit comment, delete comment
define comment(comment : AnswerComment) {
section{
header{output(comment.title)}
block[class:=commentBody]{ output(comment.text) }
block[class:=commentByLine]{ "By " output(comment.author) " on " output(comment.submitted) }
}
}define newComment(answer : Answer) {
Submitted by Eelco Visser on 4 April 2010 at 10:18
var title : String
var text : WikiText
section{
form{
header{ input(title) { validate(!isEmptyString(title), "") } }
block[class:=commentBody]{ input(text) { validate(!isEmptyString(text), "") } }
action(“Submit Comment”, action{ answer.submitComment(title, text); })
}
}
}
Issue Log
Log in to post comments