I receive the following error trying to add new questions to a quiz. I've tried several questions type, short answer, true/false, multiple choice, directions, etc. If I remove the checkbox to add directly to quiz, the questions are created without error. If I go to an existing quiz and try to add through the manage questions, I get the same error.
PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]The round function requires 2 to 3 arguments. in quiz_update_max_score_properties() (line 2610 of C:\inetpub\wwwroot\drupal7\d7\sites\all\modules\quiz\quiz.module).

I'm running a WIMP stack (Windows 2008 R2, IIS 7.5, MS SQL 2008 R2, PHP 5.3)

Comments

rob_johnston’s picture

I can confirm this one... it's a difference in the SQL dialect for MS SQL Server.

See http://msdn.microsoft.com/en-us/library/ms175003.aspx for an explanation of why MSSQL needs more arguments and see http://dev.mysql.com/doc/refman/5.1/en/mathematical-functions.html#funct... for why mySql can get away with just one. Looks to me like postgreSQL can also take either one or two arguments to the ROUND function (http://www.postgresql.org/docs/9.2/static/functions-math.html).

Correct me if I'm wrong, but adding zero as the second argument should fix it for all 3 databases?

  db_update('quiz_node_results')
    ->expression('score',
      'ROUND(
        100 * (
          SELECT COALESCE (SUM(a.points_awarded), 0)
          FROM {quiz_node_results_answers} a
          WHERE a.result_id = {quiz_node_results}.result_id
        ) / (
          SELECT max_score
          FROM {quiz_node_properties} qnp
          WHERE qnp.vid = {quiz_node_results}.vid
        )
      ,0)')
    ->condition('vid', $quizzes_to_update, 'IN')
    ->execute();
falcon’s picture

Priority: Major » Minor

mssql problem

djdevin’s picture

Issue summary: View changes
Status: Active » Closed (outdated)