Preparing for a new Experiment Interface

After my last note on rails I took a long break, in order to critique two texts (of which Cognitive Development is the first), attend the Boyd Conference, and generally relax. But a month is long enough to go without work on what will now be the technological basis for the next installment of the Wary Guerrilla / Wary Student research program.


An Experiment with a Question List

Today’s work focused laid the foundations for a completely revamped experiment feature. Before, the experiment feature only dropped the user straight into a note-taking interface. Now, question lists are being integrated so that an entire battery can be given through the interface. The task is not completed today — indeed, all that was accomplished was presenting one question list instead of the notetaknig matrix — but it’s a start

After thanking the websites of continuous thinking, hokudai, rubyinside, and rubyonrails more practical help, read below the fold for implementation details…


A number of things being done today. The main thing is allowing the student to actually take the full experiment, and that requires keeping track of what questionlist the student is currently on. To do that, we will alter the study model to have a current_question_list field

ruby script/generat migration alter_student_add_current_question_list

And then for 025_alter_student_add_current_question_list.rb

class AlterStudentAddCurrentQuestionList < ActiveRecord::Migration
def self.up
add_column :students, :current_question_list, :integer, :default => 0
end

def self.down
remove_column :students, :current_question_list
end
end

Now in the student model, add code to retrieve the next question list

In student.rb

def self.find_next_question_list(condition_id,current_question_list)
to_find = QuestionListCondition.find(
:first,
:conditions=> [ ‘condition_id = ? AND ordering > ?’, condition_id, current_question_list ],
:order => ‘ordering ASC’
)

@to_return = to_find.question_list_id
end

In question.rb

def self.find_by_question_list_id(question_list_id)
@questions = find(:all,:conditions => [‘list_id = ?’,question_list_id], :order => "ordering ASC"
end

def self.find_question_options_array(question_id)
@options = QuestionOption.find(:all,:conditions=>[‘question_id = ?’, question_id], :order => ‘display_text ASC’)
end

def self.find_question_options_map(question_id)
@options = find_question_options_array(question_id).map {|u| [u.display_text, u.id] }
end

From student_controller.rb, update the following functions:

def select_condition_from_experiment
selected_experiment_id = params[:selected_experiment][:experiment_id]
@conditions = Condition.find_conditions(selected_experiment_id)
render :partial => "select_condition"

@student = Student.new(params[:student])
@student.save
session[:student] = @student.id;

end

def select_notes_from_condition
@student = Student.find(session[:student])
@student.condition_id = params[:student][:condition_id]
@student.save

@next_question_list = Student.find_next_question_list(@student.condition_id,@student.current_question_list)
@student.current_question_list = @next_question_list
@questions = Question.find_by_question_list_id(@student.current_question_list)

render :partial => "question_list_view"
#render_text @next_question_list

#@notes_fields = NotesField.find_by_condition(@student.condition_id)
#@notes_records = NotesRecord.find_by_condition(@student.condition_id)
#render :partial => "notes_view"
end

create the new file app/views/students/_question_list_view.rhtml

<h1>Question List Page</h1>
<%= form_remote_tag(
:update => "notetaking_display",
:url => { :action => :save_student_notes },
:position => "top" )
%>
<% for question in @questions %>
<p><h3><%= question.display_text %></h3>

<% if question.type_id == QuestionType::STRING %>
<%= text_field("question",question.id) %>
<% end %>

<% if question.type_id == QuestionType::TEXT %>
<%= text_area("question",question.id) %>
<% end %>

<% if question.type_id == QuestionType::SELECTION %>
<% @options = Question.find_question_options_map(question.id) %>
<%= select :question, question.id, @options %>
<% end %>

<% if question.type_id == QuestionType::CHECKBOX %>
<% @options = Question.find_question_options_array(question.id) %>
<% for option in @options %>
<%= check_box("question",question.id) %><%= option.display_text %>

<% end %>
<% end %>

<% if question.type_id == QuestionType::RADIO %>
<% @options = Question.find_question_options_array(question.id) %>
<% for option in @options %>
<%= radio_button("question",question.id,option.id) %><%= option.display_text %>

<% end %>
<% end %>

<% if question.type_id == QuestionType::INSTRUCTION %>

<% end %>

</p>
<% end %>
<%= end_form_tag %>

Update _select_condition.rhtml

<%= form_remote_tag(:update => "notetaking_display",
:url => { :action => :select_notes_from_condition },
:position => "top" ) %>
Your Condition: <%= select :student, :condition_id, @conditions %>
<%= submit_tag "Select Condition" %>

<%= end_form_tag %>

The index.rhtml in the same folder was also updated:

<html>
<head>
<title>Notes on Rails Mock Student Interface</title>
<%= javascript_include_tag "prototype" %>
</head>
<body>
<h3>Add to list using Ajax</h3>
<%= form_remote_tag(:update => "login_with_condition",
:url => { :action => :select_condition_from_experiment },
:position => "top" ) %>

<p><label for="student_name">Your Name</label><br/>
<%= text_field ‘student’, ‘name’ %>
<br />Your Experiment:
<%= select :selected_experiment, :experiment_id, @experiments %>
<%= submit_tag "Select Experiment" %></p>

<%= end_form_tag %>

<div id="login_with_condition"></div>
<div id="notetaking_display"></div>
</body>
</html>

Cognitive Development, Part I: Introduction

This is my first reaction paper for Cognitive development: Fourth edition by Flavell, Miller, & Miller (2002). In their first chapter, “Introduction,” they discuss the theories of Jean Piaget and the major research programs which owe a lot to him: the neo-piagetian, information processing, biological perspectives, theory theory, dynamic systems, and sociocultural approaches. Rather than summarizing the material in the chapter, which would be about as interesting as the preceding two sentences, I will confess my bias and outline my perspective, tying these as needed to the book’s contents.

I do not believe that people have good reasons for their actions. I do not believe that people are rational agents, that they create and test scientific theories, or that their self-conceptions matter most of the time. I think this is all for the best, as the limited cognitive resources of homo sapiens make them terrible decision makers. Humans make their best actions when they do not have to labor over decision making and instead trust their orientation state – their gut. Verbal discourse exists primarily to get people to do things against their own interests. It is a relic of the group-selection events that formed our species. Intuition, by contrast, is how we and every animal actually live.


My preferred model of cognition is the Observe-Orient-Decide-Act (OODA) loop originally devised by John Boyd (Fadok, Boyd, & Warden, 1995) for the United States Air Force and now in use by the Marine Corps and Navy. The OODA loop is a variation of information-processing theory influenced by biological approaches (Richards, 2002). Applicants of OODA loop theory are urged to avoid the decision-making state when possible by allowing orientation to guide action.

Flavell, Miller, & Miller’s introductory chapter provide support the OODA perspective. The Neo-Pagetian Robbie Case rejects Piaget’s stages of operational development in favor of four phases, culminating in “integrated dimensional” thinking (11; Case & Okamoto, 1996). These are stages of narrative complexity and storytelling. That one thinks in an “integrated dimensional” manner does not make one a rational agent, but rather capable of following more complex myths and ideologies. Likewise, information processing theories work best by describing how resource constraints hamper cognition. Not surprisingly, the limited capacity of human thinkers is an old but still productive field of study (Miller, 1956; Paas & Kester, 2006). For their part, biological researches have shown that traits from preferred mate smell (Jacob, McClintock, Zelano, & Ober, 2002) to political orientation are genetically heritable (Alford, Funk, & Hibbing, 2005). If indeed these are rationally constructed, then the rational self must hold prejudices that strongly influence the outcome. Similarly, the main-take away of the sociocultural theorists is that social interaction rather than personal reflect leads to better results. Sociocultural theory, originating in the needs of the Communist Party of the Soviet Union at the time of Stalin, emphasizes the pre-modern concept of apprenticeship. As Rogoff (1990,40; Flavell, Miller, & Miller, 2002, 24) writes, “Apprenticeships provide the beginner with access to both the overt aspects of the skill and the more hidden inner processes of thought.” In other words, apprenticeships offload thinking, so that rational reflection is not needed in the period between when the skill is presented and when it is automatized.

To be fair. some of the frameworks presented by the chapter do not fit into such a view. Theory theory, for instance, posits that while developing, “children continually test [their] intuitive theories, like a scientist, in light of their experiences [and] that children’s theories are abstract, coherent, and internally consistent” (20-21). A different post-piagetian perspective, dynamic systems, holds that “one can understand where a new behavior comes from… only by looking at the overall pattern, at both previous and current events, and at many levels of causation” (22). For different reasons I reject both of these contributions. Theory theory is simply too generous. Children are desperately short of the prior knowledge, working memory capacity, and attention that are required for the thinking of a scientist. Scientific thinking is an advanced form of cognition (see Moshman, 2005), not an early one. As to dynamic systems, I have been previously exposed to this perspective (Bloom, 2000) and I recognize that it has a lot to offer. However, the multiplication of variables is a scientific stand of last resort, and not appropriate for a still-blossoming field such as developmental psychology.

I am looking forward to the next eight chapters of Cognitive Development. My primary interest is in advanced psychological development, but I expect the material in this book to provide the perspective that will allow me to cement my views within a broader context of development.


Cognitive Development, a tdaxp series
1. Introduction
2. Infant Perception
3. Infant Cognition
4. Representation and Concepts
5. Reasoning and Problem Solving
6. Social Cognition
7. Memory
8. Language
9. Questions and Problems
10. Bibliography