More actions
Nguyenduyan (talk | contribs) No edit summary |
Nguyenduyan (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 28: | Line 28: | ||
}} | }} | ||
=== <span style="color:#DF8621">'''Examples'''</span> === | === <span style="color:#DF8621">'''Examples'''</span> === | ||
<span style="color:#DF8621">Old way</span> | |||
<source lang="js"> | <source lang="js"> | ||
if(getRPQCompleted() && !getRPQTest() && D_Copied!=1 && D_Week == [202401] && Region==[1-5] && getRPQStatus() == 5) | if(getRPQCompleted() && !getRPQTest() && D_Copied!=1 && D_Week == [202401] && Region==[1-5] && getRPQStatus() == 5) | ||
print(getRPQId() + ","); | print(getRPQId() + ","); | ||
</source> | </source> | ||
<span style="color:#DF8621">New way</span> | |||
<source lang="js"> | <source lang="js"> | ||
QuestionnaireBatchJob batch = new QuestionnaireBatchJob(0); | QuestionnaireBatchJob batch = new QuestionnaireBatchJob(0); | ||
Line 44: | Line 44: | ||
print(batch.CurrentId + ","); | print(batch.CurrentId + ","); | ||
}); | }); | ||
</source> | |||
<span style="color:#DF8621">Old way</span> | |||
<source lang="js"> | |||
if (getRPQStatus() == 5 && getRPQTest() == false){ | |||
if (Q100_Relation_New[5] == empty && Q6_Awareness == [34]) print("ERROR"); | |||
} | |||
</source> | |||
<span style="color:#DF8621">New way</span> | |||
<source lang="js"> | |||
QuestionnaireBatchJob batch = new QuestionnaireBatchJob(0); | |||
//batch.LatestOnly = false; | |||
//batch.CompletedOnly = true; | |||
//batch.IncludeTest = false; | |||
array errorQAS; | |||
batch.Execute(function(Question Q100_Relation_New, Question Q6_Awareness){ | |||
QAS qas = new QAS(batch.CurrentId); | |||
if(qas.Status == 5 && Q100_Relation_New[5] == empty && Q6_Awareness == [34]){ | |||
errorQAS.Add(batch.CurrentId); | |||
} | |||
}); | |||
print(errorQAS.Count); | |||
print(errorQAS); | |||
</source> | </source> |
Latest revision as of 05:30, 6 January 2025
QuestionnaireBatchJob
Process each QAS with some custom logic in a optimal way.
Parent class
Inherits from object
Constructors
- (int questionnaireId "Id of the base questionnaire") - Process each QAS with some custom logic in a optimal way.
Methods
- Empty AttachQuestionnaire(int questionnaireId "Id of the questionnaire", bool latestOnly "If user has multiple qas, only include last created or error", bool completedOnly "Limit by qas that is completed", string questionLabel "Label of the question to load") - Load readonly question from another questionnaire based on UserId
- Empty AttachQuestionnaire(int questionnaireId "Id of the questionnaire", bool latestOnly "If user has multiple qas, only include last created or error", bool completedOnly "Limit by qas that is completed", string questionLabel "Label of the question to load", string alias "Alias to use in execute parameter naming") - Load readonly question from another questionnaire based on UserId with an alias
- Empty Execute(Function runner "The function called for each QAS - parameter names infers which questions to load") - Run the batch job - implicitly saves all modified question data
- (From object) string ToString() - The string representation of the object.
Properties
- bool CompletedOnly { get; set; } - Get/Set Limit by qas that is completed. Default true
- bool CurrentCompleted { get; set; } - Get/Set current qas to completed or not
- int CurrentId { get; } - Get current qas id
- bool CurrentIsTest { get; } - Get current qas is test qas
- bool IncludeTest { get; set; } - Get/Set if include test qas. Default false
- bool LatestOnly { get; set; } - Get/Set If user has multiple qas, only include last created or all. Default false
- string ObjectTypeName { get; } - The name of the type of object.
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Old way
if(getRPQCompleted() && !getRPQTest() && D_Copied!=1 && D_Week == [202401] && Region==[1-5] && getRPQStatus() == 5)
print(getRPQId() + ",");
New way
QuestionnaireBatchJob batch = new QuestionnaireBatchJob(0);
//batch.LatestOnly = false;
//batch.CompletedOnly = true;
//batch.IncludeTest = false;
batch.Execute(function(Question D_Copied, Question D_Week, Question Region){
QAS qas = new QAS(batch.CurrentId);
if(D_Copied!=1 && D_Week == [202401] && Region==[1-5] && qas.Status == 5)
print(batch.CurrentId + ",");
});
Old way
if (getRPQStatus() == 5 && getRPQTest() == false){
if (Q100_Relation_New[5] == empty && Q6_Awareness == [34]) print("ERROR");
}
New way
QuestionnaireBatchJob batch = new QuestionnaireBatchJob(0);
//batch.LatestOnly = false;
//batch.CompletedOnly = true;
//batch.IncludeTest = false;
array errorQAS;
batch.Execute(function(Question Q100_Relation_New, Question Q6_Awareness){
QAS qas = new QAS(batch.CurrentId);
if(qas.Status == 5 && Q100_Relation_New[5] == empty && Q6_Awareness == [34]){
errorQAS.Add(batch.CurrentId);
}
});
print(errorQAS.Count);
print(errorQAS);