CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Data Structure Loop: Edit Log



ogit2
Novice

Oct 17, 2017, 8:48 AM


Views: 1598
Data Structure Loop

Hi

I have the following data structure (received from 3rd party web site so I cannot change format) and am trying to find a way to output status and direction for each question (questions) using a loop. I can access them individually. Hopefully a simple query.


Code
   my $ans =  $data->{questions}->{textQuestion}->{status}; 
my $quest = $data->{questions}->{textQuestion}->{direction};



Code
$VAR1 = { 
'questions' => {
'textQuestion' => {
'status' => 'incorrect',
'direction' => "How many types of features does an owl have?",
},
'numericQuestion' => {
'status' => 'correct',
'direction' => "The interior angles of a triangle add up to? ",
},
'textQuestion' => {
'status' => 'correct',
'direction' => "Please spell the opposite of majestic ",
},
'multipleQuestion' => {
'status' => 'incorrect',
'direction' => "Which of these can be found in a swamp ",
},
'selectionQuestion' => {
'status' => 'correct',
'direction' => "Select the correct wood for building firewood ",
}
},
'groups' => {
'group' => {
'passingPercent' => '80',
'name' => 'Question Group 1',
'passingScore' => '80',
'totalQuestions' => '10',
'awardedScore' => '80.83',
'answeredQuestions' => '7',
'awardedPercent' => '80.83'
}
},
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'quizSettings' => {
'maxScore' => '100',
'maxNormalizedScore' => '100',
'timeLimit' => '1200',
'passingPercent' => '0.8',
'quizType' => 'graded'
},
'xmlns' => 'http://results',
'version' => '1'
};



(This post was edited by ogit2 on Oct 17, 2017, 8:57 AM)


Edit Log:
Post edited by ogit2 (Novice) on Oct 17, 2017, 8:57 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives