Help

Scoring Code showing no errors, but also not working. All columns are correct.

Topic Labels: Data Extensions Sync
948 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Jbest04
4 - Data Explorer
4 - Data Explorer
// Async function to process the scoring
async function processScoring() {
// Revised scoring guide structure
const scoringGuide = {
"Question1": {
correct: ["$5,000,000 - $10,000,000", "$10,000,000 - $20,000,000", "$20,000,000 - $50,000,000", "$50,000,000+"],
partlycorrect: ["$500,000 - $1,000,000", "1,000,000 - $2,500,000", "2,500,000 - $5,000,000"]
},
"Question2": {
correct: [">500 employees", "350 - 500 employees", "150 - 350 employees"],
partlycorrect: ["10 - 50 employees", "50 - 150 employees"]
},
"Question3": {
correct: ["Financial Management, Time Management & Organized", "Construction Estimating, Organized & Risk Management"],
partlycorrect: ["Communication Skills, Leadership & Team Building"]
},
"Question4": {
correct: ["Directive", "Democratic", "Commanding", "Pacesetting"],
partlycorrect: ["Visionary", "Laissez-faire", "Coaching", "Transactional", "Affiliative", "Transformational"]
},
"Question5": {
correct: ["Client Satisfaction"],
partlycorrect: ["Quality Assurance", "Safety Compliance", "Time Efficiency", "Measurable Milestones", "Budget Management"]
},
"Question6": {
correct: ["Project Plan Revision: Adjust the project scope, prioritize tasks, or extend timelines based on budget constraints.",
"Stakeholder Communication: Communicate openly with stakeholders about budget issues and involve them in solution-finding."],
partlycorrect: ["Cost-Benefit Analysis: Evaluate project elements for potential cost-saving modifications or eliminations.",
"Regular Monitoring: Implement strict budget monitoring and continually adjust the plan to stay within financial limits.",
"Budget Review: Conduct a focused review to identify key areas causing budget overruns."]
}
};

// Select the table
const table = base.getTable('Applicant 1');

// Query the records
const query = await table.selectRecordsAsync();

// Iterate through the records to calculate the score
for (let record of query.records) {
let score = 0;

for (let [question, answers] of Object.entries(scoringGuide)) {
const candidateAnswer = record.getCellValueAsString(question);
console.log(`Question: ${question}, Candidate's Answer: ${candidateAnswer}`);

if (answers.correct.includes(candidateAnswer)) {
score += 5;
} else if (answers.partlycorrect.includes(candidateAnswer)) {
score += 3;
}

// Print the candidate's name, email, and total score
console.log(`Candidate Name: ${record.getCellValue('Name')}`);
console.log(`Candidate Email: ${record.getCellValue('Email')}`);
console.log(`Total Score: ${score}`);
}

// Update the 'Score' field for the current record
await table.updateRecordsAsync([
{
id: record.id,
fields: {
'Score': score.toString()
}
}
]);
}
}

processScoring(); // Call the function
1 Reply 1

Hi,
try to run

await processScoring()

also, using special tag for code

Alexey_Gusev_0-1703470651933.png

can raise the chance to get the answer 😀
otherwise it's hard to read.