~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/subject.py

  • Committer: William Grant
  • Date: 2009-12-17 04:55:50 UTC
  • mto: This revision was merged to the branch mainline in revision 1450.
  • Revision ID: me@williamgrant.id.au-20091217045550-03vxauhdeixwdie9
Show the worksheet listing with marks and schtuff on the offering index.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
from ivle.webapp.admin.breadcrumbs import (SubjectBreadcrumb,
52
52
            OfferingBreadcrumb, UserBreadcrumb, ProjectBreadcrumb)
53
53
from ivle.webapp.groups import GroupsView
 
54
from ivle.webapp.tutorial import Plugin as TutorialPlugin
54
55
 
55
56
class SubjectsView(XHTMLView):
56
57
    '''The view of the list of subjects.'''
113
114
    permission = 'view'
114
115
 
115
116
    def populate(self, req, ctx):
 
117
        # Need the worksheet result styles.
 
118
        self.plugin_styles[TutorialPlugin] = ['tutorial.css']
116
119
        ctx['context'] = self.context
117
120
        ctx['req'] = req
118
121
        ctx['permissions'] = self.context.get_permissions(req.user)
120
123
        ctx['format_datetime'] = ivle.date.make_date_nice
121
124
        ctx['format_datetime_short'] = ivle.date.format_datetime_for_paragraph
122
125
 
 
126
        # As we go, calculate the total score for this subject
 
127
        # (Assessable worksheets only, mandatory problems only)
 
128
 
 
129
        ctx['worksheets'], problems_total, problems_done = (
 
130
            ivle.worksheet.utils.create_list_of_fake_worksheets_and_stats(
 
131
                req.store, req.user, self.context))
 
132
 
 
133
        ctx['exercises_total'] = problems_total
 
134
        ctx['exercises_done'] = problems_done
 
135
        if problems_total > 0:
 
136
            if problems_done >= problems_total:
 
137
                ctx['worksheets_complete_class'] = "complete"
 
138
            elif problems_done > 0:
 
139
                ctx['worksheets_complete_class'] = "semicomplete"
 
140
            else:
 
141
                ctx['worksheets_complete_class'] = "incomplete"
 
142
            # Calculate the final percentage and mark for the subject
 
143
            (ctx['exercises_pct'], ctx['worksheet_mark'],
 
144
             ctx['worksheet_max_mark']) = (
 
145
                ivle.worksheet.utils.calculate_mark(
 
146
                    problems_done, problems_total))
 
147
 
123
148
 
124
149
class UserValidator(formencode.FancyValidator):
125
150
    """A FormEncode validator that turns a username into a user.