function delete_map($student_id, $map_id)
{
    $maps = get_user_maps($student_id);
    foreach ($maps as $map) {
        if ($map->id == $map_id) {
            $dom = dom_import_simplexml($map);
            $dom->parentNode->removeChild($dom);
        }
    }
    $maps_as_string = xml_to_string($maps);
    $query = "UPDATE Students SET MAPS='{$maps_as_string}' WHERE STUDENT_ID={$student_id};";
    exec_query($query);
}
예제 #2
0
     $map = json_decode($map, true);
     // echo $map['id'];
     if ($map['id'] != null) {
         deliver_response("Map retrieving successful", $map);
     } else {
         deliver_response("Map not found");
     }
     break;
 case 'PUT':
     $json_string = file_get_contents('php://input');
     $json_arr = json_decode($json_string, true);
     $conceptmap->mapxml = "";
     if (empty($conceptmap->mapxml)) {
         // updating empty record with whole map
         $mapxml = json_arr_to_xml($json_arr);
         $mapxml = xml_to_string($mapxml);
     } else {
         // updating only the differences
         // $mapxml = format_xml($conceptmap->mapxml);
         // $mapxml = xml_maps_to_json($mapxml);
         // $mapxml = json_decode($mapxml, true)[0];
         // foreach ($mapxml as $key => $value) {
         //     if (!empty($json_arr[$key])) {
         //         $mapxml[$key] = $json_arr[$key];
         //     }
         // }
     }
     $conceptmap->mapxml = $mapxml;
     $DB->update_record($table, $conceptmap, $bulk = false);
     // super_echo($conceptmap); // result as XML
     $map = from_db_to_json($conceptmap);