source: Dev/branches/jQueryUI/pages_old/saveSurvey.php @ 247

Last change on this file since 247 was 246, checked in by hendrikvanantwerpen, 13 years ago

Created first page mainmenu in new system.
Moved old pages out of project root.
Fixed RDFAPI.php case for people with proper OS'es.

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.