Exemplo n.º 1
0
class FlourishWorksheetEditView(flourish.form.Form, form.EditForm):

    template = InheritTemplate(flourish.page.Page.template)
    label = None
    legend = _('Worksheet Information')
    fields = field.Fields(interfaces.IActivityWorksheet).select('title')

    @property
    def title(self):
        return self.context.title

    def update(self):
        return form.EditForm.update(self)

    @button.buttonAndHandler(_('Submit'), name='apply')
    def handleApply(self, action):
        super(FlourishWorksheetEditView, self).handleApply.func(self, action)
        # XXX: hacky sucessful submit check
        if (self.status == self.successMessage
                or self.status == self.noChangesMessage):
            url = absoluteURL(self.context.__parent__, self.request)
            self.request.response.redirect(url)

    @button.buttonAndHandler(_("Cancel"))
    def handle_cancel_action(self, action):
        url = absoluteURL(self.context.__parent__, self.request)
        self.request.response.redirect(url)

    def updateActions(self):
        super(FlourishWorksheetEditView, self).updateActions()
        self.actions['apply'].addClass('button-ok')
        self.actions['cancel'].addClass('button-cancel')
Exemplo n.º 2
0
 def __init__(self):
     self.templates, event = containedEvent(
         GradebookTemplates(_('Report Sheet Templates')), self, 'templates')
     self.deployed, event = containedEvent(
         GradebookDeployed(_('Deployed Report Sheets')), self, 'deployed')
     self.layouts, event = containedEvent(
         GradebookLayouts(_('Report Card Layouts')), self, 'layouts')
Exemplo n.º 3
0
class FlourishCategoryAddView(flourish.form.AddForm):

    template = flourish.templates.Inherit(flourish.page.Page.template)
    legend = _('Category')
    fields = field.Fields(ICategoryForm)

    def nextURL(self):
        return absoluteURL(self.context, self.request)

    @button.buttonAndHandler(_('Add'))
    def handle_add_action(self, action):
        flourish.form.AddForm.handleAdd.func(self, action)

    @button.buttonAndHandler(_('Cancel'))
    def handle_cancel_action(self, action):
        self.request.response.redirect(self.nextURL())

    def create(self, data):
        return data['title']

    def add(self, title):
        key = unicode(title).encode('punycode')
        self.context[key] = title

    def updateActions(self):
        super(FlourishCategoryAddView, self).updateActions()
        self.actions['add'].addClass('button-ok')
        self.actions['cancel'].addClass('button-cancel')
Exemplo n.º 4
0
class ICourseWorksheet(interfaces.IRequirement):
    '''A worksheet template to get copied into section gradebooks.'''

    contains('.IActivity')

    title = zope.schema.TextLine(
        title=_(u'Title'),
        description=_(u'Identifies the course worksheet in gradebooks.'))
Exemplo n.º 5
0
class ILinkedColumnActivity(IActivity):
    """An activity that can be linked to an external activity"""

    source = zope.schema.TextLine(
        title=_(u"Linked Column Activity Source"),
        description=_(
            u"A text string that specifies the source of the column"),
        required=True)
Exemplo n.º 6
0
class IReportWorksheet(interfaces.IRequirement, IWorksheetAnnotatableMixin):
    '''A worksheet template to get copied into section gradebooks.'''

    containers(IGradebookTemplates, IGradebookDeployed)
    contains('.IReportActivity')

    title = zope.schema.TextLine(
        title=_(u'Title'),
        description=_(u'Identifies the report sheet in teacher gradebooks.'))
Exemplo n.º 7
0
    def __call__(self):
        self.makeProgress()
        self.task_progress.title = _("Exporting worksheets")
        self.addImporters(self.task_progress)

        wb = xlwt.Workbook()
        self.export_terms(wb, self.getTerms())

        self.task_progress.title = _("Export complete")
        return wb
Exemplo n.º 8
0
 def minmax(self):
     ismax = False
     current = self.current_source()
     if current:
         ss = self.getScoreSystem(current)
         if IDiscreteValuesScoreSystem.providedBy(ss):
             if ss._isMaxPassingScore:
                 ismax = True
     if ismax:
         return _('Maximum Passing Score')
     else:
         return _('Minimum Passing Score')
Exemplo n.º 9
0
class IReportLayout(Interface):
    '''The layout of the report card for the school year'''

    columns = zope.schema.List(
        title=_('Columns'),
        description=_('Columns to be printed in the report card.'))

    outline_activities = zope.schema.List(
        title=_('Outline Activities'),
        description=_('Activities to be printed in the outline section.'))

    containers(IGradebookLayouts)
Exemplo n.º 10
0
class ICategoriesForm(zope.interface.Interface):
    """Schema for the form."""

    categories = zope.schema.Set(
        title=_('Categories'),
        value_type=zope.schema.Choice(
            vocabulary="schooltool.gradebook.category-vocabulary"))

    newCategory = zope.schema.TextLine(title=_("New Category"), required=False)

    defaultCategory = zope.schema.Choice(
        title=_("Default Category"),
        vocabulary="schooltool.gradebook.category-vocabulary")
Exemplo n.º 11
0
class FlourishCourseActivityAddView(FlourishActivityAddView):
    legend = _('Course Activity Details')

    @property
    def fields(self):
        default = FlourishActivityAddView.fields
        default += field.Fields(IReportScoreSystem).select('scoresystem')
        return default.select(
            'title',
            'label',
            'due_date',
            'description',
            'category',
            'scoresystem',
            'max',
            'min',
        )

    def create(self, data):
        if data['scoresystem'] == 'ranged':
            minimum = data['min']
            if minimum is None:
                minimum = 0
            maximum = data['max']
            if maximum is None:
                maximum = 100
            scoresystem = RangedValuesScoreSystem(u'generated',
                                                  min=minimum,
                                                  max=maximum)
        else:
            scoresystem = data['scoresystem']
        activity = Activity(data['title'], data['category'], scoresystem,
                            data['description'], data['label'],
                            data.get('due_date'))
        return activity
Exemplo n.º 12
0
class AbsencesByDateRangeRequestView(RequestRemoteReportDialog):

    fields = z3c.form.field.Fields(IRequestAbsencesByDateRangeForm)

    report_builder = 'absences_by_date_range.pdf'

    title = _('Request Absences for Range of Dates Report')

    @property
    def schoolyear(self):
        return self.context

    def update(self):
        self.message = ''
        RequestRemoteReportDialog.update(self)

    def updateTaskParams(self, task):
        start = self.form_params.get('start')
        end = self.form_params.get('end')
        if start > end:
            start, end = end, start
        if start is not None:
            day = '%d-%02d-%02d' % (start.year, start.month, start.day)
            task.request_params['start'] = day
        if end is not None:
            day = '%d-%02d-%02d' % (end.year, end.month, end.day)
            task.request_params['end'] = day
Exemplo n.º 13
0
 def choices(self):
     """Get  a list of the possible choices for report activities."""
     result = {
         'name': _('Choose a report activity'),
         'value': '',
         }
     results = [result]
     root = IGradebookRoot(ISchoolToolApplication(None))
     term = self.context
     schoolyear = ISchoolYear(term)
     deployedKey = '%s_%s' % (schoolyear.__name__, term.__name__)
     for key in root.deployed:
         if key.startswith(deployedKey):
             deployedWorksheet = root.deployed[key]
             for activity in deployedWorksheet.values():
                 if ICommentScoreSystem.providedBy(activity.scoresystem):
                     continue
                 name = '%s - %s - %s' % (term.title,
                     deployedWorksheet.title, activity.title)
                 value = '%s|%s|%s' % (term.__name__,
                     deployedWorksheet.__name__, activity.__name__)
                 result = {
                     'name': name,
                     'value': value,
                     }
                 results.append(result)
     return results
Exemplo n.º 14
0
 def createTerms(self, term):
     result = []
     result.append(self.createTerm(
             None,
             z3c.form.widget.SequenceWidget.noValueToken,
             _("Select a source"),
             ))
     root = IGradebookRoot(ISchoolToolApplication(None))
     schoolyear = ISchoolYear(term)
     deployedKey = '%s_%s' % (schoolyear.__name__, term.__name__)
     for key in root.deployed:
         if key.startswith(deployedKey):
             deployedWorksheet = root.deployed[key]
             for activity in deployedWorksheet.values():
                 if ICommentScoreSystem.providedBy(activity.scoresystem):
                     continue
                 title = '%s - %s - %s' % (term.title,
                     deployedWorksheet.title, activity.title)
                 token = '%s-%s-%s' % (term.__name__,
                     deployedWorksheet.__name__, activity.__name__)
                 token=unicode(token).encode('punycode')
                 result.append(self.createTerm(
                     (deployedWorksheet, activity,),
                     token,
                     title,
                     ))
     return result
Exemplo n.º 15
0
class FlourishCourseWorksheetEditView(flourish.form.Form, form.EditForm):

    template = InheritTemplate(flourish.page.Page.template)
    label = None
    legend = _('Course Worksheet Template Information')
    fields = field.Fields(ICourseWorksheet).select('title')

    @property
    def title(self):
        return self.context.title

    def update(self):
        if 'form-submitted' in self.request:
            for activity in self.context.values():
                name = 'delete.%s' % activity.__name__
                if name in self.request:
                    del self.context[activity.__name__]
                    break
        return form.EditForm.update(self)

    @button.buttonAndHandler(_('Submit'), name='apply')
    def handleApply(self, action):
        super(FlourishCourseWorksheetEditView,
              self).handleApply.func(self, action)
        # XXX: hacky sucessful submit check
        if (self.status == self.successMessage
                or self.status == self.noChangesMessage):
            self.request.response.redirect(self.nextURL())

    @button.buttonAndHandler(_("Cancel"))
    def handle_cancel_action(self, action):
        self.request.response.redirect(self.nextURL())

    def nextURL(self):
        return absoluteURL(self.context.__parent__, self.request)

    def updateActions(self):
        super(FlourishCourseWorksheetEditView, self).updateActions()
        self.actions['apply'].addClass('button-ok')
        self.actions['cancel'].addClass('button-cancel')

    def display_scoresystem(self, activity):
        ss = activity.scoresystem
        if IRangedValuesScoreSystem.providedBy(ss):
            return '%s - %s' % (ss.min, ss.max)
        return ss.title
Exemplo n.º 16
0
class IExternalActivity(zope.interface.Interface):
    """An external activity"""

    source = zope.schema.TextLine(
        title=_(u"External Activity Source"),
        description=_(u"The registration name of the source"),
        required=True)

    external_activity_id = zope.schema.TextLine(
        title=_(u"External Activity ID"),
        description=_(u"A unique identifier for the external activity"),
        required=True)

    title = zope.schema.TextLine(
        title=_(u"Title"),
        description=_(u"A brief title of the external activity."),
        required=True)

    description = zope.schema.Text(title=_("Description"), required=False)

    def getGrade(student):
        """Get the grade for an external activity.

        Return a Decimal percentage representing the grade for the
        given student. If there is no grade for that student for that
        external activity, None should be returned"""

    def __eq__(another):
        """Compare equality with other external activities"""
Exemplo n.º 17
0
class IExternalActivities(zope.interface.Interface):
    """External activities of a section"""

    source = zope.schema.TextLine(
        title=_(u"External Activity Source"),
        description=_(u"Name of the external activities source"),
        required=True)

    title = zope.schema.TextLine(
        title=_(u"Title"),
        description=_(u"A brief title of the external activities source"),
        required=True)

    def getExternalActivities():
        """Return a list of IExternalActivity objects for its context
        section"""

    def getExternalActivity(external_activity_id):
        """Return an IExternalActivity object matching the provided id.
Exemplo n.º 18
0
class FlourishWorksheetAddView(flourish.form.AddForm):
    """flourish view for adding a worksheet."""

    fields = field.Fields(interfaces.IActivityWorksheet).select('title')
    template = InheritTemplate(flourish.page.Page.template)
    label = None
    legend = _('Worksheet Details')

    @button.buttonAndHandler(_('Submit'), name='add')
    def handleAdd(self, action):
        super(FlourishWorksheetAddView, self).handleAdd.func(self, action)

    @button.buttonAndHandler(_("Cancel"))
    def handle_cancel_action(self, action):
        person = IPerson(self.request.principal, None)
        if person is None:
            worksheet = self.context._getDefaultWorksheet()
        else:
            worksheet = self.context.getCurrentWorksheet(person)
        if worksheet is None:
            url = absoluteURL(self.context.__parent__, self.request)
        else:
            url = absoluteURL(worksheet, self.request) + '/gradebook'
        self.request.response.redirect(url)

    def create(self, data):
        self.worksheet = Worksheet(data['title'])
        return self.worksheet

    def add(self, worksheet):
        chooser = INameChooser(self.context)
        name = chooser.chooseName(worksheet.title, worksheet)
        self.context[name] = worksheet
        return worksheet

    def nextURL(self):
        return absoluteURL(self.worksheet, self.request)

    def updateActions(self):
        super(FlourishWorksheetAddView, self).updateActions()
        self.actions['add'].addClass('button-ok')
        self.actions['cancel'].addClass('button-cancel')
Exemplo n.º 19
0
def setUpDefaultCategories(categories):
    # XXX: We werestoring zope.i18nmessageid.message.Message in ZODB...
    #      I'm not changing the behaviour at this point, but I wonder
    #      if it will bite us or become a common thing in ST.
    categories[u'assignment'] = _('Assignment')
    categories[u'essay'] = _('Essay')
    categories[u'exam'] = _('Exam')
    categories[u'homework'] = _('Homework')
    categories[u'journal'] = _('Journal')
    categories[u'lab'] = _('Lab')
    categories[u'presentation'] = _('Presentation')
    categories[u'project'] = _('Project')
    categories.default_key = u'assignment'
Exemplo n.º 20
0
class IMyGrades(Interface):
    """The students gradebook for a section.

    This interface provides an API that allows the studentto see their
    grades for a section.
    """
    worksheets = zope.schema.List(
        title=_('Worksheets'), description=_('Worksheets in this gradebook.'))

    def getScore(student, activity):
        """Get the score of a student for a given activity."""

    def getCurrentWorksheet():
        """Get the currently active worksheet."""

    def getCurrentActivities():
        """Get the activities for the currently active worksheet."""

    def setCurrentWorksheet(worksheet):
        """Set the currently active worksheet."""
Exemplo n.º 21
0
def getCourseDeployedWorksheets(context):
    '''IAttributeAnnotatable object to ICourseDeployedWorksheets adapter.'''
    annotations = annotation.interfaces.IAnnotations(context)
    try:
        return annotations[COURSE_DEPLOYED_WORKSHEETS_KEY]
    except KeyError:
        worksheets = CourseDeployedWorksheets(_('Deployed Worksheets'))
        annotations[COURSE_DEPLOYED_WORKSHEETS_KEY] = worksheets
        zope.container.contained.contained(
            worksheets, context, 'deployed_worksheets')
        return worksheets
Exemplo n.º 22
0
def getCourseActivities(context):
    '''IAttributeAnnotatable object to ICourseActivities adapter.'''
    annotations = annotation.interfaces.IAnnotations(context)
    try:
        return annotations[COURSE_ACTIVITIES_KEY]
    except KeyError:
        activities = CourseActivities(_('Course Activities'))
        annotations[COURSE_ACTIVITIES_KEY] = activities
        zope.container.contained.contained(
            activities, context, 'activities')
        return activities
Exemplo n.º 23
0
class FlourishCourseWorksheetAddView(flourish.form.AddForm):
    """flourish view for adding a course worksheet."""

    fields = field.Fields(ICourseWorksheet).select('title')
    template = InheritTemplate(flourish.page.Page.template)
    label = None
    legend = _('Course Worksheet Details')

    @property
    def title(self):
        return self.context.__parent__.title

    @button.buttonAndHandler(_('Submit'), name='add')
    def handleAdd(self, action):
        super(FlourishCourseWorksheetAddView,
              self).handleAdd.func(self, action)

    @button.buttonAndHandler(_("Cancel"))
    def handle_cancel_action(self, action):
        url = absoluteURL(self.context, self.request)
        self.request.response.redirect(url)

    def create(self, data):
        worksheet = CourseWorksheet(data['title'])
        return worksheet

    def add(self, worksheet):
        chooser = INameChooser(self.context)
        name = chooser.chooseName(worksheet.title, worksheet)
        self.context[name] = worksheet
        self._worksheet = worksheet
        return worksheet

    def nextURL(self):
        return absoluteURL(self._worksheet, self.request)

    def updateActions(self):
        super(FlourishCourseWorksheetAddView, self).updateActions()
        self.actions['add'].addClass('button-ok')
        self.actions['cancel'].addClass('button-cancel')
Exemplo n.º 24
0
 def terms(self):
     result = [{
         'name': '',
         'title': _('-- Entire year --'),
         'selected': 'selected',
     }]
     for term in listTerms(self.schoolyear):
         result.append({
             'name': term.__name__,
             'title': term.title,
             'selected': '',
         })
     return result
Exemplo n.º 25
0
 def templates(self):
     result = [{
         'name': '',
         'title': _('-- Select a template --'),
         'selected': 'selected',
     }]
     for template in self.activities(self.course).values():
         result.append({
             'name': template.__name__,
             'title': template.title,
             'selected': '',
         })
     return result
Exemplo n.º 26
0
def ensureAtLeastOneWorksheet(worksheets, factory=None, title=None):
    # only create new worksheet if no personal
    # worksheet (hidden or not) is found
    for worksheet in worksheets.all_worksheets:
        if not worksheet.deployed:
            return
    if factory is None:
        factory = Worksheet
    if title is None:
        title = _('Sheet1')
    sheet1 = factory(title)
    chooser = INameChooser(worksheets)
    name = chooser.chooseName('', sheet1)
    worksheets[name] = sheet1
Exemplo n.º 27
0
 def validate(self, value):
     scoresystem = self.context.get('scoresystem')
     if not scoresystem:
         raise zope.schema.interfaces.RequiredMissing()
     if (value is not self.field.missing_value and
         not scoresystem.isValidScore(value)):
         raise z3c.form.converter.FormatterValidationError(
             _("${value} is not valid in ${scoresystem}.",
                 mapping={
                     'value': value,
                     'scoresystem': scoresystem.title,
                 }),
             value)
     return z3c.form.validator.SimpleFieldValidator.validate(self, value)
Exemplo n.º 28
0
    def update(self):
        if 'REMOVE' in self.request:
            keys = utility.getWidgetsData(self,
                                          ICategoriesForm,
                                          names=['categories'])['categories']
            if not keys:
                return
            for key in keys:
                del self.categories[key]
            self.message = _('Categories successfully deleted.')

        elif 'ADD' in self.request:
            value = utility.getWidgetsData(self,
                                           ICategoriesForm,
                                           names=['newCategory'
                                                  ])['newCategory']
            if not value:
                return
            name = unicode(value).encode('punycode')
            self.categories[name] = value
            self.message = _('Category successfully added.')

        elif 'CHANGE' in self.request:
            key = utility.getWidgetsData(self,
                                         ICategoriesForm,
                                         names=['defaultCategory'
                                                ])['defaultCategory']
            self.categories.default_key = key
            self.message = _('Default category successfully changed.')

        utility.setUpWidgets(self,
                             self.schema,
                             IInputWidget,
                             initial=self.getData(),
                             ignoreStickyValues=True,
                             names=self.fieldNames)
Exemplo n.º 29
0
class JournalSource(object):

    implements(interfaces.IExternalActivities)

    source = "journalsource"
    title = _('Journal')

    def __init__(self, context):
        self.context = context
        self.activities = [JournalExternalActivity(self)]
        self.__parent__ = context

    def getExternalActivities(self):
        return self.activities

    def getExternalActivity(self, external_activity_id):
        return self.activities[0]
Exemplo n.º 30
0
 def createTerms(self):
     result = []
     scoresystem = self.context.get('scoresystem')
     if not scoresystem:
         return result
     result.append(self.createTerm(
             None,
             z3c.form.widget.SequenceWidget.noValueToken,
             _("Select a score"),
             ))
     for score in scoresystem.scores:
         title = score[0]
         result.append(self.createTerm(
                 score[0],
                 'scr-%s' % unicode(title).encode('punycode'),
                 title,
                 ))
     return result