# Wiki source code of Duncan Result

Last modified by Alexandru Colesnicov on 2019/05/27 16:12
Export
Office Formats
Export as PDF
Other Formats

Select the pages to export:

select all / none

Export as HTML

Show last authors

author | version | line-number | content
--- | --- | --- | ---
1 | {{velocity}}
2 |
3 | #set($class="Duncan1.Code.GDataClass")
4 | #set($template="Duncan1.Code.GDataTemplate")
5 | #set($xwlquery="from doc.object($class) as obj where doc.fullName <> '$template' order by doc.date desc")
6 | ### "$xwlquery"
7 | #set($list=$services.query.xwql($xwlquery).execute())
8 |
9 | {{/velocity}}
10 |
11 | {{python}}
12 |
13 | import sys
14 | print "Python version is ", sys.version
15 | print
16 |
17 | className = "Duncan1.Code.GDataClass"
18 | template = "Duncan1.Code.GDataTemplate"
19 | xwlquery = "from doc.object(" + className + ") as obj where doc.fullName <> \'" + template + "\' order by doc.date desc"
20 | # print "\"%s\"" % xwlquery
21 | # import xwiki
22 | # list = services.query.xwql(xwlquery).execute()
23 |
24 | totalF=0
25 | totalM=0
26 | nPos=list.size()
27 | for item in list:
28 | itemdoc = xwiki.getDocument(item)
29 | nFInPos = itemdoc.getValue('QuaWoman')
30 | nMInPos = itemdoc.getValue('QuaMan')
31 | totalF += nFInPos
32 | totalM += nMInPos
33 | totalFM = totalF+totalM
34 | print "%s records processed\n%s pers. incl. woman: %s; man: %s" % (nPos, totalFM, totalF, totalM)
35 |
36 | iDunc = 0.0
37 | for item in list:
38 | itemdoc = xwiki.getDocument(item)
39 | nFInPos = itemdoc.getValue("QuaWoman")
40 | nMInPos = itemdoc.getValue("QuaMan")
41 | iDunc += abs(nFInPos/float(totalF) - nMInPos/float(totalM))
42 | iDunc *= 0.5
43 | print "Duncan index = %s" % (iDunc)
44 | {{/python}}

# Applications

# Tips

If you're a new XWiki user, check out the Getting Started Guide.

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support

XWiki Debian 11.5