﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="674a642d-f0d2-4f27-818f-98830891428d" codekey="CompleteThemeList" categoryCodekey="LearningPrograms" name="Complete List of all themes of current mandator" description="Complete List of all themes (deleted and not deleted)">
      <MetaData created="2015-07-11T23:32:33" createdBy_user_id="37277" modified="2015-10-11T17:40:23" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="d5a90a49-e697-4aeb-8a5b-298782815490" mandatorName="ELECT" isStandard="False" isUsedByMenu="False" />
      <Roles>
        <Role id="90" />
      </Roles>
      <command>
        --DECLARE @current_mandator_id UNIQUEIDENTIFIER = (select top 1 id from tblMandators where name = 'elect')

        SELECT
        tblThemes.id AS [ID],
        tblThemes.importPath AS [Title],
        ThemeItems.titleForLearners AS [Display_x0020_Name],
        ThemeItems.tag AS [Tag_x0020__x0028_Account_x0029_],
        (
        SELECT
        STUFF(
        (
        SELECT
        ',' + ISNULL(titleForLearners,title)
        FROM
        tblItems As EduOffers
        JOIN tblEduOffersModules
        on EduOffers.id = tblEduOffersModules.eduOffer_id
        JOIN tblModuleItems
        ON tblEduOffersModules.module_id = tblModuleItems.module_id
        WHERE
        tblModuleItems.item_id = ThemeItems.id
        FOR XML PATH('')
        ), 1, 1, '')
        ) AS [Assign_x0020_to_x0020_curricula_],
        (
        SELECT
        STUFF(
        (
        SELECT
        ';' + v_Users.Nachname + ', ' + v_Users.Vorname
        from
        v_Users
        JOIN tblTutorsItems
        on tblTutorsItems.user_id = v_Users.intUserCn
        WHERE
        tblTutorsItems.item_id = ThemeItems.id
        FOR XML PATH('')
        ), 1, 1, '')
        ) AS [Tutor],
        ISNULL('http://elect.munich.munichre.com/elect/infowbt.aspx?themetag=' + ThemeItems.tag,'') AS [URL],
        CASE
        WHEN ThemeItems.isAvailableForEduCatalog = 1
        THEN 'Unauthorized users can order the learning program'
        ELSE
        'Unauthorized users cannot see the learning program'
        END AS [Ordering_x0020_Properties],
        (
        SELECT
        STUFF(
        (
        SELECT
        ',' + title
        FROM
        tblItems As EduOffers
        JOIN tblEduOffersModules
        on EduOffers.id = tblEduOffersModules.eduOffer_id
        JOIN tblModuleItems
        ON tblEduOffersModules.module_id = tblModuleItems.module_id
        WHERE
        tblModuleItems.item_id = ThemeItems.id
        FOR XML PATH('')
        ), 1, 1, '')
        ) AS [Assign_x0020_to_x0020_curricula_0],
        (
        SELECT
        STUFF(
        (
        SELECT
        ',' + ISNULL(titleForLearners,title)  AS 'data()'
        FROM
        tblItems As Modules
        JOIN tblModuleItems
        ON Modules.id = tblModuleItems.module_id
        WHERE
        tblModuleItems.item_id = ThemeItems.id
        ORDER BY
        ISNULL(titleForLearners,title)
        FOR XML PATH('')
        ), 1, 1, '')
        ) AS [Assign_x0020_to_x0020_Module_x00],
        (
        SELECT
        STUFF(
        (
        SELECT
        ',' + title AS 'data()'
        FROM
        tblItems As Modules
        JOIN tblModuleItems
        ON Modules.id = tblModuleItems.module_id
        WHERE
        tblModuleItems.item_id = ThemeItems.id
        ORDER BY
        title
        FOR XML PATH('')
        ), 1, 1, '')
        ) AS [Assign_x0020_to_x0020_Module_x000],
        tblCertificates.name AS [Certificate_x0020__x0028_Name_x0],
        (
        isnull((select 'Lernprogramm muss vollständig bearbeitet sein,' where tblThemes.calcStatusIncludeCompleted = 1),'') +
        isnull( (select 'Test(s) muss bestanden sein,' where tblThemes.calcStatusIncludeExams= 1),'') +
        isnull( (select 'Alle Übungen müssen richtig beantwortet sein,' where tblThemes.calcStatusIncludeExercises= 1),'')
        ) AS [Certificate_x0020__x0028_Setting],
        (
        isnull((select 'Hide/Show,' where (tblThemes.themeViewerOptions &amp; 1 = 1)),'') +
        isnull((select 'Tools,' where (tblThemes.themeViewerOptions &amp; 2 = 2)),'') +
        isnull((select 'Set Bookmark,' where (tblThemes.themeViewerOptions &amp; 4 = 4)),'') +
        isnull((select 'Previous Page,' where (tblThemes.themeViewerOptions &amp; 8 = 8)),'') +
        isnull((select 'Next Page,' where (tblThemes.themeViewerOptions &amp; 16 = 16)),'') +
        isnull((select 'Next Step,' where (tblThemes.themeViewerOptions &amp; 32 = 32)),'') +
        isnull((select 'Learning-path recommendation,' where (tblThemes.themeViewerOptions &amp; 64 = 64)),'') +
        isnull((select 'Pause,' where (tblThemes.themeViewerOptions &amp; 128 = 128)),'') +
        isnull((select 'Maximize/Minimize,' where (tblThemes.themeViewerOptions &amp; 256 = 256)),'') +
        isnull((select 'Close,' where (tblThemes.themeViewerOptions &amp; 512 = 512)),'') +
        isnull((select 'Previous Step,' where (tblThemes.themeViewerOptions &amp; 1024 = 1024)),'') +
        isnull((select 'Speaker on/off,' where (tblThemes.themeViewerOptions &amp; 2048 = 2048)),'') +
        isnull((select 'Tree visible at start,' where (tblThemes.themeViewerOptions &amp; 4096 = 4096)),'') +
        isnull((select 'Automatic bookmark,' where (tblThemes.themeViewerOptions &amp; 32768 = 32768)),'')
        ) AS [Course_x0020_Viewer_x0020_Functi0],
        ThemeItems.created AS [Created0],
        ThemeItems.modified AS [Modified0],
        '|' + ThemeItems.description  + '|' AS [Description],
        ISNULL(tblThemes.StatusThreshold,0) AS [Learning_x0020_program_x0020_sta],
        '' AS [Tracing_x0020_of_x0020_SCOs],
        ThemeItems.title AS [Title_x0020_for_x0020_learners],
        tblThemes.player_id AS [Theme_x0020_Player],
        CASE
        WHEN (tblThemes.targetDevice = 0)
        THEN 'Desktop'
        WHEN (tblThemes.targetDevice = 1)
        THEN 'Tablet'
        WHEN (tblThemes.targetDevice = 2)
        THEN 'Smartphone'
        END AS [Target_x0020_Device],
        tblThemes.learningDuration AS [Learning_x0020_Time_x0020__x0028],
        CASE
        WHEN ThemeItems.deleted  IS NULL
        THEN 0
        ELSE
        1
        END AS [deleted],
        ISNULL((
        select  COUNT( id )
        from    tblThemeStructures
        where parent_id IS NOT NULL
        AND theme_id = ThemeItems.id
        group by theme_id, version
        having COUNT( id ) = 1
        ),0) AS [is monolith],
        ThemeItems.deleted AS [gel_x00f6_scht_x0020_am],
        du.FullUserName AS [gel_x00f6_scht_x0020_von]
        FROM
        tblThemes
        JOIN tblItems AS ThemeItems
        ON tblThemes.id = ThemeItems.id
        LEFT JOIN tblCertificates
        ON ThemeItems.certificate_id = tblCertificates.id
        LEFT JOIN v_Users cu
        ON cu.intUserCn = ThemeItems.createdBy_user_id
        LEFT JOIN v_Users mu
        ON mu.intUserCn = ThemeItems.modifiedBy_user_id
        LEFT JOIN v_Users du
        ON du.intUserCn = ThemeItems.deletedBy_user_id
        WHERE
        ThemeItems.mandator_id = @current_mandator_id
        ORDER BY
        importPath</command>
    </Report>
  </Reports>
</ReportsExport>