18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
40 $this->_ser_attrs = TRUE;
41 return $this->
Asset($assetid);
58 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
59 $val = parent::saveAttributes($dont_run_updated);
60 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
75 $a = $this->
attr(
'attributes');
76 if (isset($a[
'misc'][
'ip']))
return $a[
'misc'][
'ip'];
92 $a = $this->
attr(
'attributes');
93 if (empty($a[
'misc'])) $a[
'misc'] = Array();
95 $a[
'misc'][
'ip'] = $ip;
114 $a = $this->
attr(
'attributes');
115 if (isset($a[
'misc'][
'score'])) {
116 return $a[
'misc'][
'score'];
134 $a = $this->
attr(
'attributes');
135 if (empty($a[
'misc'])) $a[
'misc'] = Array();
137 $a[
'misc'][
'score'] = $score;
159 $user_details_answer = NULL;
161 if (isset($user_details_answers[$asset_id][
'answer'])) {
162 $user_details_answer = $user_details_answers[$asset_id][
'answer'];
165 return $user_details_answer;
182 if (empty($user_details_answers)) {
183 $user_details_answers = Array();
186 $user_details_answers[$asset_id][
'answer'] = $answer;
187 $result = $this->
setAttrValue(
'user_details_answers', $user_details_answers);
207 if (isset($quiz_answers[$asset_id][
'answer'])) {
208 $quiz_answer = $quiz_answers[$asset_id][
'answer'];
228 if (empty($quiz_answers)) $quiz_answers = Array();
230 $quiz_answers[$asset_id] = $answer;
231 $result = $this->
setAttrValue(
'quiz_answers', $quiz_answers);
246 $user_details_answers = $this->
attr(
'user_details_answers');
248 return $user_details_answers;
261 $quiz_answers = $this->
attr(
'quiz_answers');
263 return $quiz_answers;
277 function getSummary($incl_user_details=TRUE, $incl_quiz_responses=TRUE)
281 if ($incl_user_details){
284 foreach ($user_details_answers as $question_id => $answer_details) {
285 $summary[$question_id][
'name'] = $user_details_questions[$question_id];
286 $summary[$question_id][
'answer'] = $answer_details[
'answer'];
290 if ($incl_quiz_responses){
293 foreach ($quiz_answers as $question_id => $answer_details) {
294 $summary[$question_id][
'name'] = $quiz_questions[$question_id];
295 $summary[$question_id][
'answer'] = $answer_details[
'summary'];
316 if (empty($user_details_questions)) {
317 $user_details_questions = Array();
320 $user_details_questions[$asset_id] = $question_name;
321 $result = $this->
setAttrValue(
'user_details_questions', $user_details_questions);
340 if (empty($quiz_questions)) $quiz_questions = Array();
342 $quiz_questions[$asset_id] = $question_name;
343 $result = $this->
setAttrValue(
'quiz_questions', $quiz_questions);
358 return $this->
attr(
'user_details_questions');
371 return $this->
attr(
'quiz_questions');
392 $res = parent::getAvailableKeywords();
393 $res[
'quiz_qX_name'] =
'The name of the question with ID X';
394 $res[
'quiz_qX_answer_value'] =
'The answer to the question with ID X';
395 $res[
'quiz_qX_answer_summary'] =
'The summary of the question with ID X';
396 $res[
'quiz_qX_answer_awarded'] =
'The points awarded of the question with ID X';
397 $res[
'quiz_qX_answer_available'] =
'The points available of the question with ID X';
398 $res[
'user_details_X:qY_question'] =
'The user deatil form question with asset ID X:qY';
399 $res[
'user_details_X:qY_answer'] =
'The user deatil form answer with question asset ID X:qY';
400 $res[
'quiz_qX_answer_available'] =
'The points available of the question with ID X';
401 $res[
'user_ip_address'] =
'IP address that created this submission';
402 $res[
'user_details'] =
'User details summary, blank if User Details form not used';
403 $res[
'user_asset_id'] =
'The User who created the Submission,';
404 $res[
'quiz_responses'] =
'Summary of responses nad points awarded and maximum points per answer';
405 $res[
'quiz_total'] =
'Total points awarded and available';
406 $res[
'quiz_score'] =
'Quiz Score';
430 if (preg_match(
'/quiz\_q([0-9]+)\_name/', $keyword, $matches)) {
431 $attrs = $this->
attr(
'quiz_questions');
432 foreach ($attrs as $id => $value) {
433 if ($id == $matches[1]) {
440 if (preg_match(
'/quiz\_q([0-9]+)\_answer_value/', $keyword, $matches)) {
441 $attrs = $this->
attr(
'quiz_answers');
442 foreach ($attrs as $id => $value) {
443 if ($id == $matches[1]) {
444 return $value[
'value'];
450 if (preg_match(
'/quiz\_q([0-9]+)\_answer_summary/', $keyword, $matches)) {
451 $attrs = $this->
attr(
'quiz_answers');
452 foreach ($attrs as $id => $value) {
453 if ($id == $matches[1]) {
454 return $value[
'summary'];
460 if (preg_match(
'/quiz\_q([0-9]+)\_points_awarded/', $keyword, $matches)) {
461 $attrs = $this->
attr(
'quiz_answers');
462 foreach ($attrs as $id => $value) {
463 if ($id == $matches[1]) {
464 return $value[
'points'];
470 if (preg_match(
'/quiz\_q([0-9]+)\_points_available/', $keyword, $matches)) {
471 $attrs = $this->
attr(
'quiz_answers');
472 foreach ($attrs as $id => $value) {
473 if ($id == $matches[1]) {
474 return $value[
'available_points'];
480 if (preg_match(
'/user_details\_([0-9]+:q[0-9]+)\_question/', $keyword, $matches)) {
482 $attrs = $this->
attr(
'user_details_questions');
483 foreach ($attrs as $id => $value) {
484 if ($id == $matches[1]) {
492 if (preg_match(
'/user_details\_([0-9]+:q[0-9]+)\_answer/', $keyword, $matches)) {
493 $attrs = $this->
attr(
'user_details_answers');
494 foreach ($attrs as $id => $value) {
495 if ($id == $matches[1]) {
496 return $value[
'answer'];
502 if (preg_match(
'/user_ip_address/', $keyword, $matches)) {
503 return $this->
getIP();
507 if (preg_match(
'/user_asset_id/', $keyword, $matches)) {
508 return $this->updated_userid;
511 if (preg_match(
'/user_details/', $keyword, $matches)) {
512 $string =
'<table border="0" cellspacing="2" cellpadding="2">'.
"\n";
514 $string .=
"</table>\n";
518 if (preg_match(
'/quiz_responses/', $keyword, $matches)) {
519 $string =
'<table border="0" cellspacing="2" cellpadding="2">'.
"\n";
521 $string .=
"</table>\n";
525 if (preg_match(
'/quiz_total/', $keyword, $matches)) {
526 $string =
'<table border="0" cellspacing="2" cellpadding="2">'.
"\n";
528 $string .=
"</table>\n";
532 if (preg_match(
'/quiz_score/', $keyword, $matches)) {
536 return parent::getKeywordReplacement($keyword);
549 echo
'<table border="0" cellspacing="2" cellpadding="2">'.
"\n";
551 echo
'<tr><td><strong>User IP Address</strong></td><td>'.$this->getIP().
'</td></tr>';
571 foreach ($user_details_questions as $id => $value) {
572 $string .=
"<tr>\n<td><strong>$value</strong></td>\n";
573 if(isset($user_details_answers[$id][
'answer'])) {
574 $string .=
"<td>".$user_details_answers[$id][
'answer'].
"</td>";
576 $string .=
"\n</tr>\n";
579 if (empty($string)) {
580 return "<tr>\n<td><strong>User Asset ID</strong></td>\n<td>$this->updated_userid</td>\n</tr>\n";
601 foreach ($quiz_questions as $id => $value) {
602 $string .=
"<tr>\n<td><strong>$value</strong></td>\n<td>";
603 if(isset($quiz_answers[$id][
'summary'])) {
604 $string .= $quiz_answers[$id][
'summary'].
", ";
606 if(isset($quiz_answers[$id][
'points']) && isset($quiz_answers[$id][
'available_points'])) {
607 $string .=
" ".$quiz_answers[$id][
'points'].
" of ".$quiz_answers[$id][
'available_points'].
" points";
610 $string .=
"</td>\n</tr>\n";
628 $total_points_available = 0;
629 $total_points_awarded = 0;
631 foreach ($quiz_answers as $id => $value) {
632 if(isset($value[
'available_points']))
633 $total_points_available += $value[
'available_points'];
634 if(isset($value[
'points']))
635 $total_points_awarded += $value[
'points'];
638 $string =
"<tr>\n<td><strong>Total points awarded</strong></td>\n<td>$total_points_awarded</td>\n</tr>\n";
639 $string .=
"<tr>\n<td><strong>Total points available</strong></td>\n<td>$total_points_available</td>\n</tr>\n";