Created
December 11, 2008 18:54
-
-
Save ahoward/34820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lettuce_report_review | |
allows :student, :studentdemo | |
setup_for_student | |
@number = params[:id] || 1 | |
@disabled = params[:disabled]||params[:readonly]||request.query_string.to_s[%r/disabled|readonly/] | |
@review = @unit.find_lettuce_report_review(:student => @student, :number => @number) | |
unless @review | |
message "Sorry, there aren't any reports for you to review right now.", :class => "error" | |
redirect_to :action => 'index' and return | |
end | |
@report = @review.report | |
@questionnaire = @review.questionnaire | |
@questions_and_answers = @student.questions_and_answers_for(@questionnaire, :context => @classroom, :blank => true) | |
@disabled ||= @questions_and_answers.are_submitted? | |
if request.post? | |
transaction do | |
@questions_and_answers.update_with_params params | |
@questions_and_answers.save! | |
@review.save! | |
if submitting? | |
@questions_and_answers.submit! | |
@review.submit! | |
end | |
end | |
if submitting? | |
message 'Thanks, your review has been submitted!', :class => 'success' | |
else | |
message 'Thanks, your review has been saved!', :class => 'success' | |
end | |
qq_redirect_to :action => 'index' and return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment