Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
vmichnowicz committed Mar 31, 2012
2 parents 785b957 + 791b918 commit 3a81521
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 86 deletions.
23 changes: 18 additions & 5 deletions README.md
Expand Up @@ -8,19 +8,32 @@ VWM Surveys is licensed under the [Apache 2 License](http://www.apache.org/licen

## Change Log

### 0.3.5

* Added URL encoding for checkbox, radio matrix, and radio question types

### 0.3.4

* Fixed MySQL default value bug for survey questions

### 0.3.3

* Updated datepicker formating for date question type
* Fixed MySQL default value bug for survey pages

### 0.3.2

* Adding "Guests" member group to prevent PHP error on survey submissions page
* Adding "Guests" member group to prevent PHP error on survey submissions page

### 0.3.1

* Fixed date question type issues (If you are upgrading from an earlier version you will have to open up each survey and re-save it...)
* Added "Enter-to-add" functionality for radio matrix question type
* Fixed date question type issues (If you are upgrading from an earlier version you will have to open up each survey and re-save it...)
* Added "Enter-to-add" functionality for radio matrix question type

### 0.3

* Fixed compatibility issues with EE 2.3
* Using PHP DateTime object features (requires PHP 5.3 or greater)
* Fixed compatibility issues with EE 2.3
* Using PHP DateTime object features (requires PHP 5.3 or greater)

## Beta

Expand Down
48 changes: 44 additions & 4 deletions javascript/mcp.js
Expand Up @@ -185,11 +185,51 @@ $('.toggle > a').click(function() {
});

/**
* jQuery UI datepicker
* jQuery UI datepicker for date question type
*/
$('.datepicker').datepicker({
altFormat: $.datepicker.W3C
});
(function() {
var datepickers = $('li.vwm_date .datepicker'); // All date question type datepickers
var date_format_selects = $('li.vwm_date select.vwm_date_format'); // All date question type date format selectors

// Update all datepickers for date question type
var update_date_format = function update_date_format() {
$(datepickers).each(function() {

var li = $(this).closest('li');
var date_format_select = $(li).find('select.vwm_date_format').val();
var date_format = '';

switch (date_format_select) {
// YYYY-MM-DD
case 'YYYY-MM-DD':
date_format = 'yy-mm-dd'
break;
// DD-MM-YYYY
case 'DD-MM-YYYY':
date_format = 'dd-mm-yy'
break;
// Default to MM-DD-YYYY
default:
date_format = 'mm-dd-yy'
break;
}

$(this).datepicker('destroy');

$(this).datepicker({
dateFormat: date_format
});

});

return update_date_format;
}();

// Update datepicker whenever format changes
$(date_format_selects).live('change', function() {
update_date_format();
});
})();

/**
* Toggle select groups multiselect
Expand Down
63 changes: 35 additions & 28 deletions mcp.vwm_surveys.php
Expand Up @@ -49,7 +49,7 @@ public function __construct()
$this->EE->load->helper('vwm_surveys');

// Load config files for all question types
foreach ( $this->question_types() as $slug => $name)
foreach ( $this->get_question_types() as $slug => $name)
{
$this->EE->load->helper('vwm_' . $slug);
}
Expand All @@ -62,7 +62,7 @@ public function __construct()
* @access private
* @return array
*/
private function question_types()
private function get_question_types()
{
// If our question types have not yet been loaded
if ( ! self::$question_types )
Expand Down Expand Up @@ -263,7 +263,7 @@ public function edit_survey()
));

// Load JS for all question types
foreach ($this->question_types() as $slug => $name)
foreach ($this->get_question_types() as $slug => $name)
{
$this->EE->cp->load_package_js('vwm_' . $slug);
}
Expand All @@ -274,7 +274,7 @@ public function edit_survey()
$data = $this->EE->vwm_surveys_m->get_survey_details($survey_id);
$data['action_url'] = 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=vwm_surveys' . AMP . 'method=update_survey';
$data['pages'] = $this->EE->vwm_surveys_m->get_questions_by_page($survey_id);
$data['question_types'] = $this->question_types();
$data['question_types'] = $this->get_question_types();
$data['member_groups'] = $this->EE->vwm_surveys_m->get_groups();
$data['has_submissions'] = $this->EE->vwm_surveys_submissions_m->get_survey_submissions(array('survey_id' => $survey_id)) ? TRUE : FALSE; // See if this survey has any submissions

Expand Down Expand Up @@ -333,14 +333,14 @@ public function update_survey()
// If this is a new question
else
{
$data = array(
'title' => trim($question['title']),
'type' => $question['type'],
'options' => isset($question['options']) ? json_encode($question['options']) : NULL,
'custom_order' => (int)$question['custom_order'],
'survey_id' => $id,
'page' => $page_number
);
// Set new question properties in model
$this->EE->vwm_surveys_m
->set_survey_id($id)
->set_page($page_number)
->set_question_title( trim($question['title']) )
->set_question_type( $question['type'] )
->set_question_custom_order( $question['custom_order'] )
->set_question_options( isset($question['options']) ? json_encode($question['options']) : NULL );

$this->EE->vwm_surveys_m->insert_question($data);
}
Expand Down Expand Up @@ -472,33 +472,40 @@ public function compile_survey_results()
public function add_question()
{
// Get data for our new question
$custom_order = (int)$this->EE->input->get('custom_order');
$title = 'Question ' . $custom_order;
$type = array_key_exists($this->EE->input->get('type'), $this->question_types()) ? $this->EE->input->get('type') : 'text';
$page = (int)$this->EE->input->get('page_number');
$survey_id = (int)$this->EE->input->get('survey_id');
$question = NULL;

// Insert the new question into the database and get its ID back
if ( $id = $this->EE->vwm_surveys_m->insert_question( array('title' => $title, 'type' => $type, 'custom_order' => $custom_order, 'page' => $page, 'survey_id' => $survey_id) ) )
$page = (int)$this->EE->input->get('page_number');
$question_type = array_key_exists($this->EE->input->get('type'), $this->get_question_types()) ? $this->EE->input->get('type') : 'text';
$question_custom_order = (int)$this->EE->input->get('custom_order');
$question_title = 'Question ' . $question_custom_order;
$question = ''; // Question view data

// Set new question properties in model
$this->EE->vwm_surveys_m
->set_survey_id($survey_id)
->set_page($page)
->set_question_title($question_title)
->set_question_type($question_type)
->set_question_custom_order($question_custom_order);

// Insert the new question into the database and get its insert ID back
if ( $id = $this->EE->vwm_surveys_m->insert_question() )
{
// Prepare data array for our question view
$data = array(
'question' => array(
'title' => $title,
'title' => $question_title,
'id' => $id,
'options' => array(),
'type' => $type,
'custom_order' => $custom_order
'type' => $question_type,
'custom_order' => $question_custom_order
),
'question_type' => $type,
'question_number' => $custom_order,
'question_type' => $question_type,
'question_number' => $question_custom_order,
'page_number' => $page,
'question_types' => $this->question_types()
'question_types' => $this->get_question_types()
);

$question = $this->EE->load->view('vwm_question_template', $data, TRUE);

}

// Echo out our question
Expand Down Expand Up @@ -554,7 +561,7 @@ public function add_page()
{
$title = trim($this->EE->input->get('title'));
$survey_id = (int)$this->EE->input->get('survey_id');

// Only add a page if we have a title and a survey ID
if ($title AND $survey_id)
{
Expand Down
4 changes: 2 additions & 2 deletions mod.vwm_surveys.php
Expand Up @@ -42,7 +42,7 @@ public function __construct()
$this->EE->load->model(array('vwm_surveys_m', 'vwm_surveys_submissions_m'));

// Load config files for all question types
foreach ( $this->question_types() as $slug => $name)
foreach ( $this->get_question_types() as $slug => $name)
{
$this->EE->load->helper('vwm_' . $slug);
}
Expand All @@ -55,7 +55,7 @@ public function __construct()
* @access private
* @return array
*/
private function question_types()
private function get_question_types()
{
// If our question types have not yet been loaded
if ( ! self::$question_types )
Expand Down

0 comments on commit 3a81521

Please sign in to comment.