We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Get question data for one section | Forum

Sean Apr 24 '15
I'm pulling my hair out over this.

I have a profile section called 'Contact Details' and I would like to get the question data for this one section only.

Oxwall though for some reason saves section names as an MD5 hash of a unique id, so you cant simply use

BOL_QuestionSectionDao::getInstance()->findBySectionName('Contact Details')

That would be too easy ha-ha.

Does anyone know how to get details for a particular section only? 

Sean Apr 24 '15
The entire way question data is stored just seems odd. Why store the question names as MD5 hashes in a language key?


Sean Apr 24 '15
Okay I made my own solution to filter all question data down to one section, others may find this useful:

//Get the question data$questions = $questionService->findViewQuestionsForAccountType($targetUser->accountType);//Filter the section$keyPrefix = BOL_QuestionService::QUESTION_LANG_PREFIX;$section = 'Contact Details';$questionNames = array();foreach($questions as $question ){$sectionName = $questionService->getQuestionLangKeyName('section', $question['sectionName']);$sectionName = OW::getLanguage()->text($keyPrefix, $sectionName);if( $sectionName == $section ){$questionNames[] = $question['name'];}}//Get the question data$questionData = $questionService->getQuestionData(array($targetUserId), $questionNames);//Get the question labels$questionLabels = array();foreach( $questionData as $set => $user ){foreach( $user as $key => $value){$questionLabel = $questionService->getQuestionLangKeyName('label', $key);$questionLabel = OW::getLanguage()->text($keyPrefix, $questionLabel);if( !array_key_exists($key, $questionLabels) ){$questionLabels[$key] = $questionLabel;}}}

Sean Apr 24 '15
bloody formatting!
dave Leader
dave Apr 26 '15
yeah its pretty funky huh storing the type as a hash in the db and then creating a lang key as hash for it so it has a related text value from the lang value table lol... 

i was looking for the function to convert it from hash to text and found out i dont think there is one, they just use the hash for everything and only the text value for display purposes is all.  But it looks like all processing is done using the hash value.