Editorial Workflows

survey

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: This workflow has no description.

Shared by: brohenry

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
datetime
Value
Year: 2001-Month: 01-Day: 01THour: 01 (24h)-Minute: 01-Second: 01
Set Variable ?
Variable Name
filename
Value
survey-datetime
Get File Contents ?
File Name
%var:filename
In Dropbox
OFF
If File Does Not Exist
  • Empty Output
  • Stop Workflow
Set Variable ?
Variable Name
survey
Value
Input
Set Variable ?
Variable Name
stats
Value
{"1":0,"2":0,"3":0,"4":0,"5":0}
Set Variable ?
Variable Name
stats_summary
Value
no votes yet
Custom UI ?
User Interface
Presentation Style
  • Sheet
  • Full-Screen
  • Popover
Output
Use Editor Theme
ON
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import json

action_in = workflow.get_input()
stats = workflow.get_variable('stats')
stats = json.loads(stats)
total = stats['1'] + stats['2'] + stats['3'] + stats['4'] + stats['5']
average = (stats['1'] + stats['2'] * 2.0 + stats['3'] * 3 + stats['4'] * 4 + stats['5'] * 5) / total
summary = "average: " + str(average) + "  count " + str(stats['1']) + ", " + str(stats['2']) + ", " + str(stats['3']) + ", " + str(stats['4']) + ", " + str(stats['5'])
print(stats)
workflow.set_variable('stats_summary',summary)

#TODO: Generate the output...
action_out = action_in

workflow.set_output(action_out)
Generate Text ?
Text
stats_summary output
Set File Contents ?
File Name
%var:filename
In Dropbox
OFF
New Text
survey datetime Input
If File Does Not Exist
  • Create
  • Stop Workflow
Open Document ?
File Name
%var:filename
In Dropbox
OFF