DrupalBin
Submit Code
About
Recent Posts
Fix for Code
Code
add_to_cart_by_sku_contents()
Fix for page.tpl.php
Page.tpl
foreach is beeing disregarded dispite variable is array. Please help. Outside Drupal it works as standalone.php file
foreach is beeing disregarded dispite variable is array inside drupal. Please help. Outside Drupal it works as standalone.php
Fix for filefield implementation in an admin page. "An HTTP error 0 occurred. /drupal/?q=filefield/ahah///"
PHP Code custom.module
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
Fix for quiz pass rate hard coded
View
Fix
July 22, 2009 - 12:34pm — Anonymous
/**
* Check a user/quiz combo to see if the user passed the given quiz.
* A quiz is keyed by nid/vid, so you need both.
* This will return TRUE if the user has passed the quiz at least once, and
* false otherwise. Note that a FALSE may simply indicate that the user has not
* taken the quiz.
* @param $uid
* The user ID.
* @param $nid
* The node ID.
* @param $vid
* The version ID.
*/
function
quiz_is_passed
(
$uid
,
$nid
,
$vid
)
{
$passed
=
db_result
(
db_query
(
"SELECT COUNT(result_id) AS passed_count
FROM {quiz_node_results} qnrs
INNER JOIN {quiz_node_properties} USING (vid, nid)
WHERE qnrs.vid = %d AND qnrs.nid = %d AND qnrs.uid =%d AND score >= pass_rate"
,
$vid
,
$nid
,
$uid
)
)
;
// Force into boolean context
return
(
$passed
!
==
FALSE
&&
$passed
>
0
)
;
}
quiz
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
/** * Check a user/quiz combo to see if the user passed the given quiz. * A quiz is keyed by nid/vid, so you need both. * This will return TRUE if the user has passed the quiz at least once, and * false otherwise. Note that a FALSE may simply indicate that the user has not * taken the quiz. * @param $uid * The user ID. * @param $nid * The node ID. * @param $vid * The version ID. */ function quiz_is_passed($uid, $nid, $vid) { $passed = db_result(db_query("SELECT COUNT(result_id) AS passed_count FROM {quiz_node_results} qnrs INNER JOIN {quiz_node_properties} USING (vid, nid) WHERE qnrs.vid = %d AND qnrs.nid = %d AND qnrs.uid =%d AND score >= pass_rate", $vid, $nid, $uid )); // Force into boolean context return ($passed !== FALSE && $passed > 0); }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.