private function ScaleQuestion::excistingCollection in Quiz 6.6
Same name and namespace in other branches
- 6.4 question_types/scale/scale.classes.inc \ScaleQuestion::excistingCollection()
- 7 question_types/scale/scale.classes.inc \ScaleQuestion::excistingCollection()
Finds out if a collection allready exists.
Parameters
$alternatives - this is the collection that will be compared with the database.:
$answer_collection_id - if we are matching a set of alternatives with a given collection.:
$last_id - The id of the last alternative we compared with.:
Return value
unknown_type
1 call to ScaleQuestion::excistingCollection()
- ScaleQuestion::saveAnswerCollection in question_types/
scale/ scale.classes.inc - Stores the answer collection to the database, or reuses an excisting collection.
File
- question_types/
scale/ scale.classes.inc, line 196 - The main classes for the scale question type.
Class
- ScaleQuestion
- Implementation of QuizQuestion.
Code
private function excistingCollection($alternatives, $answer_collection_id = NULL, $last_id = NULL) {
$my_alts = isset($answer_collection_id) ? $alternatives : array_reverse($alternatives);
$sql = 'SELECT id, answer_collection_id
FROM {quiz_scale_answer}
WHERE answer = \'%s\'';
if (isset($answer_collection_id)) {
$sql .= ' AND answer_collection_id = %d';
}
if (isset($last_id)) {
$sql .= ' AND id = %d';
}
$res = db_query($sql, array_pop($my_alts), $answer_collection_id, $last_id + 1);
if (!($res_o = db_fetch_object($res))) {
return FALSE;
}
if (count($my_alts) == 0) {
$sql = 'SELECT * FROM {quiz_scale_answer}
WHERE answer_collection_id = %d
AND id = %d';
$res_o2 = db_fetch_object(db_query($sql, $answer_collection_id, $last_id + 2));
return $res_o2 == FALSE ? $answer_collection_id : FALSE;
}
do {
$col_id = $this
->excistingCollection($my_alts, $res_o->answer_collection_id, $res_o->id);
if ($col_id) {
return $col_id;
}
} while ($res_o = db_fetch_object($res));
return FALSE;
}