Esempio n. 1
0
	def scoreUpdate(self, **kw):
		print "-------------"
		print kw
		id = kw['id']
		value = kw['value']
				
		score = Score.get(int(id))
		crit = score.criterion
		assessment = score.assessment
		category = crit.category
		
		score.value = value
			
		user = identity.current.user		
		eh = EditHistory.selectBy(assessmentID=assessment.id, category=category)
		if eh.count() > 0:
			eh[0].editor = user.firstlast()
			eh[0].program = user.program.name
		else:
			EditHistory(assessmentID=assessment.id, category=category, editor=user.firstlast(), program=user.program.name)
		
		if crit.prefix in ['Y','Z']:
			st_crit = Criterion.selectBy(level=assessment.level, category=category, prefix="Z")[0]
			na_crit = Criterion.selectBy(level=assessment.level, category=category, prefix="Y")[0]
			
			possible = util.scorePossible(category, assessment.level)
			subtotal = Score.selectBy(criterionID=st_crit.id, assessmentID=assessment.id)[0].value
			na = Score.selectBy(criterionID=na_crit.id, assessmentID=assessment.id)[0].value
			
			return str(util.percent(subtotal,possible,na))
			
		return dict()
Esempio n. 2
0
	def getEditor(self, id, category):
		eh = EditHistory.selectBy(assessmentID=id, category=category)
		if eh.count() > 0:
			return (eh[0].editor,eh[0].program)
		else:
			user = identity.current.user
			e = EditHistory(assessmentID=id, category=category, editor=user.firstlast(), program=user.program.name)
			return (e.editor, e.program)
Esempio n. 3
0
	def fillUpdate(self, **kw):
		
		assessment = Assessment.get(cherrypy.session['current_assessment'])
		category = cherrypy.session['current_category']
		
		fill = kw['fill']
		value = kw['values']

		cherrypy.session['fill'] = fill
		cherrypy.session['values'] = value

		scores = assessment.scores
		criteria = Criterion.selectBy(category=category, level=assessment.level)
		
		if value == 'previous':
			sorted_assessments = Assessment.select(AND(Assessment.q.childID==assessment.childID,
													   Assessment.q.id!=assessment.id), orderBy='-dateEntered')
			previous = sorted_assessments[0]
		
		for c in criteria:
			score = Score.selectBy(criterionID=c.id, assessmentID=assessment.id, type='score')
			if score.count() == 0:
				if value == 'previous':
					temp = Score.selectBy(criterionID=c.id, assessmentID=previous.id, type='score')
					if temp.count() > 0:
						Score(value=temp[0].value, criterionID=c.id, assessmentID=assessment.id, type='score')
				elif value == 'zeros':
					Score(value="0", criterionID=c.id, assessmentID=assessment.id, type='score')
				elif value == 'twos':
					Score(value="2", criterionID=c.id, assessmentID=assessment.id, type='score')
			elif score[0].value not in ['0','1','2','#'] or fill == 'all':
				if value == 'previous':
					temp = Score.selectBy(criterionID=c.id, assessmentID=previous.id, type='score')
					if temp.count() > 0:
						score[0].value = temp[0].value
				elif value == 'zeros':
					score[0].value = "0"
				elif value == 'twos':
					score[0].value = "2"
			
		user = identity.current.user
		eh = EditHistory.selectBy(assessmentID=assessment.id, category=category)
		if eh.count() > 0:
			eh[0].editor = user.firstlast()
			eh[0].program = user.program.name
		else:
			EditHistory(assessmentID=assessment.id, category=category, editor=user.firstlast(), program=user.program.name)
		
		raise redirect("/assessment")
Esempio n. 4
0
	def assessmentUpdate(self, **kw):
		field = str(kw['field'])
		type = kw['type']
		id = cherrypy.session['current_assessment']

		if type == 'string':
			value = str(kw['value'])
		elif type == 'int':
			value = int(kw['value'])
		elif type == 'date':
			value = str(kw['value'])

		display = value

		if field == 'dateEntered':
			try:
				value = util.valiDate(value)
			except:
				cherrypy.response.status = 412
				return Assessment.get(id).dateEntered.strftime("%m/%d/%y")
			
			if value is None:
				cherrypy.response.status = 412
				return Assessment.get(id).dateEntered.strftime("%m/%d/%y")
			display = value.strftime("%m/%d/%y")

		Assessment.get(id).__setattr__(field, value)
		
		category = cherrypy.session['current_category']
		user = identity.current.user
		
		eh = EditHistory.selectBy(assessmentID=id, category=category)
		if eh.count() > 0:
			eh[0].editor = user.firstlast()
			eh[0].program = user.program.name
		else:
			EditHistory(assessmentID=id, category=category, editor=user.firstlast(), program=user.program.name)
		
		return display