use AJAX to dynamicall load list of all Quests for a Seminary (Issue #287)

This commit is contained in:
coderkun 2014-05-25 00:47:29 +02:00
commit f655749be3
4 changed files with 130 additions and 7 deletions

View file

@ -368,6 +368,35 @@
}
/**
* Get count of all Quests for a Seminary.
*
* @param int $seminaryId ID of Seminary
* @param int $questgroupId ID of Questgroup (optional)
* @param int $questtypeId ID of Questtype (optional)
* @return int Count of Quests for this Seminary
*/
public function getCountForQuestsForSeminaryByOpenSubmissions($seminaryId, $questgroupId=null, $questtypeId=null)
{
$data = $this->db->query(
'SELECT count(DISTINCT quests.id) AS c '.
'FROM questgroups '.
'INNER JOIN quests ON quests.questgroup_id = questgroups.id '.
'WHERE questgroups.seminary_id = ? '.
(!empty($questgroupId) ? sprintf('AND questgroups.id = %d ', $questgroupId) : null).
(!empty($questtypeId) ? sprintf('AND quests.questtype_id = %d ', $questtypeId) : null),
'i',
$seminaryId
);
if(!empty($data)) {
return $data[0]['c'];
}
return 0;
}
/**
* Get all Quests for a Seminary order by their count of open
* submissions.