﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="d108eacf-fe05-4115-9075-24035039117f" codekey="ListUserLocation" categoryCodekey="SpecialPurpose" name="Auflistung des Lernorts der Teilnehmer" description="Der Report listet den Lernort (zu Hause / bei Apetito) auf Basis einer Umfrage auf.&#xD;&#xA;ACHTUNG: Sehr spezifisch">
      <MetaData created="2013-05-20T00:11:14" createdBy="Administrator Apetito (Administrator)" createdBy_user_id="19183" modified="2013-05-28T14:34:34" modifiedBy="Administrator Apetito" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="a21905e0-a946-4f0f-8304-e0ad1d4ce9ba" mandatorName="Apetito" isStandard="False" isUsedByMenu="False" />
      <Roles>
        <Role id="90" />
      </Roles>
      <command>


        -- Find the Poll "Abfrage Lernort"
        DECLARE @TestID UNIQUEIDENTIFIER
        SET @TestID = (select tblItems.id from tblItems
        where mandator_id = @current_mandator_id
        and tblItems.title = 'Abfrage Lernort')

        DECLARE @TestIDNL UNIQUEIDENTIFIER
        SET @TestIDNL = (select tblItems.id from tblItems
        where mandator_id = @current_mandator_id
        and tblItems.title = 'Abfrage Lernort NL')

        if ((@TestID is not null) or (@TestIDNL is not null))
        BEGIN
        -- Find the only question in the polls
        DECLARE @QuestionID UNIQUEIDENTIFIER
        Set @QuestionID= (select distinct questionID from tblTasTestSessionQuestions where testSessionId in (select id from tblTasTestSessions where test_id =@TestID))
        DECLARE @QuestionIDNL UNIQUEIDENTIFIER
        Set @QuestionIDNL= (select distinct questionID from tblTasTestSessionQuestions where testSessionId in (select id from tblTasTestSessions where test_id =@TestIDNL))

        -- List Results
        select 'Ich lerne zu Hause (DE)' as Lernort

        select Vorname, Nachname, companyAD as Firma, division as Abteilung, office as Dienststelle, descUserCn as Kennung
        from tblTasTestSessionQuestions
        join tblTasTestSessions on tblTasTestSessions.id = tblTasTestSessionQuestions.testSessionId
        join v_Users on v_Users.intUserCn = tblTasTestSessions.user_id
        where questionId = @QuestionID
        and CAST(answerXml AS XML).value('(/AllAnswers/Answers/AnswerChoice/@answerPartId)[1]','nvarchar(64)') = 'ba50e76a-000d-4b4f-a34c-111287dfb467'
        order by Nachname

        select 'Ich lerne zu Hause (NL)' as Lernort

        select Vorname, Nachname, companyAD as Firma, division as Abteilung, office as Dienststelle, descUserCn as Kennung
        from tblTasTestSessionQuestions
        join tblTasTestSessions on tblTasTestSessions.id = tblTasTestSessionQuestions.testSessionId
        join v_Users on v_Users.intUserCn = tblTasTestSessions.user_id
        where questionId = @QuestionIDNL
        and CAST(answerXml AS XML).value('(/AllAnswers/Answers/AnswerChoice/@answerPartId)[1]','nvarchar(64)') = 'd95a8fd5-337c-484f-b335-50f21d510a07'
        order by Nachname


        select 'Ich lerne bei apetito (DE)' as Lernort

        select  Vorname, Nachname, companyAD as Firma, division as Abteilung, office as Dienststelle, descUserCn as Kennung
        from tblTasTestSessionQuestions
        join tblTasTestSessions on tblTasTestSessions.id = tblTasTestSessionQuestions.testSessionId
        join v_Users on v_Users.intUserCn = tblTasTestSessions.user_id
        where questionId = @QuestionID
        and CAST(answerXml AS XML).value('(/AllAnswers/Answers/AnswerChoice/@answerPartId)[1]','nvarchar(64)') = '0e5224f3-f314-4adb-b84d-ed04a60c6b5c'
        order by Nachname

        select 'Ich lerne bei apetito (NL)' as Lernort

        select  Vorname, Nachname, companyAD as Firma, division as Abteilung, office as Dienststelle, descUserCn as Kennung
        from tblTasTestSessionQuestions
        join tblTasTestSessions on tblTasTestSessions.id = tblTasTestSessionQuestions.testSessionId
        join v_Users on v_Users.intUserCn = tblTasTestSessions.user_id
        where questionId = @QuestionIDNL
        and CAST(answerXml AS XML).value('(/AllAnswers/Answers/AnswerChoice/@answerPartId)[1]','nvarchar(64)') = '8ddb517d-1765-4ba3-bbd9-a7c36f7a9b3a'
        order by Nachname

        select 'Keine Angabe' as Lernort

        select  Vorname, Nachname, companyAD as Firma, division as Abteilung, office as Dienststelle, descUserCn as Kennung
        from tblTasTestSessionQuestions
        join tblTasTestSessions on tblTasTestSessions.id = tblTasTestSessionQuestions.testSessionId
        join v_Users on v_Users.intUserCn = tblTasTestSessions.user_id
        where (questionId = @QuestionID OR questionId = @QuestionIDNL)
        and answerXml is null
        order by Nachname


        END
        ELSE
        BEGIN
        SELECT 'Kein Ergebnis' as Auswertung
        END

      </command>
    </Report>
  </Reports>
</ReportsExport>