source: Dev/branches/jos-branch/saveSurvey.php @ 256

Last change on this file since 256 was 238, checked in by fpvanagthoven, 13 years ago

-selectObject is een algemene object selector. Kan gebruikt worden vanuit het mainmenu om in de verschillende editors te komen, en kan eventueel ook onder de "add existing" knop kopen te staan binnen die editors.

File size: 1.2 KB
Line 
1<?php
2
3require 'classes/master.php';
4
5// Quit if no arguments have been passed.
6if (!isset($_POST['args'])) {
7    if (empty($_POST['args'])) {
8        die("Error! No arguments passed!");
9    }
10}
11
12$args = json_decode($_POST['args']);
13if ($args == false) {
14    die("Error decoding JSON arguments!");
15}
16
17// At this point we know we have arguments in the POST data.
18// Query the survey object from the database.
19
20$survey_results = Survey::get(array("uid" => $args->uid));
21if (!empty($survey_results)) {
22    $survey = $survey_results[0];
23} else {
24    die("No survey found!");
25}
26
27$question->questions = array();
28foreach ($args->questions->uids as $questionUid) {
29    $question_results = Question::get(array("uid"=>$questionUid));
30    $question = $question_results[0];
31    $survey->questions[] = $question;
32}
33
34// The next part is a rather experimental way of automatically writing all passed arguments to the session object.
35// If this does not work properly, we should write the "write title to session->title" call by hand.
36/*
37  foreach ($args as $key=>$value) {
38  $session->$key = $value;
39  }
40 */
41//var_dump($survey);
42// Do I need to check if this is done before proceeding?
43$survey->save();
44?>
Note: See TracBrowser for help on using the repository browser.