﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="0f059255-332d-47c8-b063-16904303f16c" codekey="LockedQuestionsPerTopic" categoryCodekey="SpecialPurpose" name="Alle Fragen eines Thema entsperren" description="">
      <MetaData created="2010-10-21T15:38:00" createdBy="Administrator BISS" createdBy_user_id="12" modified="2012-04-12T13:32:02" modifiedBy="Anton Administrator" />
      <ExecutionDetails format="NoResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="345bbab2-62a8-424d-a6e6-133aeab480a4" mandatorName="BISS" isStandard="False" isUsedByMenu="False" />
      <Parameters>
        <Parameter id="9d50029d-fa4c-4935-872b-d0fae72cd5c0" isRequired="True" name="TasThema" contextName="TasThema" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="90" />
      </Roles>
      <command>-- Unlock all questions in a selection tas seminar category (Lehrgang)

-- Use this for testing:
-- declare @current_mandator_id uniqueidentifier
-- select @current_mandator_id=id from tblMandators where name='viwis'

-- define cursor
declare @otxt varchar(1000)
set @otxt = 'locked="True"'

declare curs cursor local fast_forward
for
select 
	id,
	textptr(questionXML),
	charindex(@otxt, questionXML)-1
from 
	tblTasQuestions 
where 
	mandator_id=@current_mandator_id and deleted is null and locked=1 and dbo.fn_GetCategoryIdForQuestion(tblTasQuestions.id, 2, 0)=@questionCategoryTheme_id

-- make loop
declare @ntxt varchar(1000)
set @ntxt = 'locked="False"'

declare @txtlen int
set @txtlen = len(@otxt)

declare @ptr binary(16)
declare @pos int
declare @id uniqueidentifier

-- Finally we can do our search and replace:

open curs

fetch next from curs into @id, @ptr, @pos

while @@fetch_status = 0
begin	
	updatetext tblTasQuestions.questionXML @ptr @pos @txtlen @ntxt
	update tblTasQuestions set locked = 0 where id=@id

	fetch next from curs into @id, @ptr, @pos	
end

close curs
deallocate curs
</command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="9d50029d-fa4c-4935-872b-d0fae72cd5c0" isSystem="False" name="TasThema" reportParameterType_id="c444d449-547b-4700-a0e1-415d7050af16" queryParameterName="@questionCategoryTheme_id" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="c444d449-547b-4700-a0e1-415d7050af16" isSystem="False" name="TAS Thema" datatype="GuidDDL" dataValueField="value" dataTextField="text">
      <query>SELECT tblTasQuestionCategories.id AS 'value', dbo.fn_GetResourceString(tblTasQuestionCategories.name_resource_id, 1031, 0, 1033) AS 'text' FROM tblTasQuestionCategories WHERE tblTasQuestionCategories.mandator_id = @current_mandator_id AND categoryType = 2 ORDER BY text</query>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>