Example #1
0
 def get_all_evals_for_assign(quarter, year, assign_num, active=True):
     return Evaluation.query(
         Evaluation.quarter == quarter,
         Evaluation.year == year,
         Evaluation.assignment_number == assign_num,
         Evaluation.active == active
     )
Example #2
0
 def get_eval_history_by_evaluatee(student, active, quarter, year):
     return Evaluation.query(
         Evaluation.evaluatee == student.key,
         Evaluation.active == active,
         Evaluation.quarter == quarter,
         Evaluation.year == year
     )
Example #3
0
    def post(self):
        quarter = SettingModel.quarter()
        year    = SettingModel.year()
        user    = users.get_current_user()

        evaluator       = StudentModel.get_student_by_email(quarter, year, user.email())
        partners        = PartnershipModel.get_active_partner_history_for_student(evaluator, quarter, year)
        eval_key,num    = split_last(self.request.get('evaluatee'))
        eval_assign     = int(num)
        current_partner = ndb.Key(urlsafe=eval_key).get()

        evaluations = EvalModel.get_existing_eval_by_assign(evaluator, current_partner, eval_assign)
        for eval in evaluations:
            eval.active = False
            eval.put()

        evaluation                   = Evaluation(evaluator = evaluator.key, evaluatee = current_partner.key)
        evaluation.assignment_number = eval_assign
        evaluation.year              = evaluator.year
        evaluation.quarter           = evaluator.quarter
        evaluation.active            = True
        for i in range(1, 11):
            evaluation.responses.append(self.request.get('q' + str(i)))
        evaluation.put()

        message  = 'Evaluation for ' + str(current_partner.last_name) + ', '
        message += str(current_partner.first_name) + ' successfully submitted'

        self.redirect('/partner?message=' + message)
Example #4
0
 def get_eval_for_pair_by_assign(evaluator, evaluatee, assign, active=True):
     return Evaluation.query(
         Evaluation.evaluatee == evaluatee.key,
         Evaluation.evaluator == evaluator.key,
         Evaluation.assignment_number == assign,
         Evaluation.active == active,
         Evaluation.year == evaluator.year,
         Evaluation.quarter == evaluator.quarter,
     )
Example #5
0
 def get_eval_for_pair_by_assign(evaluator, evaluatee, assign, active=True):
     return Evaluation.query(
         Evaluation.evaluatee == evaluatee.key,
         Evaluation.evaluator == evaluator.key,
         Evaluation.assignment_number == assign,
         Evaluation.active == active,
         Evaluation.year == evaluator.year,
         Evaluation.quarter == evaluator.quarter,
     )
Example #6
0
    def post(self):
        quarter = SettingModel.quarter()
        year = SettingModel.year()
        user = users.get_current_user()

        evaluator = StudentModel.get_student_by_email(quarter, year,
                                                      user.email())
        partners = PartnershipModel.get_active_partner_history_for_student(
            evaluator, quarter, year)
        eval_key, num = split_last(self.request.get('evaluatee'))
        eval_assign = int(num)
        current_partner = ndb.Key(urlsafe=eval_key).get()

        #   Log when eval is submitted
        #current date for timestamp
        cur_date = datetime.datetime.now().strftime("%m/%d/%Y %H:%M:%S")
        #get current log, creating one if it does not exist
        current_log = LogModel.get_log_by_student(evaluator, quarter,
                                                  year).get()
        if current_log == None:
            current_log = Log()
            current_log.owner = evaluator.key
            current_log.quarter = quarter
            current_log.year = year
        #log the submission of the eval
        current_log.log.append(cur_date + " Submitted eval for: " +
                               current_partner.ucinetid + " assgt. " +
                               str(eval_assign))
        #save to log
        current_log.put()

        evaluations = EvalModel.get_existing_eval_by_assign(
            evaluator, current_partner, eval_assign)
        for eval in evaluations:
            eval.active = False
            eval.put()

        evaluation = Evaluation(evaluator=evaluator.key,
                                evaluatee=current_partner.key)
        evaluation.assignment_number = eval_assign
        evaluation.year = evaluator.year
        evaluation.quarter = evaluator.quarter
        evaluation.active = True
        for i in range(1, 11):
            evaluation.responses.append(self.request.get('q' + str(i)))
        evaluation.put()

        message = 'Evaluation for ' + str(current_partner.last_name) + ', '
        message += str(
            current_partner.first_name
        ) + ' confirmed: Please refresh the page and confirm the evaluation was submitted.'
        self.redirect('/partner?message=' + message)
Example #7
0
def submit_evaluation(request):
    if request.method == 'POST':
        eval1 = EvaluationForm(request.POST)
        if eval1.is_valid():
            x = Evaluation()
            x.participation = eval1.cleaned_data["participation"]
            x.communication = eval1.cleaned_data["communication"]
            x.presentation = eval1.cleaned_data["presentation"]
            x.techskill = eval1.cleaned_data["techskill"]
            x.save()
            return HttpResponseRedirect("/valid_submission")
    else:
        eval1 = EvaluationForm()
    return render(request, "loggedin.html", {"eval1": eval1})
Example #8
0
 def post(self, request, faculty = '', department = '', course = ''):
     """
     The post function is used for giving a grade or comment
     to a course
     """
     
     if request.user.is_authenticated() != True:
         return HttpResponse('evaluation error: not authenticated')
     
     grade = int(request.POST['grade'])
     
     if grade > 10 or grade < 0:
         return HttpResponse('evaluation error: invalid grade')
     
     comment = request.POST['comment']
     
     if len(comment) > 2000:
         return HttpResponse('evaluation error: comment too long')
     
     user = request.user.id
     
     if faculty == 'null' or department == 'null':
         r = get_faculty_department(course)
         faculty = r[0]
         department = r[1]
     
     review = Evaluation.objects.filter(user=user, faculty=faculty, department=department, course=course)
     if len(review) > 0:
         review = Evaluation.objects.get(id=review[0].id)
         review.delete()
     
     new_evaluation = Evaluation(faculty = faculty,
                                 department = department,
                                 course = course,
                                 grade = grade,
                                 comment = comment,
                                 user = user)
     new_evaluation.save()
     
     return HttpResponse('evaluation done')
def create_evaluations_for(match):
    """
    :param match: Match
    :return list: list of Evaluation for each user of match
    """
    evaluations = []
    for i, user in enumerate(match.users):
        if i == 0:
            mate = match.users[1]
        else:
            mate = match.users[0]
        evaluation = Evaluation(match, user, mate)
        evaluations.append(evaluation)
    return evaluations
Example #10
0
def evaluation(request):
    if request.method == 'POST':
        form = EvaluationForm(request.POST)
        if form.is_valid():
            ev = Evaluation()
            ev.author = form.cleaned_data["author"] = request.user
            ev.evaluee = form.cleaned_data["evaluee"]
            ev.participation = form.cleaned_data["participation"]
            ev.communication = form.cleaned_data["communication"]
            ev.presentation = form.cleaned_data["presentation"]
            ev.techskill = form.cleaned_data["techskill"]
            ev.save()
            return HttpResponseRedirect("/confirmation")
    elif request.method == 'GET':
        form = EvaluationForm()
    else:
        return HttpResponseRedirect("/404/")
    return render(request, 'evaluation.html', {
        "form": form,
        "teams": Team.objects.all
    })
Example #11
0
def submit_evaluation(request):
    if request.method == 'POST':
        eval1 = EvaluationForm(request.POST)
        if eval1.is_valid():
            x = Evaluation()
            x.participation = eval1.cleaned_data["participation"]
            x.communication = eval1.cleaned_data["communication"]
            x.presentation = eval1.cleaned_data["presentation"]
            x.techskill = eval1.cleaned_data["techskill"]
            x.save()
            return HttpResponseRedirect("/valid_submission")
    else:
        eval1 = EvaluationForm()
    return render(request, "loggedin.html", {"eval1": eval1})
Example #12
0
def evaluation(request):
    if request.method == 'POST':
        form = EvaluationForm(request.POST)
        if form.is_valid():
            ev = Evaluation()
            ev.author = form.cleaned_data["author"] = request.user
            ev.evaluee = form.cleaned_data["evaluee"]
            ev.participation = form.cleaned_data["participation"]
            ev.communication = form.cleaned_data["communication"]
            ev.presentation = form.cleaned_data["presentation"]
            ev.techskill = form.cleaned_data["techskill"]
            ev.save()
            return HttpResponseRedirect ("/confirmation")
    elif request.method == 'GET':
        form = EvaluationForm()
    else:
        return HttpResponseRedirect ("/404/")
    return render(request, 'evaluation.html', {"form": form, "teams": Team.objects.all})
Example #13
0
 def get_existing_eval_by_assign(evaluator, current_partner, assign_num):
     return Evaluation.query(Evaluation.evaluator == evaluator.key,
                             Evaluation.evaluatee == current_partner.key,
                             Evaluation.assignment_number == assign_num)
Example #14
0
 def get_existing_eval_by_assign(evaluator, current_partner, assign_num):
     return Evaluation.query(
         Evaluation.evaluator == evaluator.key, 
         Evaluation.evaluatee == current_partner.key,
         Evaluation.assignment_number == assign_num
     )
Example #15
0
 def get_eval_history_by_evaluatee(student, active, quarter, year):
     return Evaluation.query(Evaluation.evaluatee == student.key,
                             Evaluation.active == active,
                             Evaluation.quarter == quarter,
                             Evaluation.year == year)
Example #16
0
 def get_eval_by_evaluator_and_assign(student, assign_num, active=True):
     return Evaluation.query(
         Evaluation.evaluator == student,
         Evaluation.active == active,
         Evaluation.assignment_number == assign_num,
     ).fetch()
Example #17
0
    def test_reviewers_cant_make_evaluations(self):
        u = User()
        u.username = '******'
        u.set_password('goscience')
        u.save()
        c = Client()
        logged_in = c.login(username='******', password='******')

        self.assertTrue(logged_in)

        # attempt to edit evaluation

        r = Reviewer()
        r.user = u
        r.name = 'Foo'
        r.affiliation = 'COS'
        r.email = '*****@*****.**'
        r.bio = 'Interested in opening up the sciences.'
        r.research = 'Metascience'
        r.website = 'http://cos.io'
        r.osfreviews = 0
        r.save()

        ev = Evaluation()
        ev.status = 'Pending'
        ev.progress = 'Received'
        ev.premise = 5
        ev.research = 6
        ev.style = 4
        ev.comment = 'This is a comment.'

        ev.reviewer = r
        ev.submission = Submission.objects.first()
        ev.save()
Example #18
0
    def setUp(self):

        u = User()
        u.username = '******'
        u.save()

        r = Reviewer()
        r.user = u
        r.name = 'Luke'
        r.affiliation = 'COS'
        r.email = '*****@*****.**'
        r.bio = 'I love to have fun.'
        r.research = 'Fun Facts'
        r.website = 'http://lukemarsh.com'
        r.osfreviews = 0
        r.save()

        s = Submission()
        s.conference = 'FooCon'
        s.title = 'Effects of Foo on Bar'
        s.reviewdeadline = datetime.date(2016, 12, 25).isoformat()
        s.authorname = 'Foo Bar'
        s.authoremail = '*****@*****.**'
        s.status = 'Awaiting review'
        s.link = 'http://foobar.org'
        s.attachment = '/foo/bar.pdf'
        s.save()

        s.reviewer.add(r)
        s.save()

        u2 = User()
        u2.username = '******'
        u2.save()

        ed = Editor()
        ed.user = u2
        ed.name = 'Tom Heatwole'
        ed.email = '*****@*****.**'
        ed.save()

        s.editor = ed
        s.save()

        ev = Evaluation()
        ev.status = 'Pending'
        ev.progress = 'Received'
        ev.premise = 5
        ev.research = 6
        ev.style = 4
        ev.comment = 'This is a comment.'

        ev.reviewer = r
        ev.submission = s
        ev.save()
Example #19
0
 def get_eval_by_evaluator_and_assign(student, assign_num, active=True):
     return Evaluation.query(
         Evaluation.evaluator == student,
         Evaluation.active == active,
         Evaluation.assignment_number == assign_num,
     ).fetch()
Example #20
0
def create_Evaluation():
    try:
        data = request.get_json()
        #nameEntity=data['nameEntity']
        #addressEntity=data['addressEntity']
        idEntity = data['idEntity']
        idPlan = data['idPlan']
        idUser = data['idUser']
        initialDate = date.today()
        #entity = Entity(name=nameEntity, address=addressEntity)
        #entity.save()
        #entity_evaluation= Entity.get_by_name(nameEntity)
        #idEntity=entity_evaluation.idEntity
        #date.today().strftime("%d/%m/%Y")
        evaluation = Evaluation(idEntity=idEntity,
                                idPlan=idPlan,
                                idUser=idUser,
                                idStatus=1,
                                initialDate=initialDate,
                                idPhase=4)
        evaluation.save()
        lastEvaluation = Evaluation.get_last_registration()
        criticalVariable_list = []
        criterion_list = []
        criterionList = db.session.query(Criterion_X_CriticalVariable,Criterion,CriticalVariable).\
            join(Criterion_X_CriticalVariable.criterion,Criterion_X_CriticalVariable.criticalVariable).filter(Criterion.idPlan==idPlan).all()
        for criterion in criterionList:
            modifyWeight = EvaluationModifiedWeight(
                idCriterion_X_CriticalVariable=criterion[0].
                idCriterion_X_CriticalVariable,
                idEvaluation=lastEvaluation.idEvaluation,
                idModifiedWeight=criterion[0].idWeight)
            modifyWeight.save()
            if (criterion[2] not in criticalVariable_list):
                criticalVariable_list.append(criterion[2])
            if (criterion[1] not in criterion_list):
                criterion_list.append(criterion[1])

        indicatorList = db.session.query(Indicator,CriticalVariable).\
            join(Indicator.criticalVariable).order_by(Indicator.idIndicator.asc()).all()
        for indicator in indicatorList:
            if (indicator[1] in criticalVariable_list):
                evaluation_indicator = Evaluation_X_Indicator(
                    idIndicator=indicator[0].idIndicator,
                    idEvaluation=lastEvaluation.idEvaluation)
                evaluation_indicator.save()

        questionList = db.session.query(Question,CriticalVariable).\
            join(Question.criticalVariable).order_by(Question.idQuestion.asc()).all()
        for question in questionList:
            if (question[1] in criticalVariable_list):
                evaluation_question = Evaluation_X_Question(
                    idQuestion=question[0].idQuestion,
                    idEvaluation=lastEvaluation.idEvaluation,
                    answer=-1)
                evaluation_question.save()

        for crit in criterion_list:
            objective_row = ObjectiveStrategic(
                idCriterion=crit.idCriterion,
                idEvaluation=lastEvaluation.idEvaluation,
                description="Sin Objetivo")
            objective_row.save()

        return jsonify(result={"status": 200})
    except Exception as e:
        db.session.rollback()
        return jsonify(result={"error": 400})
Example #21
0
 def get_all_evals_for_assign(quarter, year, assign_num, active=True):
     return Evaluation.query(Evaluation.quarter == quarter,
                             Evaluation.year == year,
                             Evaluation.assignment_number == assign_num,
                             Evaluation.active == active)