# -*- coding: utf-8 -*-
# $Id: ECReviewBox.py 835 2007-06-27 15:05:17Z amelung $
#
# Copyright (c) 2007 Otto-von-Guericke-Universität Magdeburg
#
# This file is part of ECReviewBox.
# Zope imports
# Plone imports
#from Products.Archetypes.public import BooleanField
#from Products.Archetypes.public import ReferenceField
#from Products.Archetypes.public import BooleanWidget
#from Products.Archetypes.public import ReferenceWidget
# Other product imports
# DataGridField imports
# Local product imports
try:
# use ECAssignmentBox's schema and modifiy it
# we hide the field assignment_reference because it is
# unsuitable for review boxes
'view' : 'invisible',
'edit' : 'invisible'
}
except Exception, e:
pass
'referencedBox',
#allowed_types_method = 'getAllowedRefTypes',
#searchable = True,
description='All (accepted resp. graded) submissions inside selected assignment box will be used for the peer review',
),
),
'allocations',
#required = True,
#visible = {'view':'invisible', 'edit':'invisible'},
description = """Shows users and allocated assignments from the referenced box""",
columns = {
#'xyz':SelectColumn("Xyz", vocabulary="getXyzVocab"),
},
),
# let only box owner and manager read the data grid
),
'origAsAnswer',
#required = True,
description = 'If selected, the original assignments will be automaticly pasted as answer templates inside this box',
),
),
)) + ECReviewBoxSchema
#finalizeATCTSchema(ECReviewBoxSchema, folderish=True, moveDiscussion=False)
"""Assignments for peer reviewing"""
# -- actions --------------------------------------------------------------
{
'action': "string:$object_url/ecrb_allocations_view",
'id': 'allocations',
'name': 'Allocations',
},
))
'view': 'ecrb_view',
})
# -- methods --------------------------------------------------------------
# overwrite the archetypes edit method
"""
"""
log('xxx: here we ware in manage_afterAdd')
# security.declareProtected(permissions.ModifyPortalContent, 'processForm')
# def processForm(self, data=1, metadata=0, REQUEST=None, values=None):
# """
# """
# BaseFolder.processForm(self, data=data, metadata=metadata,
# REQUEST=REQUEST, values=values)
#
# #log('xxx: here we ware in processForm')
# get the referenced assignment ‚box
"""
Return the submission text for the given user or None, if user_id
isn't in the list of enabled users.
"""
"""
TODO:
"""
"""
Get all (accepted or graded) assignments in the referenced assignment
box and re-assign each submission to a new user.
@param referencedBox: the referenced assignment boxs
"""
if not referencedBox:
return
#log('referencedBox: %s' % repr(referencedBox.getPhysicalPath()))
# lets use the catalog to get all assignments inside the referenced
# assignment box
)
# reset current allocations
self.allocations = []
users = []
submissions = []
subsBackup = []
# walk through all submissions
# get creator's unique name
# add all user to a separate list, this means everyone who submitted
# an assignment takes part at the peer review
# filter only accepted or graded assignments
# get the real object
#path = (hasattr(assignment, 'getPath') and assignment.getPath()) or '/'.join(assignment.getPhysicalPath())
#answer = assignment.getAsPlainText()
#log('creator: %s' % creator)
#log('path: %s' % path)
#log('answer: %s' % answer)
# allow readable submissions only
if answer:
# add all users and submission to another list
'orig_path': path,
'orig_submission': answer,
})
# ensure that 'users' is a list of unique names
#log('unique user list: %s' % repr(users))
# lets dice: user 1 gets the submission of user 2 and so on; the last
# user in the list finally gets the original submission of user 1
allocations = []
# prevent neverending loop if only one submission exists
# in any other case: lets roll the dices
else:
#log('user: %s' % user)
#log('len(submissions): %s' % len(submissions))
subsBackup = []
#log('len(submissions) = %s' % len(submissions))
# ensure that the last remaining pair won't match
"""
if len(submissions) > 0:
row = submissions.pop(0)
submissions.append(row.copy())
if user == row['orig_user']:
row = submissions.pop(0)
submissions.append(row.copy())
row['user'] = user
#log('user: %s | orig_user: %s' % (entry['user'], entry['orig_user']))
allocations.append(row)
"""
#self.allocations = allocations
# that's all there is to it!
return