Saving Simple Survey Data

Saving survey data from the notesonrails application is not just a matter of adding something new — it also involves destroying something old. Today’s work doesn’t get us a completely functional system, but it migrates the system from a “notes” to a “survey response” method of saving data, and lays the groundwork for more tomorrow…

The old notes model is built on the idea that all instrument data involves the following structure


However, now that notes are just detailed questions, a better format would be


On one level this replaces record/field with questionlist/question as the primary identifier of where data comes from. Field and record can now be used by other purposes as well.

First, generate a model for the new survey_responses

ruby script/generate model survey_response

This creates 027_create_survey_responses.db, which should be altered to read (recall the ID is created manually):

class CreateSurveyResponses < ActiveRecord::Migration
def self.up
create_table :survey_responses do |t|
t.column :student_id, :integer
t.column :question_list_id, :integer
t.column :question_id, :integer
t.column :field_identifier, :integer
t.column :record_identifier, :integer
t.column :survey_text, :string

def self.down
drop_table :survey_responses

And next, delete the old notes table

ruby script/generate migration dump_notes

The new file that creates, 028_dump_notes.rb, should read (now that we entered the current description of the notes table in case we want to undo this)

class DumpNotes < ActiveRecord::Migration
def self.up
drop_table :notes

def self.down
create_table :notes do |t|
t.column :student_id, :integer
t.column :notetext, :string
t.column :notes_field_id, :integer
t.column :notes_record_id, :integer

And then, rake db:migrate

Good. The next part is just relatively straightforward: update the students controller to actually save information.

And in the _notes_view.rhtml partial, you’ll need to add lines to identify the detailed data of the notes survey responses, as well as getting rid of the old and redundant ajax code from prevoius days:

<table border="1">
<td>  </td>
<% for notes_record in @notes_records %>
<td><%= h( %></td>
<% end %>
<% for notes_field in @notes_fields %>
<td><%= %></td>
<% for notes_record in @notes_records %>
<td><%= text_area h(, h(, :cols => 20, :rows => 8 %></td>
<br /><%= hidden_field_tag ‘field_’ +, %>
<br /><%= hidden_field_tag ‘record_’ +, %>
<% end %>
<% end %>

For its part, the relevent section of _question_types.rhtml changes hardly at all:

<% if question.type_id == QuestionType::NOTES_MATRIX or question.type_id == QuestionType::NOTES_LINEAR %>
<br />Before, we go father, question is <%= %>
<% @notes_fields = NotesField.find_by_condition(@student.condition_id) %>
<% @notes_records = NotesRecord.find_by_condition(@student.condition_id) %>
<%= hidden_field_tag "question_" + %>
<%= render :partial => "notes_view", :locals => {:question => question } %>
<% end %>

Likewise, modify students_controller.rb so it starts like this:

def run_experiment
@student = Student.find(session[:student])

unless @student.condition_id
@student.condition_id = params[:student][:condition_id]

## Saving data goes here
@questions = params[:question]
if (@questions)
for question in @questions
question_number = question[0]
question_data = question[1]

question_field = params[‘field_’ + question_number]
question_record = params[‘record_’ + question_number]

@survey_response =
:student_id =>,
:question_list_id => @student.current_ordering,
:question_id => question_number,
:field_identifier => question_field,
:record_identifier => question_record,
:survey_text => question_data
## stop saving data here

There’s still stuff to do. Complicated form data, such as checkboxes, are not saved correctly, and the notes are still not saved at all. But it’s a start

Over-hypped, if not imaginary

The mainstrea media is so locked into its liberal v. conservative stupidity that often real stories are not told, because they do not fit some stereotype of what political debate should be. Fortunately, youtube journalists (the video equiavalent of bloggers) have stepped up. I agree with My Everything that the threat Bush cites is overypped, if not imaginary.

Everything has covered previous Bush press conferences before, as well as Attorney General Gonzales’s disturbing testimony before the House of Representatives.

DHCP for Windows Home Server

Did Brendan of I Hate Linux just write the world’s first .Net DHCP server?


He seems to think so:

Not long ago I got done confirming some last minute changes for an early build of the quasi-secret project I’d mentioned here previously… but now I can say that it’s done (enough for now) and that project is: DHCP Server for Windows Home Server, and In the hopes of getting some last minute feedback before I record my video and ship it off for entry in the Code2Fame Challenge I’ve shared it over on the Windows Home Server forums…

I’ll grant you that a DHCP Server isn’t very sexy… but it does have something very unique that I think is worth bragging about… as far as I can tell DHCP4WHS is the first and only DHCP server written in C# and/or for the .NET Framework.

Congrats Brendan!


News from Adrian (a517d0gg):

There has been an RFI on recent changes to my romantic status.

On Sunday, August 5th, I asked Ruth, my girlfriend, to marry me, and she said yes. Actually I didn’t really ask her, I just slipped the ring on her finger while we were watching our little bonfire down at the beach in the Finger Lakes. I guess I don’t have the panache of TDAXP, but then again if I had asked her on my blog she never would have seen the question! We’ll get married next summer.

We are planning to have the reception at the Rochester Science Museum. A cocktail hour in a room with a wooly mammoth in the middle – I’m excited.

Now back to your regular programming (of political rants and soccer videos).


Adolescent Psychological Development, Part I: Cognitive Development

My reaction to David Moshman’s Adolescent Psychological Development (2005) is of a different sort than my nine-part reaction to Cognitive Development by Flavell, Miller, & Miller. There, I found parts of the chapter that interested me and typically criticized it, sometimes throwing in articles I was already familiar with in the process. The reason for this is that I am not all that interested in child cognitive development. Children start out small and cute and whiny and, unless they are horribly mistreated, seem to end up all right in the end.

The same is not true of adults, and adolescents certainly are adults. Indeed, it’s not clear if adults actually can be all right at all. Moshman nears his conclusion by writing “Objectivity, in this view, is a guiding ideal, not an achievable goal” (46) and much of the chapter is written in the rhetoric of limitation. I agree with this approach. Man is a flawed species, and educational psychologists must embrace those flaws to device a truly human education.

Adolescent Psychological Development (the field and the book) properly centers on two concepts: rationality and rational agency. To the best of my understanding, I agree completely with Moshman’s description of both rationality and rational agency. If I do have a disagreement with Moshman, it is this: the latter is not necessary for the former.

“Rationality, in its oldest, broadest and deepest sense,” Moshman (16) writes, “is a matter of having good reasons for one’s beliefs and actions.” This rationality “consists in large part of appropriately applying and coordinating our various reasoning processes” (25). Clearly agreeing with certain theoriests, Moshman on the same page writes that they “see metacognition, broadly construed, as central to rationality” and concludes two pages later that “The development of rationality, as suggested in the previous section, is in large part the development of metacognition.”

Moshman describes a “rational agent” as “an individual who uses epistemic cognition to engage in reasoning” (25). Epistemic cognition is “knowledge about the fundamental nature and justifiability of knowledge and inference” (27). Therefore, a rational agent is he who uses knowledge about knowledge to determine what is true and what is false, or put another way a rational agent is he who justifies his beliefs with a developed argument.

Rationality is thus executive control over one’s cognition, whereas rational agency is rational control over one’s belief. Rational agency is an extension of rational agency, and might even be considered a domain-specific application of rationality. However, (and here I believe I disagree with Moshman) it should not be assumed that rationality agency, whether engaged in or encouraged in others, is itself rational. Rather, if belief formation is under rational control then one must have good reasons why one must have good reasons, or at least better reasons to rely on good reasons than not to rely on them with respect to belief formation. The literature does not support such a stance.

A first approach to the question, is it rational to rely on rational agency, would be to determine if people who have good reasons for their actions in some domain are better than those who do not. Published articles with titles such as “Thinking too much: introspection can reduce the quality of preferences and decisions” (Wilson & Schooler, 1991) suggest, at least when beliefs involve outcomes that actually matter, there is such a thing as too much thought. A concrete example is an experiment where students were allowed to take a poster for free, but one in condition had to present reasons why they chose the poster they did (Wilson, et al. 1993). This rational agency condition resulted in lower satisfaction than was otherwise the case.

Camerer, Loewenstein, & Prelec (2005) divided cognition into four “quadrants”, with “cognitive” and “affective” as columns and “controlled processes” and “automatic processes” as rows (16). Rational agents, desiring to control their reasoning, would be left with one of only four of these quadrants to work with. Yet there is much to life beyond controlled cognition! Automaticity, the movement of thinking in a domain from controlled via “repeated rehearsals” (Cramer, 2006, 4), has been demonstrating in many fields of thought (Morris, Taber, & Lodge., 2003). The role of automaticity in expertise is beyond argument. However, affect is also important. Affect, or emotions broadly defined, combined both information about a task and a utility assessment of the worth of the task. Better to have access to expertise, information, and utility than to be a mere rational agent. Better to exploit all your cognition than just one quadrant of it.

The goal of this first reaction on Adolescent Psychological Development is to describe rationality and rational agency, and begin the work of separating the two concepts. The next thee sections of the book, “Moral Development,” “Identity Formation,” and “Advanced Psychology Development,” will provide the framework for more in-depth discussion of rationality and the benefits of irrational agency. These reactions will build to a discussion of rational moral personhood, the development of which is the proper goal of education.

Adolescent Psychological Development, a tdaxp series
1. Cognitive Development
2. Moral Development
3. Identity Formation
4. Advanced Psychological Development
5. Bibliography