Commit 90de2338 authored by Xueyun Qian's avatar Xueyun Qian

added action "clone templates and assign to students", updated category...

added action "clone templates and assign to students", updated category pattern, changed answer set workflow so that from submitted for peer review can be archived
parent 10e5eebf
......@@ -6,6 +6,14 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ZCacheManager_ids__</string> </key>
<value>
<tuple>
<string>Organisation_cloneTemplatesAndAssignToStudents</string>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
......
......@@ -64,11 +64,10 @@ peer_reviewer_li = []\n
student_li = []\n
students = []\n
answer_set_li = []\n
answer_set_total_li = []\n
\n
student_li = context.getSubordinationRelatedValueList (portal_type = "Person")\n
\n
for student in student_li:\n
#students.append(student.getRelativeUrl())\n
for answer_set in portal_catalog(\n
portal_type = "Answer Set",\n
default_source_uid = student.getUid(),\n
......@@ -101,6 +100,7 @@ if len(duplicate) > 0:\n
translateString = portal.Base_translateString\n
return context.Base_redirect(\'view\', keep_items=dict(portal_status_message=translateString("One or more students submitted more than one answer set, please archive duplicates before assign peer reviewer")))\n
\n
\n
#check if all answer sets already have peer reviewer\n
elif len(answer_set_li) == 0:\n
translateString = portal.Base_translateString\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
portal_catalog = portal.portal_catalog\n
Base_translateString = portal.Base_translateString\n
import random\n
#context.getUid()\n
students = []\n
student_list = []\n
answer_set_list = []\n
master_template_list = []\n
old_template_list = []\n
template_list = []\n
\n
#first get all students belong to this organisation\n
student_list = context.getSubordinationRelatedValueList(portal_type = "Person")\n
#get the total number of students\n
number_of_students = len(student_list)\n
\n
for student in student_list:\n
students.append(student.getRelativeUrl())\n
\n
#get the master template answer sets \n
for answer_set in portal_catalog( portal_type = "Answer Set",\n
pattern_relative_url = "pattern/peer_review/master_template"):\n
master_template_list.append(answer_set)\n
number_of_master_templates = len(master_template_list)\n
\n
#get already existing templates\n
for answer_set in portal_catalog( portal_type = "Answer Set", \n
pattern_relative_url = "pattern/peer_review/template"):\n
if not answer_set.getDestinationDecision():\n
old_template_list.append(answer_set)\n
number_of_old_templates = len(old_template_list) \n
\n
if number_of_old_templates >= number_of_students:\n
new_template_list = random.sample(old_template_list, number_of_students)\n
for answer_set in new_template_list:\n
random_person = random.choice(students)\n
answer_set.setDestinationDecision(random_person)\n
students.remove(random_person)\n
\n
translateString = portal.Base_translateString\n
return context.Base_redirect(\'view\', keep_items=dict(portal_status_message=translateString("Some templates already exist, the rest are cloned and assigned to students"))) \n
\n
else:\n
#define the number of templates to clone for each master template\n
number_difference = number_of_students - number_of_old_templates \n
number_of_templates_to_clone = float(number_difference) / float(number_of_master_templates)\n
int_number_of_templates_to_clone = round(number_of_templates_to_clone)\n
\n
for answer_set in master_template_list:\n
for i in range (0,int(int_number_of_templates_to_clone)):\n
clone = answer_set.Base_createCloneDocument(batch_mode=1)\n
clone.submitForPeerReview() #set all the template answer set state to be "submitted for peer review"\n
clone.setVersion("002") #set all the template answer set version to be "002" since the peer review process starts after the first review\n
clone.setPattern("peer_review/template")\n
template_list.append(clone)\n
\n
if int_number_of_templates_to_clone < number_of_templates_to_clone:\n
another_template = random.choice(master_template_list)\n
clone_again = another_template.Base_createCloneDocument(batch_mode=1)\n
clone_again.submitForPeerReview()\n
clone_again.setVersion("002")\n
clone_again.setPattern("peer_review/template")\n
template_list.append(answer_set)\n
\n
for student in students:\n
total_templates = template_list + old_template_list\n
new_template_list = random.sample(total_templates, number_of_students)\n
for answer_set in new_template_list:\n
random_person = random.choice(students)\n
answer_set.setDestinationDecision(random_person)\n
students.remove(random_person)\n
\n
translateString = portal.Base_translateString\n
return context.Base_redirect(\'view\', keep_items=dict(portal_status_message=translateString("Templates cloned and assigned to students")))\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Organisation_cloneTemplatesAndAssignToStudents</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -28,6 +28,8 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>archive</string>
<string>archive_action</string>
<string>request_from_peer_review</string>
<string>request_from_peer_review_action</string>
</tuple>
......
95
\ No newline at end of file
96
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment