I am using the latest version of the quiz module. While creating multiple choice questions, if I click on the 'Add more alternatives', another alternative field appears. But the new 'feedback if chosen' field for this new alternative does not contain attached CKEditor. Nor the alternative field. How do I attach CKEditor with them?

CommentFileSizeAuthor
#2 add more alternatives.png24.12 KBrrizia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

borgewarvik’s picture

We have tested this issue and could not reproduce running Drupal 6.19 and Quiz 6.x-4.0-rc9.

rrizia’s picture

FileSize
24.12 KB

I am using drupal 6.17.
I am attaching a screenshot of the issue.

rrizia’s picture

Sorry my drupal version is also 6.19 and Quiz module version is Quiz 6.x-4.0-rc9

falcon’s picture

Are you using the wysiwyg module or the CKEditor drupal module? (http://drupal.org/project/ckeditor)

rrizia’s picture

ckeditor drupal module : CKEditor 6.x-1.1

rrizia’s picture

Hi,

Any help on this. This is an urgent issue i need to fix for my site. Can anybody tell me wht to do for this.

Thanks in advance

Rizwana Rizia

rrizia’s picture

FYI

I have fixed this issue.

in multichoice.module on 210 i have added the following two lines

$javascript = drupal_add_js(NULL, NULL);
$output_js = isset($javascript['setting']) ? '

jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');

' : '';

and the appended this to $output.

drupal_json(array('status' => TRUE, 'data' => $status . $output . $output_js));

Thanks

Rizwana Rizia.

borgewarvik’s picture

Status: Active » Needs work

Great!

Could you attach this as a patch? Makes it easier to test and commit.

falcon’s picture

Title: CKEditor for multichoice answer options » support CKEditor module
Category: bug » feature
Priority: Critical » Normal
tomvanacker’s picture

Version: 6.x-4.0-rc9 » 6.x-4.0-rc10
Category: feature » bug

I have the same problem reported here. When I apply the proposed solution, this is not solved on my site. The Javascript code in $output_js is appended to the page as normal html, instead of being excecuted. Can anyone tell me how to solve this, or supply an updated multichoice.module?

This is how I corrected multichoice_add_alternative_ahah:

/**
 * ahah callback function used when adding alternatives to the node-form
 */
function multichoice_add_alternative_ahah() {
  include_once 'modules/node/node.pages.inc';
  $form_state = array('storage' => NULL, 'submitted' => FALSE);
  $form_build_id = $_POST['form_build_id'];

  // Get the form from the cache.
  $form = form_get_cache($form_build_id, $form_state);

  // Get values have been sent using the form cache
  if (isset($form['get']['#value']) && is_array($form['get']['#value'])) {
    $get = $form['get']['#value'];
    foreach ($get as $key => $value) {
      $_GET[$key] = $value;
    }
  }

  $args = $form['#parameters'];
  $form_id = array_shift($args);

  // We will run some of the submit handlers so we need to disable redirecting.
  $form['#redirect'] = FALSE;

  // We need to process the form, prepare for that by setting a few internals
  // variables.
  $form['#post'] = $_POST;
  $form['#programmed'] = FALSE;
  $form_state['post'] = $_POST;

  // Build and submit the form.
  _multichoice_skip_validation($form);
  drupal_process_form($form_id, $form, $form_state);

  // This call recreates the form relying solely on the form_state that the
  // drupal_process_form set up.
  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

  // Count the alternatives
  $i = 0;
  while (isset($form['alternatives'][$i])) {
    $i++;
  }
  $i--;

  // Render the new output.
  $new_choice = $form['alternatives'][$i];
  $new_choice['#collapsed'] = FALSE;
  $output = form_get_errors() ? '' : drupal_render($new_choice);
  $status = theme('status_messages');

  // <============ Start proposed solution  
  $javascript = drupal_add_js(NULL, NULL);
  $output_js = isset($javascript['setting']) ? 'jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');' : '';
  // =====> End proposed solution

  drupal_json(array('status' => TRUE, 'data' => $status . $output . $output_js));
}

Greetings,
Tom

falcon’s picture

Category: bug » feature
djdevin’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

This issue is being closed because it was filed against a version that is no longer supported. If the issue still persists in the latest version of Quiz, please open a new issue.