Example #1
0
            def header(self):
                "hook to draw custom page header (logo and title)"
                import os
                import cpfecys
                logo = cpfecys.get_custom_parameters().clearance_logo
                if (logo is None) or (logo == ' ') or (logo == ''):
                    logo = os.path.join(request.folder, 'static/logo-usac.png')
                else:
                    logo = os.path.join(request.folder, 'uploads', logo)
                #self.image(logo,10,8,33)
                self.set_font('Times', 'B', 18)
                self.cell(35)  # padding
                self.cell(155, 7, "UNIVERSIDAD DE SAN CARLOS DE GUATEMALA", 0,
                          1, 'L')
                self.set_font('Times', '', 16)
                self.cell(35)  # padding
                self.cell(155, 7, u"FACULTAD DE INGENIERÍA", 0, 1, 'L')
                self.cell(35)  # padding
                self.cell(155, 8, u"Escuela de Ciencias y Sistemas", 0, 1, 'L')
                self.cell(35)  # padding
                self.cell(155, 7,
                          u"Desarrollo de Transferencia Tecnológica (DTT)", 0,
                          1, 'L')
                self.ln(5)
                self.cell(190, 0, '', 1, 1, 'L')
                self.ln(5)

                #self.cell(35) # padding
                #self.set_font('Times','B',18)
                #self.cell(190,7,"Constancia de Entrega de Reportes y Cumplimiento",0,1,'C')
                #self.cell(35) # padding
                #self.cell(190,7,"de",0,1,'C')
                #self.cell(35) # padding
                #self.cell(190,7,u"Requisitos de Práctica Final",0,1,'C')
                self.ln(1)
Example #2
0
 def header(self):
     "hook to draw custom page header (logo and title)"
     import os
     import cpfecys
     logo = cpfecys.get_custom_parameters().clearance_logo
     if (logo is None) or (logo == ' ') or (logo == ''):
         logo=os.path.join(request.folder,'static/logo-usac.png')
     else:
         logo = os.path.join(request.folder, 'uploads', logo)
     #self.image(logo,10,8,33)
     self.set_font('Times','B',18)
     self.cell(35) # padding
     self.cell(155,7,"UNIVERSIDAD DE SAN CARLOS DE GUATEMALA",0,1,'L')
     self.set_font('Times','',16)
     self.cell(35) # padding
     self.cell(155,7,u"FACULTAD DE INGENIERÍA",0,1,'L')
     self.cell(35) # padding
     self.cell(155,8,u"Escuela de Ciencias y Sistemas",0,1,'L')
     self.cell(35) # padding
     self.cell(155,7,u"Desarrollo de Transferencia Tecnológica (DTT)",0,1,'L')
     self.ln(5)
     self.cell(190,0,'',1,1,'L')
     self.ln(5)
     
     #self.cell(35) # padding
     #self.set_font('Times','B',18)
     #self.cell(190,7,"Constancia de Entrega de Reportes y Cumplimiento",0,1,'C')
     #self.cell(35) # padding
     #self.cell(190,7,"de",0,1,'C')
     #self.cell(35) # padding
     #self.cell(190,7,u"Requisitos de Práctica Final",0,1,'C')
     self.ln(1)
Example #3
0
 def footer(self):
     "hook to draw custom page footer (printing page numbers)"
     self.set_y(-25)
     self.set_font('Arial','I',8)
     txt = u'Página %s de %s' % (self.page_no(), self.alias_nb_pages())
     self.ln(2)
     self.cell(0,5,u'Firma:_______________________', 0, 1, 'C')
     import cpfecys
     cparams = cpfecys.get_custom_parameters()
     self.cell(0,4,unicode(cparams.coordinator_name), 0, 1, 'C')
     self.cell(0,4,unicode(cparams.coordinator_title), 0, 1, 'C')
     import datetime
     self.cell(0,5,'Generado: ' + datetime.datetime.now().strftime("%Y-%m-%d %H:%M"),0,0,'L')
     self.cell(0,5,txt,0,1,'R')
Example #4
0
 def footer(self):
     "hook to draw custom page footer (printing page numbers)"
     self.set_y(-25)
     self.set_font('Arial', 'I', 8)
     txt = u'Página %s de %s' % (self.page_no(),
                                 self.alias_nb_pages())
     self.ln(2)
     self.cell(0, 5, u'Firma:_______________________', 0, 1, 'C')
     import cpfecys
     cparams = cpfecys.get_custom_parameters()
     self.cell(0, 4, unicode(cparams.coordinator_name, "utf-8"), 0,
               1, 'C')
     #print "cparams.coordinator_title:"+str(cparams.coordinator_name)
     self.cell(0, 4, unicode(cparams.coordinator_title, "utf-8"), 0,
               1, 'C')
     import datetime
     self.cell(
         0, 5, 'Generado: ' +
         datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), 0, 0,
         'L')
     self.cell(0, 5, txt, 0, 1, 'R')
Example #5
0
def report():
    import datetime
    cdate = datetime.datetime.now()
    report = request.vars['report']
    report = db.report(db.report.id == report)
    import cpfecys
    parameters = cpfecys.get_custom_parameters()
    valid = not(report is None)
    next_date = None
    if valid:
        valid = cpfecys.teacher_validation_report_access(report.id)

    if (request.args(0) == 'view'):
        report = request.vars['report']
        report = db.report(db.report.id == report)
        valid = not(report is None)
        if valid:
            if report.score_date:
                next_date = report.score_date + datetime.timedelta(
                    days=parameters.rescore_max_days)
            response.view = 'teacher/report_view.html'
            assignation_reports = db(db.report.assignation== \
                report.assignation).select()
            teacher = db(db.auth_user.id==auth.user.id).select().first()
            return dict(
                log_types=db(db.log_type.id > 0).select(),
                assignation_reports = assignation_reports,
                logs=db((db.log_entry.report == report.id)).select(),
                parameters=parameters,
                metrics=db((db.log_metrics.report == report.id)).select(),
                final_r = db(db.log_final.report == report.id).select(),
                anomalies=db((db.log_type.name == 'Anomaly')&
                           (db.log_entry.log_type == db.log_type.id)&
                           (db.log_entry.report == report.id)).count(),
                markmin_settings=cpfecys.get_markmin,
                report=report,
                next_date=next_date,
                teacher=teacher)
        else:
            session.flash = T('Selected report can\'t be viewed. \
                                Select a valid report.')
            redirect(URL('teacher', 'index'))
    elif (request.args(0) == 'grade'):
        if valid:
            score = request.vars['score']
            comment = request.vars['comment']
            if score != None:
                score = int(score)
                if request.vars['improve'] != None:
                    if report.times_graded >= parameters.rescore_max_count and \
                            report.status.name!='EnabledForTeacher':
                        session.flash = T('This report can\'t be sent to \
                            rechecked anymore')
                        redirect(URL('teacher', 'report/view', \
                            vars=dict(report=report.id)))

                    if comment != None:
                        report.update_record(
                            score=score,
                            min_score=cpfecys.get_custom_parameters().min_score,
                            teacher_comment=comment,
                            status=db.report_status(name='Recheck'),
                            score_date=cdate,
                            times_graded=(report.times_graded or 0)+1)
                        session.flash = T('The report has been sent to recheck \
                            you will be notified via email when rechecked')
                        # Notification Message
                        import cpfecys
                        signature = (cpfecys.get_custom_parameters().email_signature or '')
                        me_the_user = db.auth_user(db.auth_user.id == auth.user.id)
                        row = db.user_project(db.user_project.id == report.assignation)
                        message = '<html>' + T('The report') + ' ' \
                        + '<b>' + XML(report.report_restriction['name']) + '</b><br/>' \
                        + T('sent by student: ') + XML(row.assigned_user['username']) + ' ' \
                        + XML(row.assigned_user['first_name']) + ' ' + XML(row.assigned_user['last_name']) \
                        + '<br/>' \
                        + T('Score: ') + XML(report.score) + ' ' \
                        + '<br/>' \
                        + T('Scored by: ') + XML(me_the_user.username) + ' ' \
                        + XML(me_the_user.first_name) + ' ' + XML(me_the_user.last_name) \
                        + '<br/>' \
                        + T('Comment: ') + XML(comment) + ' ' \
                        + '<br/>' \
                        + T('Was checked, but sent back to be fixed.') + '<br/>' \
                        + T('You have:') + ' ' + str(db(db.custom_parameters.id > 0).select().first().rescore_max_days) + ' '  + T('days to fix the report.') + '<br/>' \
                        + T('If report is not fixed within given time, then last valid score is taken.') + '<br/>' \
                        + T('Fix the report on:') \
                        + ' ' + cpfecys.get_domain() + '<br />' + signature + '</html>'
                        # send mail to teacher and student notifying change.
                        mails = []
                        # retrieve teacher's email
                        teacher = me_the_user.email
                        mails.append(teacher)
                        # retrieve student's email
                        student_mail = row.assigned_user['email']
                        mails.append(student_mail)
                        was_sent = mail.send(to=mails,
                                  subject=T('[DTT]Automatic Notification - Report needs improvement.'),
                                  # If reply_to is omitted, then mail.settings.sender is used
                                  reply_to = teacher,
                                  message=message)
                        #MAILER LOG
                        db.mailer_log.insert(sent_message = message,
                             destination = ','.join(mails),
                             result_log = str(mail.error or '') + ':' + str(mail.result),
                             success = was_sent)
                        redirect(URL('teacher', 'report/view', \
                            vars=dict(report=report.id)))
                else:
                    if score >= 0  and score <= 100:
                        report.update_record(
                            score=score,
                            min_score=cpfecys.get_custom_parameters().min_score,
                            teacher_comment=comment,
                            status=db.report_status(name='Acceptance'),
                            score_date=cdate,
                            times_graded=(report.times_graded or 0)+1)
                        session.flash = T('The report has been scored \
                            successfully')
                        # Notification Message
                        import cpfecys
                        signature = (cpfecys.get_custom_parameters().email_signature or '')
                        me_the_user = db.auth_user(db.auth_user.id == auth.user.id)
                        row = db.user_project(db.user_project.id == report.assignation)
                        message = '<html>' + T('The report') + ' ' \
                        + '<b>' + XML(report.report_restriction['name']) + '</b><br/>' \
                        + T('sent by student: ') + XML(row.assigned_user['username']) + ' ' \
                        + XML(row.assigned_user['first_name']) + ' ' + XML(row.assigned_user['last_name']) \
                        + '<br/>' \
                        + T('Score: ') + XML(report.score) + ' ' \
                        + '<br/>' \
                        + T('Scored by: ') + XML(me_the_user.username) + ' ' \
                        + XML(me_the_user.first_name) + ' ' + XML(me_the_user.last_name) \
                        + '<br/>' \
                        + T('Comment: ') + XML(comment) + ' ' \
                        + '<br/>' \
                        + T('Was checked. No further actions are needed.') + '<br/>' \
                        + T('DTT-ECYS') \
                        + ' ' + cpfecys.get_domain() + '<br />' + signature + '</html>'
                        # send mail to teacher and student notifying change.
                        mails = []
                        # retrieve teacher's email
                        teacher = me_the_user.email
                        mails.append(teacher)
                        # retrieve student's email
                        student_mail = row.assigned_user['email']
                        mails.append(student_mail)
                        was_sent = mail.send(to=mails,
                                  subject=T('[DTT]Automatic Notification - Report Done.'),
                                  # If reply_to is omitted, then mail.settings.sender is used
                                  reply_to = teacher,
                                  message=message)
                        #MAILER LOG
                        db.mailer_log.insert(sent_message = message,
                             destination = ','.join(mails),
                             result_log = str(mail.error or '') + ':' + str(mail.result),
                             success = was_sent)
                        redirect(URL('teacher', 'report/view', \
                            vars=dict(report=report.id)))

        session.flash = T('Selected report can\'t be viewed. \
                            Select a valid report.')
        redirect(URL('teacher', 'index'))
Example #6
0
def auto_daily():
    ## Get current year period
    import cpfecys
    currentyear_period = cpfecys.current_year_period()
    ## Get all report_restriction of this period_year that end_date is beyond today
    import datetime
    current_date = datetime.datetime.now()
    #if it is the first semester then the restriction should be:
    #start date >= January 1 year 00:00:00
    #end date >= January 1 year 00:00:00
    #start date < July 1 year 00:00:00
    #end date < July 1 year 00:00:00
    #if it is the second semester then the restriction should be:
    #start date >= July 1 year 00:00:00
    #end date >= July 1 year 00:00:00
    #start date < Jan 1 year 00:00:00
    #end date < Jan 1 year 00:00:00
    if currentyear_period.period == cpfecys.first_period.id:
        date_min = datetime.datetime(currentyear_period.yearp, 1, 1)
        date_max = datetime.datetime(currentyear_period.yearp, 7, 1)
    else:
        date_min = datetime.datetime(currentyear_period.yearp, 7, 1)
        date_max = datetime.datetime(currentyear_period.yearp, 1, 1)
    expired_restrictions = db((db.report_restriction.end_date < current_date)&
                              (db.report_restriction.start_date >= date_min)&
                              (db.report_restriction.end_date >= date_min)&
                              (db.report_restriction.start_date < date_max)&
                              (db.report_restriction.end_date < date_max)&
                              (db.report_restriction.is_enabled == True)).select()
    ## Get all assignations for this period_year
    semester_assignations = db((db.user_project.period <= currentyear_period.id)&
                     ((db.user_project.period + db.user_project.periods) > currentyear_period.id)).select()
    # For every assignation and restriction
    ## This makes all missed assignations automatically not sent and set to failed reports :(
    missed_reports = 0
    status_acceptance = db.report_status(db.report_status.name == 'Acceptance')
    for assignation in semester_assignations:
        for restriction in expired_restrictions:
            reports = db((db.report.assignation == assignation.id)&
                         (db.report.report_restriction == restriction.id)).count()
            if not(reports > 0):
                missed_reports += 1
                db.report.insert(assignation = assignation.id,
                                 min_score = cpfecys.get_custom_parameters().min_score,
                                 report_restriction = restriction.id,
                                 created = current_date,
                                 score = 0,
                                 status = status_acceptance,
                                 never_delivered = True,
                                 teacher_comment =  T('The period of time to create the report finished and it was never completed; so automatically it is considered as failed.'))
    ## This makes all 'Draft' reports that have no delivered anything to be set to failed!
    drafties = db((db.report.status == db.report_status(name = 'Draft'))&
               (db.report_restriction.end_date < current_date)&
               (db.report.report_restriction == db.report_restriction.id)&
               (db.report.heading == None)&
               (db.report.footer == None)&
               (db.report.desertion_started == None)&
               (db.report.desertion_gone == None)&
               (db.report.desertion_continued == None)&
               (db.report.hours == None)).select()
    total_drafties_empty = len(drafties)
    for d in drafties:
        d.report.score = 0
        d.report.status = db.report_status(name = 'Acceptance')
        d.report.teacher_comment =  T('The period of time to create the report finished and it was never completed; so automatically it is considered as failed.')
        d.report.never_delivered = True
        d.report.min_score = cpfecys.get_custom_parameters().min_score
        d.report.update_record()
##

    ## This makes all 'Draft' reports that expired get to 'Grading'
    drafties = db((db.report.status == db.report_status(name = 'Draft'))&
               (db.report_restriction.end_date < current_date)&
               (db.report.report_restriction == db.report_restriction.id)).select()
    total_drafties = len(drafties)
    import cpfecys
    signature = (cpfecys.get_custom_parameters().email_signature or '')
    for d in drafties:
        d.report.status = db.report_status(name = 'Grading')
        d.report.min_score = cpfecys.get_custom_parameters().min_score
        d.report.update_record()
        ## TODO: Send Email according to assignation
        # Notification Message
        me_the_user = d.report.assignation.assigned_user
        message = '<html>' + T('The report') + ' ' \
        + '<b>' + XML(d.report_restriction['name']) + '</b><br/>' \
        + T('sent by student: ') + XML(me_the_user.username) + ' ' \
        + XML(me_the_user.first_name) + ' ' + XML(me_the_user.last_name) \
        + '<br/>' \
        + T('was sent to be checked.') + '<br/>' + T('Checking can be done in:') \
        + ' ' + cpfecys.get_domain() + '<br />' + signature + '</html>'
        # send mail to teacher and student notifying change.
        mails = []
        # retrieve teacher's email
        teachers = db((db.project.id == d.report.assignation.project)&
                      (db.user_project.project == db.project.id)&
                      (db.user_project.assigned_user == db.auth_user.id)&
                      (db.auth_membership.user_id == db.auth_user.id)&
                      (db.auth_membership.group_id == db.auth_group.id)&
                      (db.auth_group.role == 'Teacher')).select()
        for teacher in teachers:
            mails.append(teacher.auth_user.email)
        # retrieve student's email
        student_mail = me_the_user.email
        mails.append(student_mail)
        was_sent = mail.send(to=mails,
                  subject=T('[DTT]Automatic Notification - Report ready to be checked.'),
                  # If reply_to is omitted, then mail.settings.sender is used
                  reply_to = student_mail,
                  message=message)
        #MAILER LOG
        db.mailer_log.insert(sent_message = message,
                             destination = ','.join(mails),
                             result_log = str(mail.error or '') + ':' + str(mail.result),
                             success = was_sent)
    ## This makes all 'Recheck' reports that expired to 'Grading'
    import datetime
    recheckies = db((db.report_restriction.id == db.report.report_restriction)&
                    (db.report.status == db.report_status(name='Recheck'))&
                    (db.report.score_date <= (current_date - datetime.timedelta(days = cpfecys.get_custom_parameters().rescore_max_days)))).select()
    total_recheckies = len(recheckies)
    import cpfecys
    signature = cpfecys.get_custom_parameters().email_signature
    for rech in recheckies:
        rech.report.status = db.report_status(name = 'Grading')
        rech.report.update_record()
        ## TODO: Send Email according to assignation
        me_the_user = rech.report.assignation.assigned_user
        message = '<html>' + T('The report') + ' ' \
        + '<b>' + XML(rech.report_restriction['name']) + '</b><br/>' \
        + T('sent by student: ') + XML(me_the_user.username) + ' ' \
        + XML(me_the_user.first_name) + ' ' + XML(me_the_user.last_name) \
        + '<br/>' \
        + T('was sent to be checked.') + '<br/>' + T('Checking can be done in:') \
        + ' ' + cpfecys.get_domain() + '<br />' + signature + '</html>'
        # send mail to teacher and student notifying change.
        mails = []
        # retrieve teacher's email
        teachers = db((db.project.id == rech.report.assignation.project)&
                      (db.user_project.project == db.project.id)&
                      (db.user_project.assigned_user == db.auth_user.id)&
                      (db.auth_membership.user_id == db.auth_user.id)&
                      (db.auth_membership.group_id == db.auth_group.id)&
                      (db.auth_group.role == 'Teacher')).select()
        for teacher in teachers:
            mails.append(teacher.auth_user.email)
        # retrieve student's email
        student_mail = me_the_user.email
        mails.append(student_mail)
        was_sent = mail.send(to=mails,
                  subject=T('[DTT]Automatic Notification - Report ready to be checked.'),
                  # If reply_to is omitted, then mail.settings.sender is used
                  reply_to = student_mail,
                  message = message)
        #MAILER LOG
        db.mailer_log.insert(sent_message = message,
                             destination = ','.join(mails),
                             result_log = str(mail.error or '') + ':' + str(mail.result),
                             success = was_sent)
    db.commit()
    auto_freeze()
    return T('Total Updated Reports: ') + str(total_recheckies + total_drafties + missed_reports) + ' ' + \
            T('Automatically Updated Draft Reports: ') + str(total_drafties) + ' ' + \
            T('Automatically Updated Recheck Reports: ') + str(total_recheckies) + ' ' + \
            T('Reports Never Delivered: ') + str(missed_reports + total_drafties_empty)