A bug in quiz.admin.inc

In line: 1940 $filter['group'] .= " GROUP BY qnrs.uid"; should be enclosed in if-mysql check. It's not at the moment, hence
there's an invalid syntax GROUP BY qnrs.uid"; GROUP BY qnrs.uid, u.uid, u.name, qnrs.result_id, qnrs.score, qnrs.is_evaluated, qnrs.time_start, qnrs.time_end, qnp.pass_rate"; produced in PostgreSQL.

Dirty fix (just commented non-postgres stuff):

//$filter['group'] .= " GROUP BY qnrs.uid";
    if ($db_type == 'pgsql') {
      $filter['group'] .= " GROUP BY qnrs.uid, u.uid, u.name, qnrs.result_id, qnrs.score, qnrs.is_evaluated, qnrs.time_start, qnrs.time_end, qnp.pass_rate";
    }

Comments

sebzur’s picture

And another thing, I had to add some explicit type casting, to have no error wher quering for some quize statistics: (quiz.module:2159-2166)

$sql = "UPDATE {quiz_node_properties} qnp
          SET max_score = cast (max_score_for_random as bigint) * CAST (number_of_random_questions as bigint)+ cast((
            SELECT SUM(max_score)
            FROM {quiz_node_relationship} qnr
            WHERE qnr.question_status = " . QUESTION_ALWAYS . "
            AND parent_vid = qnp.vid
          ) as bigint)
sebzur’s picture

And another one issue. Quiz complains when submited and sent via e-mail to authror:

    * warning: pg_query() [function.pg-query]: Query failed: ERROR: argument of AND must be type boolean, not type int_unsigned in ...PATH.../includes/database.pgsql.inc on line 139.
    * user warning: query: SELECT CEIL((time_end - time_start)/60) FROM quiz_node_results WHERE result_id = '31' AND time_end in ...PATH.../sites/all/modules/quiz/quiz.module on line 2068.

fixed with explicit casting, line 2068 in quiz.module:

'!minutes' => db_result(db_query("SELECT CEIL((time_end - time_start)/60) FROM {quiz_node_results} WHERE result_id = '%d' AND cast(time_end as boolean)"
falcon’s picture

Status: Active » Postponed

Marking this one as postponed. If we get a patch in here someone might review and commit it, but I don't think the current maintainers have the time to add postgres support :/

sebzur’s picture

OK, what can I do to help? I need the Quiz dramatically - I'm patching it version by version on my own - (I've even tried to port my DB form Postgres to MySQL, but it's quite complicated, though)...

So - shall I attach a patch file here? There are only minor changes, so It would be great to apply it and have the issue closed. I could even monitor Postgres compliance for Quiz.

falcon’s picture

Yes, please attach a patch file here, and it would be great if you could monitor Postgres compliance for Quiz in the future.

ezraw’s picture

Title: Postgres problem » Support Postgres
Version: 6.x-4.0-rc9 » 7.x-5.x-dev
Component: Code - Quiz module » Code - Quiz core
Issue summary: View changes
ezraw’s picture

Category: Bug report » Feature request
ezraw’s picture

Title: Support Postgres » Support for Postgres
thehong’s picture

Version: 7.x-5.x-dev » 7.x-6.x-dev
djdevin’s picture

Version: 7.x-6.x-dev » 7.x-5.x-dev
Category: Feature request » Bug report
Status: Postponed » Closed (cannot reproduce)