Repository: carpentries/amy

Issue:
Integration with SurveyMonkey
In this issue I want to gather all functionalities users want.



Discussion:
First thought --
I'd like three fields that hold the links to the survey results for that specific event. (pre, post, longterm)

Right now those links themselves have to be manually generated.  I'm not sure if it is possible to automate that -- but that would be ideal.

I'll add more as I think of things.

Posted by @maneesha in older issue:

> […] now that we are using Survey Monkey I'd like fields that just hold the survey results. This would be 5 > fields for the 5 surveys we're planning on using:
> Learner pre & post
> Instructor pre & post
> Learner Longterm

and:

> I was thinking these would be manually entered. So we'd just need 5 text fields validated to hold hyperlinks.


Resolving patch:
diff --git a/workshops/forms.py b/workshops/forms.py
--- a/workshops/forms.py
+++ b/workshops/forms.py
@@ -275,10 +275,22 @@ def __init__(self, *args, **kwargs):
         # wrap <div class='panel-body'> within <div class='panel panel-…'>
         self.helper[idx_start].wrap_together(Div,
                                              css_class='panel panel-default')
-        # add <div class='panel-heading'>Venue details</div> inside "div.panel"
+        # add <div class='panel-heading'>Loc. details</div> inside "div.panel"
         self.helper.layout[idx_start].insert(0, Div(HTML('Location details'),
                                                     css_class='panel-heading'))
 
+        id_learners_pre = self.helper['learners_pre'].slice[0][0][0]
+        id_learners_longterm = self.helper['learners_longterm'].slice[0][0][0]
+        # wrap all survey fields within <div class='panel-body'>
+        self.helper[id_learners_pre:id_learners_longterm + 1] \
+            .wrap_together(Div, css_class='panel-body')
+        # wrap <div class='panel-body'> within <div class='panel panel-…'>
+        self.helper[id_learners_pre].wrap_together(
+            Div, css_class='panel panel-default')
+        # add <div class='panel-heading'>Venue details</div> inside "div.panel"
+        self.helper.layout[id_learners_pre].insert(
+            0, Div(HTML('Survey links'), css_class='panel-heading'))
+
     def clean_slug(self):
         # Ensure slug is not an integer value for Event.get_by_ident
         data = self.cleaned_data['slug']
@@ -307,7 +319,9 @@ class Meta:
         fields = ('slug', 'completed', 'start', 'end', 'host', 'administrator',
                   'tags', 'url', 'reg_key', 'admin_fee', 'invoice_status',
                   'attendance', 'contact', 'notes',
-                  'country', 'venue', 'address', 'latitude', 'longitude')
+                  'country', 'venue', 'address', 'latitude', 'longitude',
+                  'learners_pre', 'learners_post', 'instructors_pre',
+                  'instructors_post', 'learners_longterm')
         # WARNING: don't change put any fields between 'country' and
         #          'longitude' that don't relate to the venue of the event
 
diff --git a/workshops/migrations/0068_auto_20160119_1247.py b/workshops/migrations/0068_auto_20160119_1247.py
new file mode 100644
--- /dev/null
+++ b/workshops/migrations/0068_auto_20160119_1247.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('workshops', '0067_person_username_regexvalidator'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='event',
+            name='instructors_post',
+            field=models.URLField(verbose_name='Pre-workshop assessment survey for instructors', blank=True, default=''),
+        ),
+        migrations.AddField(
+            model_name='event',
+            name='instructors_pre',
+            field=models.URLField(verbose_name='Pre-workshop assessment survey for instructors', blank=True, default=''),
+        ),
+        migrations.AddField(
+            model_name='event',
+            name='learners_longterm',
+            field=models.URLField(verbose_name='Long-term assessment survey for learners', blank=True, default=''),
+        ),
+        migrations.AddField(
+            model_name='event',
+            name='learners_post',
+            field=models.URLField(verbose_name='Post-workshop assessment survey for learners', blank=True, default=''),
+        ),
+        migrations.AddField(
+            model_name='event',
+            name='learners_pre',
+            field=models.URLField(verbose_name='Pre-workshop assessment survey for learners', blank=True, default=''),
+        ),
+    ]
diff --git a/workshops/models.py b/workshops/models.py
--- a/workshops/models.py
+++ b/workshops/models.py
@@ -623,6 +623,23 @@ class Event(AssignmentMixin, models.Model):
         help_text="Indicates that no more work is needed upon this event.",
     )
 
+    # links to the surveys
+    learners_pre = models.URLField(
+        blank=True, default="",
+        verbose_name="Pre-workshop assessment survey for learners")
+    learners_post = models.URLField(
+        blank=True, default="",
+        verbose_name="Post-workshop assessment survey for learners")
+    instructors_pre = models.URLField(
+        blank=True, default="",
+        verbose_name="Pre-workshop assessment survey for instructors")
+    instructors_post = models.URLField(
+        blank=True, default="",
+        verbose_name="Pre-workshop assessment survey for instructors")
+    learners_longterm = models.URLField(
+        blank=True, default="",
+        verbose_name="Long-term assessment survey for learners")
+
     class Meta:
         ordering = ('-start', )
 


Test patch: