Created
April 3, 2012 04:24
-
-
Save uris77/2289292 to your computer and use it in GitHub Desktop.
Example of weight templates
This file contains hidden or 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
//Create a template weight | |
SubjectAssessmentWeightTemplate weightTemplate1 = new SubjectAssessmentWeightTemplate() | |
weightTemplate1.subject = english101SUbject | |
weightTemplate1.assessmentType = quiz | |
weightTemplate1.weight = 10 | |
weightTemplate1.save() | |
SubjectAssessmentWeightTemplate weightTemplate2 = new SUbjectAssessmentWeightTemplate() | |
weightTemplate2.subject = english101Subject | |
weightTemplate2.assessmentType = homework | |
weightTemplate2.weight = 5 | |
weightTemplate2.save() | |
//Add templates to a group | |
SubjectAssessmentWeightTemplateGroup englishGroup = new SubjectAssessmentWeightTemplateGroup() | |
englishGroup.name = "Weights for English" | |
englishGroup.description = "Weights for English introductory classess" | |
englishGroup.addToSubjectAssessmentWeights(weightTemplate1) | |
englishGroup.addToSubjectAssessmentWeights(weightTemplate2) | |
enlgishGroup.save() | |
//Now we can apply weights from a template to a specific subject | |
SubjectAssessmentWeight subjectWeight = new SubjectAssessmentWeight() | |
subjectWeight.subject = english101 | |
subjectWeight.applyTemplate(englishGroup) | |
subject.validate() //should return false because semester is missing | |
subject.semester = firstSemester | |
subject.validate() //should pass now | |
subject.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment