Public
Sub
CreateTestFromSolution()
Dim
pDocInfo
As
cDocumentInfo
Set
pDocInfo =
New
cDocumentInfo
pDocInfo.FromFileName ActiveDocument.name
If
pDocInfo.TypeEnum <> itsCwTypeTestSolution
Then
MsgBox ActiveDocument.name &
" ist keine Test-Lösung (TES)"
, vbCritical + vbOKOnly,
"Courseware Prüfer - "
& ActiveDocument.name
Exit
Sub
End
If
Dim
na
As
String
, nna
As
String
, ndoc
As
Document, oDoc
As
Document
Set
oDoc = ActiveDocument
na = ActiveDocument.FullName
nna = Replace(na,
"TES"
,
"TE"
)
Set
ndoc = Application.Documents.Add(ActiveDocument.FullName)
ndoc.SaveAs2 FileName:=nna, FileFormat:=wdFormatXMLDocument, _
LockComments:=
False
, Password:=
""
, _
AddToRecentFiles:=
True
, WritePassword:=
""
, ReadOnlyRecommended:=
False
, _
EmbedTrueTypeFonts:=
False
, SaveNativePictureFormat:=
False
, SaveFormsData:=
False
, _
SaveAsAOCELetter:=
False
, CompatibilityMode:=15
oDoc.Close SaveChanges:=wdDoNotSaveChanges
ndoc.Activate
AutoTemplateSub
RemoveAllCheckComments
TestWatermark itsCwTypeTestQuestions
Dim
tpl
As
Template, bblat
As
BuildingBlock, bblps
As
BuildingBlock, ins
As
Boolean
For
Each
tpl
In
Application.Templates
If
tpl.name =
"ITS-Test-Questions.dotm"
And
ins =
False
Then
Set
bblat = tpl.BuildingBlockEntries(
"ITS:TE Anfangstext"
)
Set
bblps = tpl.BuildingBlockEntries(
"ITS:TE:PointsScored"
)
ins =
True
End
If
Next
tpl
Dim
para
As
Paragraph, st
As
Style, nlines
As
Integer
, nshapes
As
Integer
For
Each
para
In
ActiveDocument.Paragraphs
para.Range.
Select
Selection.Collapse wdCollapseStart
Set
st = para.Style
If
Not
st
Is
Nothing
Then
nlines = GetLinesCount(para)
nshapes = GetParaHeight(para)
Select
Case
st.NameLocal
Case
"ITS:TE:List:Dot:Answer"
para.Style = ActiveDocument.Styles(
"ITS:TE:List:Dot:DottedLine"
)
ReplaceWithDottedLine para, nlines, nshapes
Case
"ITS:TE:List:Letter:Answer"
para.Style = ActiveDocument.Styles(
"ITS:TE:List:Letter:DottedLine"
)
ReplaceWithDottedLine para, nlines, nshapes
Case
"ITS:TE:MultipleChoice:Answer"
para.Style = ActiveDocument.Styles(
"ITS:TE:MultipleChoice"
)
Case
"ITS:TE:Para1:Answer"
para.Style = ActiveDocument.Styles(
"ITS:TE:Para1:DottedLine"
)
ReplaceWithDottedLine para, nlines, nshapes
Case
"ITS:TE:Para2:Answer"
para.Style = ActiveDocument.Styles(
"ITS:TE:Para2:DottedLine"
)
ReplaceWithDottedLine para, nlines, nshapes
Case
"ITS:TE:Para3:Answer"
para.Style = ActiveDocument.Styles(
"ITS:TE:Para3:DottedLine"
)
ReplaceWithDottedLine para, nlines, nshapes
Case
"ITS:TE:SolutionSpace"
para.Style = ActiveDocument.Styles(
"ITS:TE:PointsScored"
)
bblps.Insert para.Range
Case
"ITS:TE:Compose"